Commit bbc51c91 authored by yurys@chromium.org's avatar yurys@chromium.org

DevTools: remove obsolete methods from DevToolsClientHost

BUG=104625
TEST=Existing tests

Review URL: http://codereview.chromium.org/8636011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111139 0039d316-1c4b-4281-b951-d872f2087c98
parent 1d067221
......@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/json/json_writer.h"
#include "base/lazy_instance.h"
#include "base/stringprintf.h"
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
......@@ -44,6 +45,13 @@
#include "content/public/common/bindings_policy.h"
#include "grit/generated_resources.h"
typedef std::vector<DevToolsWindow*> DevToolsWindowList;
namespace {
base::LazyInstance<DevToolsWindowList,
base::LeakyLazyInstanceTraits<DevToolsWindowList> >
g_instances = LAZY_INSTANCE_INITIALIZER;
} // namespace
const char DevToolsWindow::kDevToolsApp[] = "DevToolsApp";
// static
......@@ -60,9 +68,6 @@ TabContentsWrapper* DevToolsWindow::GetDevToolsContents(
return NULL;
DevToolsManager* manager = DevToolsManager::GetInstance();
if (!manager)
return NULL; // Happens only in tests.
DevToolsClientHost* client_host = manager->
GetDevToolsClientHostFor(inspected_tab->render_view_host());
DevToolsWindow* window = AsDevToolsWindow(client_host);
......@@ -72,12 +77,16 @@ TabContentsWrapper* DevToolsWindow::GetDevToolsContents(
}
// static
DevToolsWindow* DevToolsWindow::FindDevToolsWindow(
RenderViewHost* window_rvh) {
DevToolsClientHost* client_host =
DevToolsClientHost::FindOwnerClientHost(window_rvh);
return client_host != NULL ? DevToolsWindow::AsDevToolsWindow(client_host)
: NULL;
bool DevToolsWindow::IsDevToolsWindow(RenderViewHost* window_rvh) {
if (g_instances == NULL)
return NULL;
DevToolsWindowList& instances = g_instances.Get();
for (DevToolsWindowList::iterator it = instances.begin();
it != instances.end(); ++it) {
if ((*it)->tab_contents_->render_view_host() == window_rvh)
return true;
}
return false;
}
// static
......@@ -163,6 +172,7 @@ DevToolsWindow::DevToolsWindow(TabContentsWrapper* tab_contents,
docked_(docked),
is_loaded_(false),
action_on_load_(DEVTOOLS_TOGGLE_ACTION_NONE) {
g_instances.Get().push_back(this);
// Wipe out page icon so that the default application icon is used.
NavigationEntry* entry = tab_contents_->controller().GetActiveEntry();
entry->favicon().set_bitmap(SkBitmap());
......@@ -191,6 +201,12 @@ DevToolsWindow::DevToolsWindow(TabContentsWrapper* tab_contents,
}
DevToolsWindow::~DevToolsWindow() {
DevToolsWindowList& instances = g_instances.Get();
DevToolsWindowList::iterator it = std::find(instances.begin(),
instances.end(),
this);
DCHECK(it != instances.end());
instances.erase(it);
}
void DevToolsWindow::SendMessageToClient(const IPC::Message& message) {
......@@ -231,10 +247,6 @@ void DevToolsWindow::TabReplaced(TabContents* new_tab) {
inspected_tab_ = new_tab_wrapper;
}
RenderViewHost* DevToolsWindow::GetClientRenderViewHost() {
return tab_contents_->render_view_host();
}
void DevToolsWindow::Show(DevToolsToggleAction action) {
if (docked_) {
Browser* inspected_browser;
......@@ -646,10 +658,15 @@ DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow(
// static
DevToolsWindow* DevToolsWindow::AsDevToolsWindow(
DevToolsClientHost* client_host) {
if (!client_host)
if (!client_host || g_instances == NULL)
return NULL;
if (client_host->GetClientRenderViewHost() != NULL)
return static_cast<DevToolsWindow*>(client_host);
DevToolsWindowList& instances = g_instances.Get();
for (DevToolsWindowList::iterator it = instances.begin();
it != instances.end(); ++it) {
DevToolsClientHost* client = *it;
if (client == client_host)
return *it;
}
return NULL;
}
......
......@@ -43,7 +43,7 @@ class DevToolsWindow
static const char kDevToolsApp[];
static void RegisterUserPrefs(PrefService* prefs);
static TabContentsWrapper* GetDevToolsContents(TabContents* inspected_tab);
static DevToolsWindow* FindDevToolsWindow(RenderViewHost* window_rvh);
static bool IsDevToolsWindow(RenderViewHost* window_rvh);
static DevToolsWindow* OpenDevToolsWindowForWorker(
Profile* profile,
......@@ -60,7 +60,6 @@ class DevToolsWindow
virtual void SendMessageToClient(const IPC::Message& message) OVERRIDE;
virtual void InspectedTabClosing() OVERRIDE;
virtual void TabReplaced(TabContents* new_tab) OVERRIDE;
virtual RenderViewHost* GetClientRenderViewHost() OVERRIDE;
RenderViewHost* GetRenderViewHost();
void Show(DevToolsToggleAction action);
......
......@@ -7,13 +7,13 @@
#include <cmath>
#include "base/sys_string_conversions.h"
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/spellchecker/spellchecker_platform_engine.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#import "chrome/browser/ui/cocoa/history_overlay_controller.h"
#import "chrome/browser/ui/cocoa/view_id_util.h"
#include "chrome/common/spellcheck_messages.h"
#include "content/browser/debugger/devtools_client_host.h"
#include "content/browser/mac/closure_blocks_leopard_compat.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_view_host_observer.h"
......@@ -165,8 +165,8 @@ class SpellCheckRenderViewObserver : public RenderViewHostObserver {
if (!render_widget_host_ || !render_widget_host_->IsRenderView())
return NO;
bool isDevtoolsRwhv = DevToolsClientHost::FindOwnerClientHost(
static_cast<RenderViewHost*>(render_widget_host_)) != NULL;
bool isDevtoolsRwhv = DevToolsWindow::IsDevToolsWindow(
static_cast<RenderViewHost*>(render_widget_host_));
if (isDevtoolsRwhv)
return NO;
......
......@@ -2,45 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <algorithm>
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "content/browser/debugger/devtools_client_host.h"
#include "content/browser/debugger/devtools_manager.h"
typedef std::vector<DevToolsClientHost*> DevToolsClientHostList;
namespace {
base::LazyInstance<DevToolsClientHostList,
base::LeakyLazyInstanceTraits<DevToolsClientHostList> >
g_instances = LAZY_INSTANCE_INITIALIZER;
} // namespace
// static
DevToolsClientHost* DevToolsClientHost::FindOwnerClientHost(
RenderViewHost* client_rvh) {
for (DevToolsClientHostList::iterator it = g_instances.Get().begin();
it != g_instances.Get().end(); ++it) {
if ((*it)->GetClientRenderViewHost() == client_rvh)
return *it;
}
return NULL;
}
#include "content/browser/debugger/devtools_manager.h"
DevToolsClientHost::~DevToolsClientHost() {
DevToolsClientHostList::iterator it = std::find(g_instances.Get().begin(),
g_instances.Get().end(),
this);
DCHECK(it != g_instances.Get().end());
g_instances.Get().erase(it);
}
RenderViewHost* DevToolsClientHost::GetClientRenderViewHost() {
return NULL;
}
DevToolsClientHost::DevToolsClientHost() : close_listener_(NULL) {
g_instances.Get().push_back(this);
}
void DevToolsClientHost::ForwardToDevToolsAgent(const IPC::Message& message) {
......
......@@ -7,7 +7,6 @@
#pragma once
#include <string>
#include <vector>
#include "base/basictypes.h"
#include "content/common/content_export.h"
......@@ -16,7 +15,6 @@ namespace IPC {
class Message;
}
class RenderViewHost;
class TabContents;
// Describes interface for managing devtools clients from browser process. There
......@@ -33,8 +31,6 @@ class CONTENT_EXPORT DevToolsClientHost {
DISALLOW_COPY_AND_ASSIGN(CloseListener);
};
static DevToolsClientHost* FindOwnerClientHost(RenderViewHost* client_rvh);
virtual ~DevToolsClientHost();
// This method is called when tab inspected by this devtools client is
......@@ -56,10 +52,6 @@ class CONTENT_EXPORT DevToolsClientHost {
// TabStripModel::ReplaceTabContentsAt.
virtual void TabReplaced(TabContents* new_tab) = 0;
// Returns client (front-end) RenderViewHost implementation of this
// client host if applicable. NULL otherwise.
virtual RenderViewHost* GetClientRenderViewHost();
protected:
DevToolsClientHost();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment