OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/browser/shell.h" | 5 #include "content/shell/browser/shell.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 int current_index = web_contents_->GetController().GetCurrentEntryIndex(); | 241 int current_index = web_contents_->GetController().GetCurrentEntryIndex(); |
242 int max_index = web_contents_->GetController().GetEntryCount() - 1; | 242 int max_index = web_contents_->GetController().GetEntryCount() - 1; |
243 | 243 |
244 PlatformEnableUIControl(BACK_BUTTON, current_index > 0); | 244 PlatformEnableUIControl(BACK_BUTTON, current_index > 0); |
245 PlatformEnableUIControl(FORWARD_BUTTON, current_index < max_index); | 245 PlatformEnableUIControl(FORWARD_BUTTON, current_index < max_index); |
246 PlatformEnableUIControl(STOP_BUTTON, | 246 PlatformEnableUIControl(STOP_BUTTON, |
247 to_different_document && web_contents_->IsLoading()); | 247 to_different_document && web_contents_->IsLoading()); |
248 } | 248 } |
249 | 249 |
250 void Shell::ShowDevTools() { | 250 void Shell::ShowDevTools() { |
251 InnerShowDevTools("", ""); | 251 InnerShowDevTools(); |
252 } | 252 } |
253 | 253 |
254 void Shell::ShowDevToolsForElementAt(int x, int y) { | 254 void Shell::ShowDevToolsForElementAt(int x, int y) { |
255 InnerShowDevTools("", ""); | 255 InnerShowDevTools(); |
256 devtools_frontend_->InspectElementAt(x, y); | 256 devtools_frontend_->InspectElementAt(x, y); |
257 } | 257 } |
258 | 258 |
259 void Shell::ShowDevToolsForTest(const std::string& settings, | |
260 const std::string& frontend_url) { | |
261 InnerShowDevTools(settings, frontend_url); | |
262 } | |
263 | |
264 void Shell::CloseDevTools() { | 259 void Shell::CloseDevTools() { |
265 if (!devtools_frontend_) | 260 if (!devtools_frontend_) |
266 return; | 261 return; |
267 devtools_observer_.reset(); | 262 devtools_observer_.reset(); |
268 devtools_frontend_->Close(); | 263 devtools_frontend_->Close(); |
269 devtools_frontend_ = NULL; | 264 devtools_frontend_ = NULL; |
270 } | 265 } |
271 | 266 |
272 gfx::NativeView Shell::GetContentView() { | 267 gfx::NativeView Shell::GetContentView() { |
273 if (!web_contents_) | 268 if (!web_contents_) |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 #if defined(TOOLKIT_VIEWS) | 406 #if defined(TOOLKIT_VIEWS) |
412 PlatformWebContentsFocused(contents); | 407 PlatformWebContentsFocused(contents); |
413 #endif | 408 #endif |
414 } | 409 } |
415 | 410 |
416 void Shell::TitleWasSet(NavigationEntry* entry, bool explicit_set) { | 411 void Shell::TitleWasSet(NavigationEntry* entry, bool explicit_set) { |
417 if (entry) | 412 if (entry) |
418 PlatformSetTitle(entry->GetTitle()); | 413 PlatformSetTitle(entry->GetTitle()); |
419 } | 414 } |
420 | 415 |
421 void Shell::InnerShowDevTools(const std::string& settings, | 416 void Shell::InnerShowDevTools() { |
422 const std::string& frontend_url) { | |
423 if (!devtools_frontend_) { | 417 if (!devtools_frontend_) { |
424 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 418 devtools_frontend_ = ShellDevToolsFrontend::Show(web_contents()); |
425 switches::kDumpRenderTree)) { | |
426 devtools_frontend_ = LayoutTestDevToolsFrontend::Show( | |
427 web_contents(), settings, frontend_url); | |
428 } else { | |
429 devtools_frontend_ = ShellDevToolsFrontend::Show(web_contents()); | |
430 } | |
431 devtools_observer_.reset(new DevToolsWebContentsObserver( | 419 devtools_observer_.reset(new DevToolsWebContentsObserver( |
432 this, devtools_frontend_->frontend_shell()->web_contents())); | 420 this, devtools_frontend_->frontend_shell()->web_contents())); |
433 } | 421 } |
434 | 422 |
435 devtools_frontend_->Activate(); | 423 devtools_frontend_->Activate(); |
436 devtools_frontend_->Focus(); | 424 devtools_frontend_->Focus(); |
437 } | 425 } |
438 | 426 |
439 void Shell::OnDevToolsWebContentsDestroyed() { | 427 void Shell::OnDevToolsWebContentsDestroyed() { |
440 devtools_observer_.reset(); | 428 devtools_observer_.reset(); |
441 devtools_frontend_ = NULL; | 429 devtools_frontend_ = NULL; |
442 } | 430 } |
443 | 431 |
444 } // namespace content | 432 } // namespace content |
OLD | NEW |