#ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_CONTROLLER_H_
#define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_UI_CONTROLLER_H_
#include <memory>
#include "base/callback_list.h"
#include "base/memory/raw_ptr.h"
#include "ui/views/focus/external_focus_tracker.h"
class ContentsContainerView;
namespace content {
class WebContents;
}
namespace views {
class WebView;
}
class DevtoolsUIController {
public:
explicit DevtoolsUIController(
std::vector<ContentsContainerView*> contents_container_views);
~DevtoolsUIController();
void TearDown();
bool UpdateDevtools(ContentsContainerView* contents_container,
content::WebContents* web_contents,
bool update_devtools_web_contents);
private:
class DevtoolsWebViewController {
public:
explicit DevtoolsWebViewController(
ContentsContainerView* contents_container_view);
DevtoolsWebViewController(const DevtoolsWebViewController&) = delete;
DevtoolsWebViewController& operator=(const DevtoolsWebViewController&) =
delete;
~DevtoolsWebViewController();
void OnWebContentsAttached(views::WebView* web_view);
void OnWebContentsDetached(views::WebView* web_view);
bool UpdateDevtools(content::WebContents* web_contents,
bool update_devtools_web_contents);
void RestoreFocus();
private:
raw_ptr<ContentsContainerView> contents_container_view_;
std::unique_ptr<views::ExternalFocusTracker> devtools_focus_tracker_;
base::CallbackListSubscription web_contents_attached_subscription_;
base::CallbackListSubscription web_contents_detached_subscription_;
};
std::map<ContentsContainerView*, std::unique_ptr<DevtoolsWebViewController>>
devtools_web_view_controllers_;
};
#endif