Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 DevToolsManager* manager = DevToolsManager::GetInstance(); | 96 DevToolsManager* manager = DevToolsManager::GetInstance(); |
| 97 DevToolsClientHost* client_host = manager->GetDevToolsClientHostFor(agent); | 97 DevToolsClientHost* client_host = manager->GetDevToolsClientHostFor(agent); |
| 98 DevToolsWindow* window = AsDevToolsWindow(client_host); | 98 DevToolsWindow* window = AsDevToolsWindow(client_host); |
| 99 if (!window || !window->is_docked()) | 99 if (!window || !window->is_docked()) |
| 100 return NULL; | 100 return NULL; |
| 101 return window->tab_contents(); | 101 return window->tab_contents(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 // static | 104 // static |
| 105 bool DevToolsWindow::IsDevToolsWindow(RenderViewHost* window_rvh) { | 105 bool DevToolsWindow::IsDevToolsWindow(RenderViewHost* window_rvh) { |
| 106 if (g_instances == NULL) | 106 return AsDevToolsWindow(window_rvh) != NULL; |
| 107 return false; | |
| 108 DevToolsWindowList& instances = g_instances.Get(); | |
| 109 for (DevToolsWindowList::iterator it = instances.begin(); | |
| 110 it != instances.end(); ++it) { | |
| 111 if ((*it)->tab_contents_->web_contents()->GetRenderViewHost() == window_rvh) | |
| 112 return true; | |
| 113 } | |
| 114 return false; | |
| 115 } | 107 } |
| 116 | 108 |
| 117 // static | 109 // static |
| 118 DevToolsWindow* DevToolsWindow::OpenDevToolsWindowForWorker( | 110 DevToolsWindow* DevToolsWindow::OpenDevToolsWindowForWorker( |
| 119 Profile* profile, | 111 Profile* profile, |
| 120 DevToolsAgentHost* worker_agent) { | 112 DevToolsAgentHost* worker_agent) { |
| 121 DevToolsWindow* window; | 113 DevToolsWindow* window; |
| 122 DevToolsClientHost* client = content::DevToolsManager::GetInstance()-> | 114 DevToolsClientHost* client = content::DevToolsManager::GetInstance()-> |
| 123 GetDevToolsClientHostFor(worker_agent); | 115 GetDevToolsClientHostFor(worker_agent); |
| 124 if (client) { | 116 if (client) { |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 if (inspected_window) | 603 if (inspected_window) |
| 612 inspected_window->HandleKeyboardEvent(event); | 604 inspected_window->HandleKeyboardEvent(event); |
| 613 } | 605 } |
| 614 } | 606 } |
| 615 | 607 |
| 616 // static | 608 // static |
| 617 DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( | 609 DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( |
| 618 RenderViewHost* inspected_rvh, | 610 RenderViewHost* inspected_rvh, |
| 619 bool force_open, | 611 bool force_open, |
| 620 DevToolsToggleAction action) { | 612 DevToolsToggleAction action) { |
| 613 if (action == DEVTOOLS_TOGGLE_ACTION_TOGGLE_INSPECTOR) { | |
|
pfeldman
2012/08/14 11:04:11
You should add event source browser here. Then you
| |
| 614 DevToolsWindow* currentDevToolsWindow = AsDevToolsWindow(inspected_rvh); | |
| 615 if (currentDevToolsWindow) { | |
| 616 chrome::CloseAllTabs(currentDevToolsWindow->browser()); | |
| 617 return currentDevToolsWindow; | |
| 618 } | |
| 619 | |
| 620 // If invoked not on a DevTools window, behave as if it were a normal | |
| 621 // "Open DevTools window" shortcut. | |
| 622 action = DEVTOOLS_TOGGLE_ACTION_NONE; | |
| 623 } | |
| 624 | |
| 621 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( | 625 DevToolsAgentHost* agent = DevToolsAgentHostRegistry::GetDevToolsAgentHost( |
| 622 inspected_rvh); | 626 inspected_rvh); |
| 623 DevToolsManager* manager = DevToolsManager::GetInstance(); | 627 DevToolsManager* manager = DevToolsManager::GetInstance(); |
| 624 DevToolsClientHost* host = manager->GetDevToolsClientHostFor(agent); | 628 DevToolsClientHost* host = manager->GetDevToolsClientHostFor(agent); |
| 625 DevToolsWindow* window = AsDevToolsWindow(host); | 629 DevToolsWindow* window = AsDevToolsWindow(host); |
| 626 if (host != NULL && window == NULL) { | 630 if (host != NULL && window == NULL) { |
| 627 // Break remote debugging / extension debugging session. | 631 // Break remote debugging / extension debugging session. |
| 628 manager->UnregisterDevToolsClientHostFor(agent); | 632 manager->UnregisterDevToolsClientHostFor(agent); |
| 629 } | 633 } |
| 630 | 634 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 658 return NULL; | 662 return NULL; |
| 659 DevToolsWindowList& instances = g_instances.Get(); | 663 DevToolsWindowList& instances = g_instances.Get(); |
| 660 for (DevToolsWindowList::iterator it = instances.begin(); | 664 for (DevToolsWindowList::iterator it = instances.begin(); |
| 661 it != instances.end(); ++it) { | 665 it != instances.end(); ++it) { |
| 662 if ((*it)->frontend_host_ == client_host) | 666 if ((*it)->frontend_host_ == client_host) |
| 663 return *it; | 667 return *it; |
| 664 } | 668 } |
| 665 return NULL; | 669 return NULL; |
| 666 } | 670 } |
| 667 | 671 |
| 672 // static | |
| 673 DevToolsWindow* DevToolsWindow::AsDevToolsWindow(RenderViewHost* rvh) { | |
| 674 if (g_instances == NULL) | |
| 675 return NULL; | |
| 676 DevToolsWindowList& instances = g_instances.Get(); | |
| 677 for (DevToolsWindowList::iterator it = instances.begin(); | |
| 678 it != instances.end(); ++it) { | |
| 679 if ((*it)->tab_contents_->web_contents()->GetRenderViewHost() == rvh) | |
| 680 return *it; | |
| 681 } | |
| 682 return NULL; | |
| 683 } | |
| 684 | |
| 668 void DevToolsWindow::ActivateWindow() { | 685 void DevToolsWindow::ActivateWindow() { |
| 669 if (!docked_) { | 686 if (!docked_) { |
| 670 if (!browser_->window()->IsActive()) { | 687 if (!browser_->window()->IsActive()) { |
| 671 browser_->window()->Activate(); | 688 browser_->window()->Activate(); |
| 672 } | 689 } |
| 673 } else { | 690 } else { |
| 674 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 691 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); |
| 675 if (inspected_window) | 692 if (inspected_window) |
| 676 tab_contents_->web_contents()->GetView()->Focus(); | 693 tab_contents_->web_contents()->GetView()->Focus(); |
| 677 } | 694 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 766 } | 783 } |
| 767 | 784 |
| 768 void DevToolsWindow::UpdateBrowserToolbar() { | 785 void DevToolsWindow::UpdateBrowserToolbar() { |
| 769 if (!inspected_tab_) | 786 if (!inspected_tab_) |
| 770 return; | 787 return; |
| 771 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 788 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); |
| 772 if (inspected_window) | 789 if (inspected_window) |
| 773 inspected_window->UpdateToolbar(inspected_tab_, false); | 790 inspected_window->UpdateToolbar(inspected_tab_, false); |
| 774 } | 791 } |
| 775 | 792 |
| OLD | NEW |