| 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/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 RenderViewHost* window_rvh) { | 67 RenderViewHost* window_rvh) { |
| 68 for (DevToolsWindowList::iterator it = instances_.begin(); | 68 for (DevToolsWindowList::iterator it = instances_.begin(); |
| 69 it != instances_.end(); ++it) { | 69 it != instances_.end(); ++it) { |
| 70 if ((*it)->GetRenderViewHost() == window_rvh) | 70 if ((*it)->GetRenderViewHost() == window_rvh) |
| 71 return *it; | 71 return *it; |
| 72 } | 72 } |
| 73 return NULL; | 73 return NULL; |
| 74 } | 74 } |
| 75 | 75 |
| 76 // static | 76 // static |
| 77 DevToolsWindow* DevToolsWindow::CreateDevToolsWindow(Profile* profile) { |
| 78 return new DevToolsWindow(profile, NULL, false); |
| 79 } |
| 80 |
| 81 // static |
| 77 DevToolsWindow* DevToolsWindow::OpenDevToolsWindow( | 82 DevToolsWindow* DevToolsWindow::OpenDevToolsWindow( |
| 78 RenderViewHost* inspected_rvh) { | 83 RenderViewHost* inspected_rvh) { |
| 79 return ToggleDevToolsWindow(inspected_rvh, true, | 84 return ToggleDevToolsWindow(inspected_rvh, true, |
| 80 DEVTOOLS_TOGGLE_ACTION_NONE); | 85 DEVTOOLS_TOGGLE_ACTION_NONE); |
| 81 } | 86 } |
| 82 | 87 |
| 83 // static | 88 // static |
| 84 DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( | 89 DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( |
| 85 RenderViewHost* inspected_rvh, | 90 RenderViewHost* inspected_rvh, |
| 86 DevToolsToggleAction action) { | 91 DevToolsToggleAction action) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 registrar_.Add(this, | 128 registrar_.Add(this, |
| 124 NotificationType::LOAD_STOP, | 129 NotificationType::LOAD_STOP, |
| 125 Source<NavigationController>(&tab_contents_->controller())); | 130 Source<NavigationController>(&tab_contents_->controller())); |
| 126 registrar_.Add(this, | 131 registrar_.Add(this, |
| 127 NotificationType::TAB_CLOSING, | 132 NotificationType::TAB_CLOSING, |
| 128 Source<NavigationController>(&tab_contents_->controller())); | 133 Source<NavigationController>(&tab_contents_->controller())); |
| 129 registrar_.Add( | 134 registrar_.Add( |
| 130 this, | 135 this, |
| 131 NotificationType::BROWSER_THEME_CHANGED, | 136 NotificationType::BROWSER_THEME_CHANGED, |
| 132 Source<ThemeService>(ThemeServiceFactory::GetForProfile(profile_))); | 137 Source<ThemeService>(ThemeServiceFactory::GetForProfile(profile_))); |
| 133 TabContents* tab = inspected_rvh->delegate()->GetAsTabContents(); | 138 // There is now inspected_rvh in case of shared workers. |
| 134 if (tab) | 139 if (inspected_rvh) { |
| 135 inspected_tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tab); | 140 TabContents* tab = inspected_rvh->delegate()->GetAsTabContents(); |
| 136 | 141 if (tab) |
| 142 inspected_tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tab); |
| 143 } |
| 137 instances_.push_back(this); | 144 instances_.push_back(this); |
| 138 } | 145 } |
| 139 | 146 |
| 140 DevToolsWindow::~DevToolsWindow() { | 147 DevToolsWindow::~DevToolsWindow() { |
| 141 DevToolsWindowList::iterator it = std::find(instances_.begin(), | 148 DevToolsWindowList::iterator it = std::find(instances_.begin(), |
| 142 instances_.end(), | 149 instances_.end(), |
| 143 this); | 150 this); |
| 144 DCHECK(it != instances_.end()); | 151 DCHECK(it != instances_.end()); |
| 145 instances_.erase(it); | 152 instances_.erase(it); |
| 146 } | 153 } |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 DevToolsClientHost* client_host) { | 568 DevToolsClientHost* client_host) { |
| 562 if (!client_host) | 569 if (!client_host) |
| 563 return NULL; | 570 return NULL; |
| 564 DevToolsWindowList::iterator it = std::find(instances_.begin(), | 571 DevToolsWindowList::iterator it = std::find(instances_.begin(), |
| 565 instances_.end(), | 572 instances_.end(), |
| 566 client_host); | 573 client_host); |
| 567 if (it == instances_.end()) | 574 if (it == instances_.end()) |
| 568 return NULL; | 575 return NULL; |
| 569 return *it; | 576 return *it; |
| 570 } | 577 } |
| OLD | NEW |