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 "chrome/browser/devtools/devtools_window.h" | 5 #include "chrome/browser/devtools/devtools_window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 if (window) | 152 if (window) |
153 window->HandleKeyboardEvent(event); | 153 window->HandleKeyboardEvent(event); |
154 } | 154 } |
155 | 155 |
156 void DevToolsToolboxDelegate::WebContentsDestroyed() { | 156 void DevToolsToolboxDelegate::WebContentsDestroyed() { |
157 delete this; | 157 delete this; |
158 } | 158 } |
159 | 159 |
160 BrowserWindow* DevToolsToolboxDelegate::GetInspectedBrowserWindow() { | 160 BrowserWindow* DevToolsToolboxDelegate::GetInspectedBrowserWindow() { |
161 WebContents* inspected_contents = | 161 WebContents* inspected_contents = |
162 inspected_contents_observer_->GetWebContents(); | 162 inspected_contents_observer_->web_contents(); |
163 if (!inspected_contents) | 163 if (!inspected_contents) |
164 return NULL; | 164 return NULL; |
165 Browser* browser = NULL; | 165 Browser* browser = NULL; |
166 int tab = 0; | 166 int tab = 0; |
167 if (FindInspectedBrowserAndTabIndex(inspected_contents, &browser, &tab)) | 167 if (FindInspectedBrowserAndTabIndex(inspected_contents, &browser, &tab)) |
168 return browser->window(); | 168 return browser->window(); |
169 return NULL; | 169 return NULL; |
170 } | 170 } |
171 | 171 |
172 } // namespace | 172 } // namespace |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 // DevToolsWindow::ObserverWithAccessor ------------------------------- | 285 // DevToolsWindow::ObserverWithAccessor ------------------------------- |
286 | 286 |
287 DevToolsWindow::ObserverWithAccessor::ObserverWithAccessor( | 287 DevToolsWindow::ObserverWithAccessor::ObserverWithAccessor( |
288 WebContents* web_contents) | 288 WebContents* web_contents) |
289 : WebContentsObserver(web_contents) { | 289 : WebContentsObserver(web_contents) { |
290 } | 290 } |
291 | 291 |
292 DevToolsWindow::ObserverWithAccessor::~ObserverWithAccessor() { | 292 DevToolsWindow::ObserverWithAccessor::~ObserverWithAccessor() { |
293 } | 293 } |
294 | 294 |
295 WebContents* DevToolsWindow::ObserverWithAccessor::GetWebContents() { | |
296 return web_contents(); | |
297 } | |
298 | |
299 // DevToolsWindow ------------------------------------------------------------- | 295 // DevToolsWindow ------------------------------------------------------------- |
300 | 296 |
301 const char DevToolsWindow::kDevToolsApp[] = "DevToolsApp"; | 297 const char DevToolsWindow::kDevToolsApp[] = "DevToolsApp"; |
302 | 298 |
303 DevToolsWindow::~DevToolsWindow() { | 299 DevToolsWindow::~DevToolsWindow() { |
304 life_stage_ = kClosing; | 300 life_stage_ = kClosing; |
305 | 301 |
306 UpdateBrowserWindow(); | 302 UpdateBrowserWindow(); |
307 UpdateBrowserToolbar(); | 303 UpdateBrowserToolbar(); |
308 | 304 |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 inspected_window->UpdateToolbar(NULL); | 1206 inspected_window->UpdateToolbar(NULL); |
1211 } | 1207 } |
1212 | 1208 |
1213 void DevToolsWindow::UpdateBrowserWindow() { | 1209 void DevToolsWindow::UpdateBrowserWindow() { |
1214 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); | 1210 BrowserWindow* inspected_window = GetInspectedBrowserWindow(); |
1215 if (inspected_window) | 1211 if (inspected_window) |
1216 inspected_window->UpdateDevTools(); | 1212 inspected_window->UpdateDevTools(); |
1217 } | 1213 } |
1218 | 1214 |
1219 WebContents* DevToolsWindow::GetInspectedWebContents() { | 1215 WebContents* DevToolsWindow::GetInspectedWebContents() { |
1220 return inspected_contents_observer_ ? | 1216 return inspected_contents_observer_ |
1221 inspected_contents_observer_->GetWebContents() : NULL; | 1217 ? inspected_contents_observer_->web_contents() |
| 1218 : NULL; |
1222 } | 1219 } |
1223 | 1220 |
1224 void DevToolsWindow::LoadCompleted() { | 1221 void DevToolsWindow::LoadCompleted() { |
1225 Show(action_on_load_); | 1222 Show(action_on_load_); |
1226 action_on_load_ = DevToolsToggleAction::NoOp(); | 1223 action_on_load_ = DevToolsToggleAction::NoOp(); |
1227 if (!load_completed_callback_.is_null()) { | 1224 if (!load_completed_callback_.is_null()) { |
1228 load_completed_callback_.Run(); | 1225 load_completed_callback_.Run(); |
1229 load_completed_callback_ = base::Closure(); | 1226 load_completed_callback_ = base::Closure(); |
1230 } | 1227 } |
1231 } | 1228 } |
1232 | 1229 |
1233 void DevToolsWindow::SetLoadCompletedCallback(const base::Closure& closure) { | 1230 void DevToolsWindow::SetLoadCompletedCallback(const base::Closure& closure) { |
1234 if (life_stage_ == kLoadCompleted || life_stage_ == kClosing) { | 1231 if (life_stage_ == kLoadCompleted || life_stage_ == kClosing) { |
1235 if (!closure.is_null()) | 1232 if (!closure.is_null()) |
1236 closure.Run(); | 1233 closure.Run(); |
1237 return; | 1234 return; |
1238 } | 1235 } |
1239 load_completed_callback_ = closure; | 1236 load_completed_callback_ = closure; |
1240 } | 1237 } |
1241 | 1238 |
1242 bool DevToolsWindow::ForwardKeyboardEvent( | 1239 bool DevToolsWindow::ForwardKeyboardEvent( |
1243 const content::NativeWebKeyboardEvent& event) { | 1240 const content::NativeWebKeyboardEvent& event) { |
1244 return event_forwarder_->ForwardEvent(event); | 1241 return event_forwarder_->ForwardEvent(event); |
1245 } | 1242 } |
OLD | NEW |