diff options
-rwxr-xr-x | chrome/browser/automation/automation_provider.cc | 4 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 4 | ||||
-rw-r--r-- | chrome/browser/debugger/debugger_remote_service.cc | 6 | ||||
-rw-r--r-- | chrome/browser/debugger/devtools_manager.cc | 18 | ||||
-rw-r--r-- | chrome/browser/debugger/devtools_manager.h | 3 | ||||
-rw-r--r-- | chrome/browser/debugger/devtools_sanity_unittest.cc | 5 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 3 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_ui.cc | 2 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 18 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 6 | ||||
-rw-r--r-- | chrome/browser/tab_contents/render_view_context_menu.cc | 4 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 2 |
12 files changed, 38 insertions, 37 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 5db7a8a..ce26d28 100755 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -28,6 +28,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/dom_operation_notification_details.h" +#include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/download/download_shelf.h" #include "chrome/browser/extensions/extension_message_service.h" @@ -2072,7 +2073,8 @@ void AutomationProvider::HandleInspectElementRequest( DCHECK(reply_message_ == NULL); reply_message_ = reply_message; - tab_contents->render_view_host()->InspectElementAt(x, y); + DevToolsManager::GetInstance()->InspectElement( + tab_contents->render_view_host(), x, y); } else { AutomationMsg_InspectElement::WriteReplyParams(reply_message, -1); Send(reply_message); diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 5ce3891..936d896 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1075,8 +1075,8 @@ void Browser::OpenCreateShortcutsDialog() { void Browser::OpenJavaScriptConsole() { UserMetrics::RecordAction(L"ShowJSConsole", profile_); - GetSelectedTabContents()->render_view_host()-> - ShowJavaScriptConsole(); + DevToolsManager::GetInstance()->OpenDevToolsWindow( + GetSelectedTabContents()->render_view_host()); } void Browser::OpenTaskManager() { diff --git a/chrome/browser/debugger/debugger_remote_service.cc b/chrome/browser/debugger/debugger_remote_service.cc index 47f503e3..9a46c63 100644 --- a/chrome/browser/debugger/debugger_remote_service.cc +++ b/chrome/browser/debugger/debugger_remote_service.cc @@ -229,7 +229,7 @@ void DebuggerRemoteService::AttachToTab(const std::string& destination, if (client_host == NULL) { client_host = delegate_->inspectable_tab_proxy()->NewClientHost(tab_uid, this); - DevToolsManager* manager = g_browser_process->devtools_manager(); + DevToolsManager* manager = DevToolsManager::GetInstance(); if (manager != NULL) { manager->RegisterDevToolsClientHostFor(target_host, client_host); response->SetInteger(kResultWide, RESULT_OK); @@ -283,7 +283,7 @@ bool DebuggerRemoteService::DispatchDebuggerCommand(int tab_uid, response->SetInteger(kResultWide, RESULT_UNKNOWN_TAB); return true; } - DevToolsManager* manager = g_browser_process->devtools_manager(); + DevToolsManager* manager = DevToolsManager::GetInstance(); if (manager == NULL) { response->SetInteger(kResultWide, RESULT_DEBUGGER_ERROR); return true; @@ -305,7 +305,7 @@ bool DebuggerRemoteService::DispatchDebuggerCommand(int tab_uid, DictionaryValue* v8_command_value; content->GetDictionary(kDataWide, &v8_command_value); JSONWriter::Write(v8_command_value, false, &v8_command); - g_browser_process->devtools_manager()->ForwardToDevToolsAgent( + manager->ForwardToDevToolsAgent( client_host, DevToolsAgentMsg_DebuggerCommand(v8_command)); // Do not send the response right now, as the JSON will be received from // the V8 debugger asynchronously. diff --git a/chrome/browser/debugger/devtools_manager.cc b/chrome/browser/debugger/devtools_manager.cc index 5e5907f..f6dcc7b 100644 --- a/chrome/browser/debugger/devtools_manager.cc +++ b/chrome/browser/debugger/devtools_manager.cc @@ -5,6 +5,7 @@ #include "chrome/browser/debugger/devtools_manager.h" #include "base/message_loop.h" +#include "chrome/browser/browser_process.h" #include "chrome/browser/debugger/devtools_window.h" #include "chrome/browser/debugger/devtools_client_host.h" #include "chrome/browser/profile.h" @@ -15,8 +16,14 @@ #include "chrome/common/pref_service.h" #include "googleurl/src/gurl.h" +// static +DevToolsManager* DevToolsManager::GetInstance() { + return g_browser_process->devtools_manager(); +} + DevToolsManager::DevToolsManager() - : inspected_rvh_for_reopen_(NULL) { + : inspected_rvh_for_reopen_(NULL), + in_initial_show_(false) { } DevToolsManager::~DevToolsManager() { @@ -97,8 +104,11 @@ void DevToolsManager::OpenDevToolsWindow(RenderViewHost* inspected_rvh) { RegisterDevToolsClientHostFor(inspected_rvh, host); } DevToolsWindow* window = host->AsDevToolsWindow(); - if (window) + if (window) { + in_initial_show_ = true; window->Show(); + in_initial_show_ = false; + } } void DevToolsManager::InspectElement(RenderViewHost* inspected_rvh, @@ -148,6 +158,10 @@ void DevToolsManager::UnregisterDevToolsClientHostFor( void DevToolsManager::OnNavigatingToPendingEntry(RenderViewHost* rvh, RenderViewHost* dest_rvh, const GURL& gurl) { + if (in_initial_show_) { + // Mute this even in case it is caused by the initial show routines. + return; + } DevToolsClientHost* client_host = GetDevToolsClientHostFor(rvh); if (client_host) { diff --git a/chrome/browser/debugger/devtools_manager.h b/chrome/browser/debugger/devtools_manager.h index d911250..3790d27 100644 --- a/chrome/browser/debugger/devtools_manager.h +++ b/chrome/browser/debugger/devtools_manager.h @@ -22,6 +22,8 @@ class RenderViewHost; class DevToolsManager : public DevToolsClientHost::CloseListener, public base::RefCounted<DevToolsManager> { public: + static DevToolsManager* GetInstance(); + DevToolsManager(); virtual ~DevToolsManager(); @@ -87,6 +89,7 @@ private: ClientHostToInspectedRvhMap; ClientHostToInspectedRvhMap client_host_to_inspected_rvh_; RenderViewHost* inspected_rvh_for_reopen_; + bool in_initial_show_; DISALLOW_COPY_AND_ASSIGN(DevToolsManager); }; diff --git a/chrome/browser/debugger/devtools_sanity_unittest.cc b/chrome/browser/debugger/devtools_sanity_unittest.cc index d52d9cd..8e7deb5 100644 --- a/chrome/browser/debugger/devtools_sanity_unittest.cc +++ b/chrome/browser/debugger/devtools_sanity_unittest.cc @@ -4,7 +4,6 @@ #include "base/command_line.h" #include "chrome/browser/browser.h" -#include "chrome/browser/browser_process.h" #include "chrome/browser/debugger/devtools_client_host.h" #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/debugger/devtools_window.h" @@ -72,7 +71,7 @@ class DevToolsSanityTest : public InProcessBrowserTest { TabContents* tab = browser()->GetTabContentsAt(0); inspected_rvh_ = tab->render_view_host(); - DevToolsManager* devtools_manager = g_browser_process->devtools_manager(); + DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); devtools_manager->OpenDevToolsWindow(inspected_rvh_); DevToolsClientHost* client_host = @@ -84,7 +83,7 @@ class DevToolsSanityTest : public InProcessBrowserTest { } void CloseDevToolsWindow() { - DevToolsManager* devtools_manager = g_browser_process->devtools_manager(); + DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); devtools_manager->UnregisterDevToolsClientHostFor(inspected_rvh_); BrowserClosedObserver close_observer(window_->browser()); } diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index cf84ea2..733492b 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -9,7 +9,6 @@ #include "base/string_util.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" -#include "chrome/browser/browser_process.h" #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/extensions/extension_message_service.h" #include "chrome/browser/extensions/extension_process_manager.h" @@ -248,7 +247,7 @@ void ExtensionHost::ShowCreatedWidget(int route_id, void ExtensionHost::ShowContextMenu(const ContextMenuParams& params) { // TODO(erikkay) - This is a temporary hack. Show a menu here instead. - g_browser_process->devtools_manager()->OpenDevToolsWindow(render_view_host()); + DevToolsManager::GetInstance()->OpenDevToolsWindow(render_view_host()); } void ExtensionHost::StartDragging(const WebDropData& drop_data) { diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index 02ad15f..1edacb8 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -118,7 +118,7 @@ void ExtensionsDOMHandler::HandleInspectMessage(const Value* value) { return; } - g_browser_process->devtools_manager()->OpenDevToolsWindow(host); + DevToolsManager::GetInstance()->OpenDevToolsWindow(host); } void ExtensionsDOMHandler::HandleUninstallMessage(const Value* value) { diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 3a8cb2c..8833c41 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -12,7 +12,6 @@ #include "base/string_util.h" #include "base/time.h" #include "base/waitable_event.h" -#include "chrome/browser/browser_process.h" #include "chrome/browser/child_process_security_policy.h" #include "chrome/browser/cross_site_request_manager.h" #include "chrome/browser/debugger/devtools_manager.h" @@ -119,7 +118,7 @@ RenderViewHost::RenderViewHost(SiteInstance* instance, } RenderViewHost::~RenderViewHost() { - DevToolsManager* devtools_manager = g_browser_process->devtools_manager(); + DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); if (devtools_manager) // NULL in tests devtools_manager->UnregisterDevToolsClientHostFor(this); @@ -562,16 +561,6 @@ void RenderViewHost::CopyImageAt(int x, int y) { Send(new ViewMsg_CopyImageAt(routing_id(), x, y)); } -void RenderViewHost::InspectElementAt(int x, int y) { - DevToolsManager* manager = g_browser_process->devtools_manager(); - manager->InspectElement(this, x, y); -} - -void RenderViewHost::ShowJavaScriptConsole() { - DevToolsManager* manager = g_browser_process->devtools_manager(); - manager->OpenDevToolsWindow(this); -} - void RenderViewHost::DragSourceEndedAt( int client_x, int client_y, int screen_x, int screen_y) { Send(new ViewMsg_DragSourceEndedOrMoved( @@ -1234,12 +1223,11 @@ void RenderViewHost::OnAddMessageToConsole(const std::wstring& message, } void RenderViewHost::OnForwardToDevToolsAgent(const IPC::Message& message) { - g_browser_process->devtools_manager()->ForwardToDevToolsAgent(this, message); + DevToolsManager::GetInstance()->ForwardToDevToolsAgent(this, message); } void RenderViewHost::OnForwardToDevToolsClient(const IPC::Message& message) { - g_browser_process->devtools_manager()->ForwardToDevToolsClient(this, - message); + DevToolsManager::GetInstance()->ForwardToDevToolsClient(this, message); } void RenderViewHost::OnUserMetricsRecordAction(const std::wstring& action) { diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 84051f2..16e0acc 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -285,12 +285,6 @@ class RenderViewHost : public RenderWidgetHost { // Copies the image at the specified point. void CopyImageAt(int x, int y); - // Inspects the element at the specified point using the Web Inspector. - void InspectElementAt(int x, int y); - - // Show the JavaScript console. - void ShowJavaScriptConsole(); - // Notifies the renderer that a drop occurred. This is necessary because the // render may be the one that started the drag. void DragSourceEndedAt( diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index ecb3eba..94c789d 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -11,6 +11,7 @@ #include "base/scoped_clipboard_writer.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/fonts_languages_window.h" #include "chrome/browser/page_info_window.h" @@ -624,7 +625,8 @@ void RenderViewContextMenu::CopyImageAt(int x, int y) { } void RenderViewContextMenu::Inspect(int x, int y) { - source_tab_contents_->render_view_host()->InspectElementAt(x, y); + DevToolsManager::GetInstance()->InspectElement( + source_tab_contents_->render_view_host(), x, y); } void RenderViewContextMenu::WriteTextToClipboard( diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index c19719b..7aecca5 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -644,7 +644,7 @@ bool TabContents::NavigateToPendingEntry(bool reload) { return false; // Unable to create the desired render view host. // Tell DevTools agent that it is attached prior to the navigation. - DevToolsManager* devtools_manager = g_browser_process->devtools_manager(); + DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); if (devtools_manager) { // NULL in unit tests. devtools_manager->OnNavigatingToPendingEntry( render_view_host(), |