Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 #include "chrome/browser/themes/theme_service_factory.h" | 24 #include "chrome/browser/themes/theme_service_factory.h" |
| 25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| 26 #include "chrome/browser/ui/browser_list.h" | 26 #include "chrome/browser/ui/browser_list.h" |
| 27 #include "chrome/browser/ui/browser_window.h" | 27 #include "chrome/browser/ui/browser_window.h" |
| 28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 29 #include "chrome/common/chrome_notification_types.h" | 29 #include "chrome/common/chrome_notification_types.h" |
| 30 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 31 #include "chrome/common/render_messages.h" | 31 #include "chrome/common/render_messages.h" |
| 32 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
| 33 #include "content/browser/browsing_instance.h" | 33 #include "content/browser/browsing_instance.h" |
| 34 #include "content/browser/debugger/devtools_manager.h" | |
| 35 #include "content/browser/in_process_webkit/session_storage_namespace.h" | 34 #include "content/browser/in_process_webkit/session_storage_namespace.h" |
| 36 #include "content/browser/load_notification_details.h" | 35 #include "content/browser/load_notification_details.h" |
| 37 #include "content/browser/renderer_host/render_view_host.h" | 36 #include "content/browser/renderer_host/render_view_host.h" |
| 38 #include "content/browser/tab_contents/navigation_controller.h" | 37 #include "content/browser/tab_contents/navigation_controller.h" |
| 39 #include "content/browser/tab_contents/navigation_entry.h" | 38 #include "content/browser/tab_contents/navigation_entry.h" |
| 40 #include "content/browser/tab_contents/tab_contents.h" | 39 #include "content/browser/tab_contents/tab_contents.h" |
| 41 #include "content/browser/tab_contents/tab_contents_view.h" | 40 #include "content/browser/tab_contents/tab_contents_view.h" |
| 42 #include "content/common/devtools_messages.h" | |
| 43 #include "content/public/browser/content_browser_client.h" | 41 #include "content/public/browser/content_browser_client.h" |
| 44 #include "content/public/browser/devtools_frontend_window.h" | 42 #include "content/public/browser/devtools_agent_host_registry.h" |
| 43 #include "content/public/browser/devtools_manager.h" | |
| 45 #include "content/public/browser/notification_source.h" | 44 #include "content/public/browser/notification_source.h" |
| 46 #include "content/public/common/bindings_policy.h" | 45 #include "content/public/common/bindings_policy.h" |
| 47 #include "grit/generated_resources.h" | 46 #include "grit/generated_resources.h" |
| 48 | 47 |
| 49 typedef std::vector<DevToolsWindow*> DevToolsWindowList; | 48 typedef std::vector<DevToolsWindow*> DevToolsWindowList; |
| 50 namespace { | 49 namespace { |
| 51 base::LazyInstance<DevToolsWindowList, | 50 base::LazyInstance<DevToolsWindowList, |
| 52 base::LeakyLazyInstanceTraits<DevToolsWindowList> > | 51 base::LeakyLazyInstanceTraits<DevToolsWindowList> > |
| 53 g_instances = LAZY_INSTANCE_INITIALIZER; | 52 g_instances = LAZY_INSTANCE_INITIALIZER; |
| 54 } // namespace | 53 } // namespace |
| 55 | 54 |
| 55 using content::DevToolsAgentHost; | |
| 56 using content::DevToolsAgentHostRegistry; | |
| 57 using content::DevToolsClientHost; | |
| 58 using content::DevToolsManager; | |
| 59 | |
| 56 const char DevToolsWindow::kDevToolsApp[] = "DevToolsApp"; | 60 const char DevToolsWindow::kDevToolsApp[] = "DevToolsApp"; |
| 57 | 61 |
| 58 // static | 62 // static |
| 59 void DevToolsWindow::RegisterUserPrefs(PrefService* prefs) { | 63 void DevToolsWindow::RegisterUserPrefs(PrefService* prefs) { |
| 60 prefs->RegisterBooleanPref(prefs::kDevToolsOpenDocked, | 64 prefs->RegisterBooleanPref(prefs::kDevToolsOpenDocked, |
| 61 true, | 65 true, |
| 62 PrefService::UNSYNCABLE_PREF); | 66 PrefService::UNSYNCABLE_PREF); |
| 63 } | 67 } |
| 64 | 68 |
| 65 // static | 69 // static |
| 66 TabContentsWrapper* DevToolsWindow::GetDevToolsContents( | 70 TabContentsWrapper* DevToolsWindow::GetDevToolsContents( |
| 67 TabContents* inspected_tab) { | 71 TabContents* inspected_tab) { |
| 68 if (!inspected_tab) | 72 if (!inspected_tab) |
| 69 return NULL; | 73 return NULL; |
| 70 | 74 |
| 75 if (!DevToolsAgentHostRegistry::HasDevToolsAgentHost( | |
| 76 inspected_tab->render_view_host())) | |
| 77 return NULL; | |
| 78 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( | |
| 79 inspected_tab->render_view_host()); | |
| 71 DevToolsManager* manager = DevToolsManager::GetInstance(); | 80 DevToolsManager* manager = DevToolsManager::GetInstance(); |
| 72 DevToolsClientHost* client_host = manager-> | 81 DevToolsClientHost* client_host = manager->GetDevToolsClientHostFor(agent); |
| 73 GetDevToolsClientHostFor(inspected_tab->render_view_host()); | |
| 74 DevToolsWindow* window = AsDevToolsWindow(client_host); | 82 DevToolsWindow* window = AsDevToolsWindow(client_host); |
| 75 if (!window || !window->is_docked()) | 83 if (!window || !window->is_docked()) |
| 76 return NULL; | 84 return NULL; |
| 77 return window->tab_contents(); | 85 return window->tab_contents(); |
| 78 } | 86 } |
| 79 | 87 |
| 80 // static | 88 // static |
| 81 bool DevToolsWindow::IsDevToolsWindow(RenderViewHost* window_rvh) { | 89 bool DevToolsWindow::IsDevToolsWindow(RenderViewHost* window_rvh) { |
| 82 if (g_instances == NULL) | 90 if (g_instances == NULL) |
| 83 return NULL; | 91 return NULL; |
| 84 DevToolsWindowList& instances = g_instances.Get(); | 92 DevToolsWindowList& instances = g_instances.Get(); |
| 85 for (DevToolsWindowList::iterator it = instances.begin(); | 93 for (DevToolsWindowList::iterator it = instances.begin(); |
| 86 it != instances.end(); ++it) { | 94 it != instances.end(); ++it) { |
| 87 if ((*it)->tab_contents_->render_view_host() == window_rvh) | 95 if ((*it)->tab_contents_->render_view_host() == window_rvh) |
| 88 return true; | 96 return true; |
| 89 } | 97 } |
| 90 return false; | 98 return false; |
| 91 } | 99 } |
| 92 | 100 |
| 93 // static | 101 // static |
| 94 DevToolsWindow* DevToolsWindow::OpenDevToolsWindowForWorker( | 102 DevToolsWindow* DevToolsWindow::OpenDevToolsWindowForWorker( |
| 95 Profile* profile, | 103 Profile* profile, |
| 96 DevToolsAgentHost* worker_agent) { | 104 DevToolsAgentHost* worker_agent) { |
| 97 DevToolsWindow* window; | 105 DevToolsWindow* window; |
| 98 DevToolsClientHost* client = | 106 DevToolsClientHost* client = content::DevToolsManager::GetInstance()-> |
| 99 DevToolsManager::GetInstance()->GetDevToolsClientHostFor(worker_agent); | 107 GetDevToolsClientHostFor(worker_agent); |
| 100 if (client) { | 108 if (client) { |
| 101 window = AsDevToolsWindow(client); | 109 window = AsDevToolsWindow(client); |
| 102 if (!window) | 110 if (!window) |
| 103 return NULL; | 111 return NULL; |
| 104 } else { | 112 } else { |
| 105 window = DevToolsWindow::CreateDevToolsWindowForWorker(profile); | 113 window = DevToolsWindow::CreateDevToolsWindowForWorker(profile); |
| 106 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(worker_agent, | 114 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( |
| 107 window); | 115 worker_agent, |
| 116 window->frontend_host_); | |
| 108 } | 117 } |
| 109 window->Show(DEVTOOLS_TOGGLE_ACTION_NONE); | 118 window->Show(DEVTOOLS_TOGGLE_ACTION_NONE); |
| 110 return window; | 119 return window; |
| 111 } | 120 } |
| 112 | 121 |
| 113 // static | 122 // static |
| 114 DevToolsWindow* DevToolsWindow::CreateDevToolsWindowForWorker( | 123 DevToolsWindow* DevToolsWindow::CreateDevToolsWindowForWorker( |
| 115 Profile* profile) { | 124 Profile* profile) { |
| 116 return Create(profile, NULL, false, true); | 125 return Create(profile, NULL, false, true); |
| 117 } | 126 } |
| 118 | 127 |
| 119 // static | 128 // static |
| 120 DevToolsWindow* DevToolsWindow::OpenDevToolsWindow( | 129 DevToolsWindow* DevToolsWindow::OpenDevToolsWindow( |
| 121 RenderViewHost* inspected_rvh) { | 130 RenderViewHost* inspected_rvh) { |
| 122 return ToggleDevToolsWindow(inspected_rvh, true, | 131 return ToggleDevToolsWindow(inspected_rvh, true, |
| 123 DEVTOOLS_TOGGLE_ACTION_NONE); | 132 DEVTOOLS_TOGGLE_ACTION_NONE); |
| 124 } | 133 } |
| 125 | 134 |
| 126 // static | 135 // static |
| 127 DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( | 136 DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( |
| 128 RenderViewHost* inspected_rvh, | 137 RenderViewHost* inspected_rvh, |
| 129 DevToolsToggleAction action) { | 138 DevToolsToggleAction action) { |
| 130 return ToggleDevToolsWindow(inspected_rvh, false, action); | 139 return ToggleDevToolsWindow(inspected_rvh, false, action); |
| 131 } | 140 } |
| 132 | 141 |
| 133 void DevToolsWindow::InspectElement(RenderViewHost* inspected_rvh, | 142 void DevToolsWindow::InspectElement(RenderViewHost* inspected_rvh, |
| 134 int x, | 143 int x, |
| 135 int y) { | 144 int y) { |
| 136 inspected_rvh->Send(new DevToolsAgentMsg_InspectElement( | 145 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( |
| 137 inspected_rvh->routing_id(), | 146 inspected_rvh); |
| 138 x, | 147 DevToolsManager::GetInstance()->InspectElement(agent, x, y); |
| 139 y)); | |
| 140 // TODO(loislo): we should initiate DevTools window opening from within | 148 // TODO(loislo): we should initiate DevTools window opening from within |
| 141 // renderer. Otherwise, we still can hit a race condition here. | 149 // renderer. Otherwise, we still can hit a race condition here. |
| 142 OpenDevToolsWindow(inspected_rvh); | 150 OpenDevToolsWindow(inspected_rvh); |
| 143 } | 151 } |
| 144 | 152 |
| 145 | 153 |
| 146 DevToolsWindow* DevToolsWindow::Create( | 154 DevToolsWindow* DevToolsWindow::Create( |
| 147 Profile* profile, | 155 Profile* profile, |
| 148 RenderViewHost* inspected_rvh, | 156 RenderViewHost* inspected_rvh, |
| 149 bool docked, | 157 bool docked, |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 164 DevToolsWindow::DevToolsWindow(TabContentsWrapper* tab_contents, | 172 DevToolsWindow::DevToolsWindow(TabContentsWrapper* tab_contents, |
| 165 Profile* profile, | 173 Profile* profile, |
| 166 RenderViewHost* inspected_rvh, | 174 RenderViewHost* inspected_rvh, |
| 167 bool docked) | 175 bool docked) |
| 168 : profile_(profile), | 176 : profile_(profile), |
| 169 inspected_tab_(NULL), | 177 inspected_tab_(NULL), |
| 170 tab_contents_(tab_contents), | 178 tab_contents_(tab_contents), |
| 171 browser_(NULL), | 179 browser_(NULL), |
| 172 docked_(docked), | 180 docked_(docked), |
| 173 is_loaded_(false), | 181 is_loaded_(false), |
| 174 action_on_load_(DEVTOOLS_TOGGLE_ACTION_NONE) { | 182 action_on_load_(DEVTOOLS_TOGGLE_ACTION_NONE), |
| 183 ALLOW_THIS_IN_INITIALIZER_LIST(frontend_host_( | |
|
pfeldman
2011/11/30 16:43:26
You could initialize it in the constructor instead
yurys
2011/11/30 17:08:28
Done.
| |
| 184 DevToolsClientHost::CreateDevToolsFrontendHost( | |
| 185 tab_contents->tab_contents(), | |
| 186 this))) { | |
| 175 g_instances.Get().push_back(this); | 187 g_instances.Get().push_back(this); |
| 176 // Wipe out page icon so that the default application icon is used. | 188 // Wipe out page icon so that the default application icon is used. |
| 177 NavigationEntry* entry = tab_contents_->controller().GetActiveEntry(); | 189 NavigationEntry* entry = tab_contents_->controller().GetActiveEntry(); |
| 178 entry->favicon().set_bitmap(SkBitmap()); | 190 entry->favicon().set_bitmap(SkBitmap()); |
| 179 entry->favicon().set_is_valid(true); | 191 entry->favicon().set_is_valid(true); |
| 180 | 192 |
| 181 // Install DevTools front-end message handler. | 193 // Install DevTools front-end message handler. |
| 182 content::SetupDevToolsFrontendDelegate( | 194 // content::SetupDevToolsFrontendDelegate( |
|
pfeldman
2011/11/30 16:43:26
remove these?
yurys
2011/11/30 17:08:28
Done.
| |
| 183 tab_contents->tab_contents(), | 195 // tab_contents->tab_contents(), |
| 184 this); | 196 // this); |
| 185 | 197 |
| 186 // Register on-load actions. | 198 // Register on-load actions. |
| 187 registrar_.Add( | 199 registrar_.Add( |
| 188 this, | 200 this, |
| 189 content::NOTIFICATION_LOAD_STOP, | 201 content::NOTIFICATION_LOAD_STOP, |
| 190 content::Source<NavigationController>(&tab_contents_->controller())); | 202 content::Source<NavigationController>(&tab_contents_->controller())); |
| 191 registrar_.Add( | 203 registrar_.Add( |
| 192 this, | 204 this, |
| 193 content::NOTIFICATION_TAB_CLOSING, | 205 content::NOTIFICATION_TAB_CLOSING, |
| 194 content::Source<NavigationController>(&tab_contents_->controller())); | 206 content::Source<NavigationController>(&tab_contents_->controller())); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 207 | 219 |
| 208 DevToolsWindow::~DevToolsWindow() { | 220 DevToolsWindow::~DevToolsWindow() { |
| 209 DevToolsWindowList& instances = g_instances.Get(); | 221 DevToolsWindowList& instances = g_instances.Get(); |
| 210 DevToolsWindowList::iterator it = std::find(instances.begin(), | 222 DevToolsWindowList::iterator it = std::find(instances.begin(), |
| 211 instances.end(), | 223 instances.end(), |
| 212 this); | 224 this); |
| 213 DCHECK(it != instances.end()); | 225 DCHECK(it != instances.end()); |
| 214 instances.erase(it); | 226 instances.erase(it); |
| 215 } | 227 } |
| 216 | 228 |
| 217 void DevToolsWindow::SendMessageToClient(const IPC::Message& message) { | |
| 218 RenderViewHost* target_host = tab_contents_->render_view_host(); | |
| 219 IPC::Message* m = new IPC::Message(message); | |
| 220 m->set_routing_id(target_host->routing_id()); | |
| 221 target_host->Send(m); | |
| 222 } | |
| 223 | |
| 224 void DevToolsWindow::InspectedTabClosing() { | 229 void DevToolsWindow::InspectedTabClosing() { |
| 225 if (docked_) { | 230 if (docked_) { |
| 226 // Update dev tools to reflect removed dev tools window. | 231 // Update dev tools to reflect removed dev tools window. |
| 227 | 232 |
| 228 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 233 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); |
| 229 if (inspected_window) | 234 if (inspected_window) |
| 230 inspected_window->UpdateDevTools(); | 235 inspected_window->UpdateDevTools(); |
| 231 // In case of docked tab_contents we own it, so delete here. | 236 // In case of docked tab_contents we own it, so delete here. |
| 232 delete tab_contents_; | 237 delete tab_contents_; |
| 233 | 238 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 UpdateTheme(); | 475 UpdateTheme(); |
| 471 DoAction(); | 476 DoAction(); |
| 472 AddDevToolsExtensionsToClient(); | 477 AddDevToolsExtensionsToClient(); |
| 473 } else if (type == content::NOTIFICATION_TAB_CLOSING) { | 478 } else if (type == content::NOTIFICATION_TAB_CLOSING) { |
| 474 if (content::Source<NavigationController>(source).ptr() == | 479 if (content::Source<NavigationController>(source).ptr() == |
| 475 &tab_contents_->controller()) { | 480 &tab_contents_->controller()) { |
| 476 // This happens when browser closes all of its tabs as a result | 481 // This happens when browser closes all of its tabs as a result |
| 477 // of window.Close event. | 482 // of window.Close event. |
| 478 // Notify manager that this DevToolsClientHost no longer exists and | 483 // Notify manager that this DevToolsClientHost no longer exists and |
| 479 // initiate self-destuct here. | 484 // initiate self-destuct here. |
| 480 NotifyCloseListener(); | 485 DevToolsManager::GetInstance()->ClientHostClosing(frontend_host_); |
| 481 delete this; | 486 delete this; |
| 482 } | 487 } |
| 483 } else if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { | 488 } else if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { |
| 484 UpdateTheme(); | 489 UpdateTheme(); |
| 485 } | 490 } |
| 486 } | 491 } |
| 487 | 492 |
| 488 void DevToolsWindow::ScheduleAction(DevToolsToggleAction action) { | 493 void DevToolsWindow::ScheduleAction(DevToolsToggleAction action) { |
| 489 action_on_load_ = action; | 494 action_on_load_ = action; |
| 490 if (is_loaded_) | 495 if (is_loaded_) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 591 if (inspected_window) | 596 if (inspected_window) |
| 592 inspected_window->HandleKeyboardEvent(event); | 597 inspected_window->HandleKeyboardEvent(event); |
| 593 } | 598 } |
| 594 } | 599 } |
| 595 | 600 |
| 596 // static | 601 // static |
| 597 DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( | 602 DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( |
| 598 RenderViewHost* inspected_rvh, | 603 RenderViewHost* inspected_rvh, |
| 599 bool force_open, | 604 bool force_open, |
| 600 DevToolsToggleAction action) { | 605 DevToolsToggleAction action) { |
| 606 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( | |
| 607 inspected_rvh); | |
| 601 DevToolsManager* manager = DevToolsManager::GetInstance(); | 608 DevToolsManager* manager = DevToolsManager::GetInstance(); |
| 602 | 609 DevToolsClientHost* host = manager->GetDevToolsClientHostFor(agent); |
| 603 DevToolsClientHost* host = manager->GetDevToolsClientHostFor(inspected_rvh); | |
| 604 DevToolsWindow* window = AsDevToolsWindow(host); | 610 DevToolsWindow* window = AsDevToolsWindow(host); |
| 605 if (host != NULL && window == NULL) { | 611 if (host != NULL && window == NULL) { |
| 606 // Break remote debugging / extension debugging session. | 612 // Break remote debugging / extension debugging session. |
| 607 manager->UnregisterDevToolsClientHostFor(inspected_rvh); | 613 manager->UnregisterDevToolsClientHostFor(agent); |
| 608 } | 614 } |
| 609 | 615 |
| 610 bool do_open = force_open; | 616 bool do_open = force_open; |
| 611 if (!window) { | 617 if (!window) { |
| 612 Profile* profile = Profile::FromBrowserContext( | 618 Profile* profile = Profile::FromBrowserContext( |
| 613 inspected_rvh->process()->GetBrowserContext()); | 619 inspected_rvh->process()->GetBrowserContext()); |
| 614 bool docked = profile->GetPrefs()->GetBoolean(prefs::kDevToolsOpenDocked); | 620 bool docked = profile->GetPrefs()->GetBoolean(prefs::kDevToolsOpenDocked); |
| 615 window = Create(profile, inspected_rvh, docked, false); | 621 window = Create(profile, inspected_rvh, docked, false); |
| 616 manager->RegisterDevToolsClientHostFor(inspected_rvh, window); | 622 manager->RegisterDevToolsClientHostFor(agent, window->frontend_host_); |
| 617 do_open = true; | 623 do_open = true; |
| 618 } | 624 } |
| 619 | 625 |
| 620 // If window is docked and visible, we hide it on toggle. If window is | 626 // If window is docked and visible, we hide it on toggle. If window is |
| 621 // undocked, we show (activate) it. | 627 // undocked, we show (activate) it. |
| 622 if (!window->is_docked() || do_open) | 628 if (!window->is_docked() || do_open) |
| 623 window->Show(action); | 629 window->Show(action); |
| 624 else | 630 else |
| 625 manager->UnregisterDevToolsClientHostFor(inspected_rvh); | 631 manager->UnregisterDevToolsClientHostFor(agent); |
| 626 | 632 |
| 627 return window; | 633 return window; |
| 628 } | 634 } |
| 629 | 635 |
| 630 // static | 636 // static |
| 631 DevToolsWindow* DevToolsWindow::AsDevToolsWindow( | 637 DevToolsWindow* DevToolsWindow::AsDevToolsWindow( |
| 632 DevToolsClientHost* client_host) { | 638 DevToolsClientHost* client_host) { |
| 633 if (!client_host || g_instances == NULL) | 639 if (!client_host || g_instances == NULL) |
| 634 return NULL; | 640 return NULL; |
| 635 DevToolsWindowList& instances = g_instances.Get(); | 641 DevToolsWindowList& instances = g_instances.Get(); |
| 636 for (DevToolsWindowList::iterator it = instances.begin(); | 642 for (DevToolsWindowList::iterator it = instances.begin(); |
| 637 it != instances.end(); ++it) { | 643 it != instances.end(); ++it) { |
| 638 DevToolsClientHost* client = *it; | 644 if ((*it)->frontend_host_ == client_host) |
| 639 if (client == client_host) | |
| 640 return *it; | 645 return *it; |
| 641 } | 646 } |
| 642 return NULL; | 647 return NULL; |
| 643 } | 648 } |
| 644 | 649 |
| 645 void DevToolsWindow::ForwardToDevToolsAgent(const IPC::Message& message) { | |
| 646 DevToolsManager::GetInstance()->ForwardToDevToolsAgent(this, message); | |
| 647 } | |
| 648 | |
| 649 void DevToolsWindow::ActivateWindow() { | 650 void DevToolsWindow::ActivateWindow() { |
| 650 if (!docked_) { | 651 if (!docked_) { |
| 651 if (!browser_->window()->IsActive()) { | 652 if (!browser_->window()->IsActive()) { |
| 652 browser_->window()->Activate(); | 653 browser_->window()->Activate(); |
| 653 } | 654 } |
| 654 } else { | 655 } else { |
| 655 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 656 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); |
| 656 if (inspected_window) | 657 if (inspected_window) |
| 657 tab_contents_->view()->Focus(); | 658 tab_contents_->view()->Focus(); |
| 658 } | 659 } |
| 659 } | 660 } |
| 660 | 661 |
| 661 void DevToolsWindow::CloseWindow() { | 662 void DevToolsWindow::CloseWindow() { |
| 662 DCHECK(docked_); | 663 DCHECK(docked_); |
| 663 NotifyCloseListener(); | 664 DevToolsManager::GetInstance()->ClientHostClosing(frontend_host_); |
| 664 InspectedTabClosing(); | 665 InspectedTabClosing(); |
| 665 } | 666 } |
| 666 | 667 |
| 667 void DevToolsWindow::MoveWindow(int x, int y) { | 668 void DevToolsWindow::MoveWindow(int x, int y) { |
| 668 if (!docked_) { | 669 if (!docked_) { |
| 669 gfx::Rect bounds = browser_->window()->GetBounds(); | 670 gfx::Rect bounds = browser_->window()->GetBounds(); |
| 670 bounds.Offset(x, y); | 671 bounds.Offset(x, y); |
| 671 browser_->window()->SetBounds(bounds); | 672 browser_->window()->SetBounds(bounds); |
| 672 } | 673 } |
| 673 } | 674 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 687 content); | 688 content); |
| 688 } | 689 } |
| 689 | 690 |
| 690 content::JavaScriptDialogCreator* DevToolsWindow::GetJavaScriptDialogCreator() { | 691 content::JavaScriptDialogCreator* DevToolsWindow::GetJavaScriptDialogCreator() { |
| 691 if (inspected_tab_ && inspected_tab_->tab_contents()->delegate()) { | 692 if (inspected_tab_ && inspected_tab_->tab_contents()->delegate()) { |
| 692 return inspected_tab_->tab_contents()->delegate()-> | 693 return inspected_tab_->tab_contents()->delegate()-> |
| 693 GetJavaScriptDialogCreator(); | 694 GetJavaScriptDialogCreator(); |
| 694 } | 695 } |
| 695 return TabContentsDelegate::GetJavaScriptDialogCreator(); | 696 return TabContentsDelegate::GetJavaScriptDialogCreator(); |
| 696 } | 697 } |
| OLD | NEW |