| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 RenderViewHost* window_rvh) { | 68 RenderViewHost* window_rvh) { |
| 69 for (DevToolsWindowList::iterator it = instances_.begin(); | 69 for (DevToolsWindowList::iterator it = instances_.begin(); |
| 70 it != instances_.end(); ++it) { | 70 it != instances_.end(); ++it) { |
| 71 if ((*it)->GetRenderViewHost() == window_rvh) | 71 if ((*it)->GetRenderViewHost() == window_rvh) |
| 72 return *it; | 72 return *it; |
| 73 } | 73 } |
| 74 return NULL; | 74 return NULL; |
| 75 } | 75 } |
| 76 | 76 |
| 77 // static | 77 // static |
| 78 DevToolsWindow* DevToolsWindow::CreateDevToolsWindowForWorker( |
| 79 Profile* profile) { |
| 80 return new DevToolsWindow(profile, NULL, false); |
| 81 } |
| 82 |
| 83 // static |
| 78 DevToolsWindow* DevToolsWindow::OpenDevToolsWindow( | 84 DevToolsWindow* DevToolsWindow::OpenDevToolsWindow( |
| 79 RenderViewHost* inspected_rvh) { | 85 RenderViewHost* inspected_rvh) { |
| 80 return ToggleDevToolsWindow(inspected_rvh, true, | 86 return ToggleDevToolsWindow(inspected_rvh, true, |
| 81 DEVTOOLS_TOGGLE_ACTION_NONE); | 87 DEVTOOLS_TOGGLE_ACTION_NONE); |
| 82 } | 88 } |
| 83 | 89 |
| 84 // static | 90 // static |
| 85 DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( | 91 DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( |
| 86 RenderViewHost* inspected_rvh, | 92 RenderViewHost* inspected_rvh, |
| 87 DevToolsToggleAction action) { | 93 DevToolsToggleAction action) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 registrar_.Add(this, | 130 registrar_.Add(this, |
| 125 content::NOTIFICATION_LOAD_STOP, | 131 content::NOTIFICATION_LOAD_STOP, |
| 126 Source<NavigationController>(&tab_contents_->controller())); | 132 Source<NavigationController>(&tab_contents_->controller())); |
| 127 registrar_.Add(this, | 133 registrar_.Add(this, |
| 128 content::NOTIFICATION_TAB_CLOSING, | 134 content::NOTIFICATION_TAB_CLOSING, |
| 129 Source<NavigationController>(&tab_contents_->controller())); | 135 Source<NavigationController>(&tab_contents_->controller())); |
| 130 registrar_.Add( | 136 registrar_.Add( |
| 131 this, | 137 this, |
| 132 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 138 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 133 Source<ThemeService>(ThemeServiceFactory::GetForProfile(profile_))); | 139 Source<ThemeService>(ThemeServiceFactory::GetForProfile(profile_))); |
| 134 TabContents* tab = inspected_rvh->delegate()->GetAsTabContents(); | 140 // There is no inspected_rvh in case of shared workers. |
| 135 if (tab) | 141 if (inspected_rvh) { |
| 136 inspected_tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tab); | 142 TabContents* tab = inspected_rvh->delegate()->GetAsTabContents(); |
| 137 | 143 if (tab) |
| 144 inspected_tab_ = TabContentsWrapper::GetCurrentWrapperForContents(tab); |
| 145 } |
| 138 instances_.push_back(this); | 146 instances_.push_back(this); |
| 139 } | 147 } |
| 140 | 148 |
| 141 DevToolsWindow::~DevToolsWindow() { | 149 DevToolsWindow::~DevToolsWindow() { |
| 142 DevToolsWindowList::iterator it = std::find(instances_.begin(), | 150 DevToolsWindowList::iterator it = std::find(instances_.begin(), |
| 143 instances_.end(), | 151 instances_.end(), |
| 144 this); | 152 this); |
| 145 DCHECK(it != instances_.end()); | 153 DCHECK(it != instances_.end()); |
| 146 instances_.erase(it); | 154 instances_.erase(it); |
| 147 } | 155 } |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 return *it; | 578 return *it; |
| 571 } | 579 } |
| 572 | 580 |
| 573 content::JavaScriptDialogCreator* DevToolsWindow::GetJavaScriptDialogCreator() { | 581 content::JavaScriptDialogCreator* DevToolsWindow::GetJavaScriptDialogCreator() { |
| 574 if (inspected_tab_ && inspected_tab_->tab_contents()->delegate()) { | 582 if (inspected_tab_ && inspected_tab_->tab_contents()->delegate()) { |
| 575 return inspected_tab_->tab_contents()->delegate()-> | 583 return inspected_tab_->tab_contents()->delegate()-> |
| 576 GetJavaScriptDialogCreator(); | 584 GetJavaScriptDialogCreator(); |
| 577 } | 585 } |
| 578 return TabContentsDelegate::GetJavaScriptDialogCreator(); | 586 return TabContentsDelegate::GetJavaScriptDialogCreator(); |
| 579 } | 587 } |
| OLD | NEW |