summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-18 12:24:49 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-18 12:24:49 +0000
commit67d55aca476b3389a51f555b40af521afee4435c (patch)
tree0b48faf87dbd3b0a79e8865dba4fff16c7da4c9e
parent5d1e6661ba9b10fe59831e851e61ac4b966b98a1 (diff)
downloadchromium_src-67d55aca476b3389a51f555b40af521afee4435c.zip
chromium_src-67d55aca476b3389a51f555b40af521afee4435c.tar.gz
chromium_src-67d55aca476b3389a51f555b40af521afee4435c.tar.bz2
DevTools: migrate DevToolsFrontendHost from RenderViewHostObserver to WebContents observer.
BUG=170476 Review URL: https://chromiumcodereview.appspot.com/11967044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177650 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/devtools/devtools_sanity_browsertest.cc2
-rw-r--r--chrome/browser/devtools/devtools_window.cc18
-rw-r--r--chrome/browser/devtools/devtools_window.h5
-rw-r--r--content/browser/devtools/devtools_frontend_host.cc5
-rw-r--r--content/browser/devtools/devtools_frontend_host.h7
5 files changed, 20 insertions, 17 deletions
diff --git a/chrome/browser/devtools/devtools_sanity_browsertest.cc b/chrome/browser/devtools/devtools_sanity_browsertest.cc
index 2fc78be..97162ca 100644
--- a/chrome/browser/devtools/devtools_sanity_browsertest.cc
+++ b/chrome/browser/devtools/devtools_sanity_browsertest.cc
@@ -388,7 +388,7 @@ class WorkerDevToolsSanityTest : public InProcessBrowserTest {
worker_data->worker_route_id));
DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(
agent_host,
- window_->devtools_client_host());
+ window_->GetDevToolsClientHostForTest());
RenderViewHost* client_rvh = window_->GetRenderViewHost();
WebContents* client_contents = WebContents::FromRenderViewHost(client_rvh);
if (client_contents->IsLoading()) {
diff --git a/chrome/browser/devtools/devtools_window.cc b/chrome/browser/devtools/devtools_window.cc
index 927c276..822039f 100644
--- a/chrome/browser/devtools/devtools_window.cc
+++ b/chrome/browser/devtools/devtools_window.cc
@@ -138,7 +138,7 @@ DevToolsWindow* DevToolsWindow::OpenDevToolsWindowForWorker(
window = DevToolsWindow::CreateDevToolsWindowForWorker(profile);
DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(
worker_agent,
- window->frontend_host_);
+ window->frontend_host_.get());
}
window->Show(DEVTOOLS_TOGGLE_ACTION_SHOW);
return window;
@@ -217,8 +217,8 @@ DevToolsWindow::DevToolsWindow(WebContents* web_contents,
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
width_(-1),
height_(-1) {
- frontend_host_ = DevToolsClientHost::CreateDevToolsFrontendHost(web_contents,
- this);
+ frontend_host_.reset(
+ DevToolsClientHost::CreateDevToolsFrontendHost(web_contents, this));
file_helper_.reset(new DevToolsFileHelper(web_contents, profile));
g_instances.Get().push_back(this);
@@ -314,6 +314,10 @@ void DevToolsWindow::Show(DevToolsToggleAction action) {
ScheduleAction(action);
}
+DevToolsClientHost* DevToolsWindow::GetDevToolsClientHostForTest() {
+ return frontend_host_.get();
+}
+
int DevToolsWindow::GetWidth(int container_width) {
if (width_ == -1) {
width_ = profile_->GetPrefs()->
@@ -543,7 +547,7 @@ void DevToolsWindow::Observe(int type,
// of window.Close event.
// Notify manager that this DevToolsClientHost no longer exists and
// initiate self-destuct here.
- DevToolsManager::GetInstance()->ClientHostClosing(frontend_host_);
+ DevToolsManager::GetInstance()->ClientHostClosing(frontend_host_.get());
UpdateBrowserToolbar();
delete this;
}
@@ -687,7 +691,7 @@ DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow(
inspected_rvh->GetProcess()->GetBrowserContext());
DevToolsDockSide dock_side = GetDockSideFromPrefs(profile);
window = Create(profile, inspected_rvh, dock_side, false);
- manager->RegisterDevToolsClientHostFor(agent, window->frontend_host_);
+ manager->RegisterDevToolsClientHostFor(agent, window->frontend_host_.get());
do_open = true;
}
@@ -712,7 +716,7 @@ DevToolsWindow* DevToolsWindow::AsDevToolsWindow(
DevToolsWindowList& instances = g_instances.Get();
for (DevToolsWindowList::iterator it = instances.begin();
it != instances.end(); ++it) {
- if ((*it)->frontend_host_ == client_host)
+ if ((*it)->frontend_host_.get() == client_host)
return *it;
}
return NULL;
@@ -745,7 +749,7 @@ void DevToolsWindow::ActivateWindow() {
void DevToolsWindow::CloseWindow() {
DCHECK(IsDocked());
- DevToolsManager::GetInstance()->ClientHostClosing(frontend_host_);
+ DevToolsManager::GetInstance()->ClientHostClosing(frontend_host_.get());
InspectedContentsClosing();
}
diff --git a/chrome/browser/devtools/devtools_window.h b/chrome/browser/devtools/devtools_window.h
index 58a9b0b..c1aa383 100644
--- a/chrome/browser/devtools/devtools_window.h
+++ b/chrome/browser/devtools/devtools_window.h
@@ -89,7 +89,8 @@ class DevToolsWindow : private content::NotificationObserver,
content::WebContents* web_contents() { return web_contents_; }
Browser* browser() { return browser_; } // For tests.
DevToolsDockSide dock_side() { return dock_side_; }
- content::DevToolsClientHost* devtools_client_host() { return frontend_host_; }
+
+ content::DevToolsClientHost* GetDevToolsClientHostForTest();
// Returns preferred devtools window width for given |container_width|. It
// tries to use the saved window width, or, if none exists, 1/3 of the
@@ -209,7 +210,7 @@ class DevToolsWindow : private content::NotificationObserver,
bool is_loaded_;
DevToolsToggleAction action_on_load_;
content::NotificationRegistrar registrar_;
- content::DevToolsClientHost* frontend_host_;
+ scoped_ptr<content::DevToolsClientHost> frontend_host_;
base::WeakPtrFactory<DevToolsWindow> weak_factory_;
scoped_ptr<DevToolsFileHelper> file_helper_;
int width_;
diff --git a/content/browser/devtools/devtools_frontend_host.cc b/content/browser/devtools/devtools_frontend_host.cc
index e29bd54..4e8966b 100644
--- a/content/browser/devtools/devtools_frontend_host.cc
+++ b/content/browser/devtools/devtools_frontend_host.cc
@@ -31,8 +31,7 @@ void DevToolsClientHost::SetupDevToolsFrontendClient(
DevToolsFrontendHost::DevToolsFrontendHost(
WebContentsImpl* web_contents,
DevToolsFrontendHostDelegate* delegate)
- : RenderViewHostObserver(web_contents->GetRenderViewHost()),
- web_contents_(web_contents),
+ : WebContentsObserver(web_contents),
delegate_(delegate) {
}
@@ -43,7 +42,7 @@ DevToolsFrontendHost::~DevToolsFrontendHost() {
void DevToolsFrontendHost::DispatchOnInspectorFrontend(
const std::string& message) {
RenderViewHostImpl* target_host =
- static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost());
+ static_cast<RenderViewHostImpl*>(web_contents()->GetRenderViewHost());
target_host->Send(new DevToolsClientMsg_DispatchOnInspectorFrontend(
target_host->GetRoutingID(),
message));
diff --git a/content/browser/devtools/devtools_frontend_host.h b/content/browser/devtools/devtools_frontend_host.h
index e06db3a..87c6924 100644
--- a/content/browser/devtools/devtools_frontend_host.h
+++ b/content/browser/devtools/devtools_frontend_host.h
@@ -10,7 +10,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "content/public/browser/devtools_client_host.h"
-#include "content/public/browser/render_view_host_observer.h"
+#include "content/public/browser/web_contents_observer.h"
namespace content {
@@ -22,7 +22,7 @@ class WebContentsImpl;
// embedder. This allows us to avoid exposing DevTools client messages through
// the content public API.
class DevToolsFrontendHost : public DevToolsClientHost,
- public RenderViewHostObserver {
+ public WebContentsObserver {
public:
DevToolsFrontendHost(WebContentsImpl* web_contents,
DevToolsFrontendHostDelegate* delegate);
@@ -35,7 +35,7 @@ class DevToolsFrontendHost : public DevToolsClientHost,
virtual void InspectedContentsClosing() OVERRIDE;
virtual void ReplacedWithAnotherClient() OVERRIDE;
- // RenderViewHostObserver overrides.
+ // WebContentsObserver overrides.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
void OnDispatchOnInspectorBackend(const std::string& message);
@@ -50,7 +50,6 @@ class DevToolsFrontendHost : public DevToolsClientHost,
void OnAddFileSystem();
void OnRemoveFileSystem(const std::string& file_system_path);
- WebContentsImpl* web_contents_;
DevToolsFrontendHostDelegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(DevToolsFrontendHost);
};