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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 int current_index = web_contents_->GetController().GetCurrentEntryIndex(); | 279 int current_index = web_contents_->GetController().GetCurrentEntryIndex(); |
280 int max_index = web_contents_->GetController().GetEntryCount() - 1; | 280 int max_index = web_contents_->GetController().GetEntryCount() - 1; |
281 | 281 |
282 PlatformEnableUIControl(BACK_BUTTON, current_index > 0); | 282 PlatformEnableUIControl(BACK_BUTTON, current_index > 0); |
283 PlatformEnableUIControl(FORWARD_BUTTON, current_index < max_index); | 283 PlatformEnableUIControl(FORWARD_BUTTON, current_index < max_index); |
284 PlatformEnableUIControl(STOP_BUTTON, | 284 PlatformEnableUIControl(STOP_BUTTON, |
285 to_different_document && web_contents_->IsLoading()); | 285 to_different_document && web_contents_->IsLoading()); |
286 } | 286 } |
287 | 287 |
288 void Shell::ShowDevTools() { | 288 void Shell::ShowDevTools() { |
289 InnerShowDevTools(); | 289 if (!devtools_frontend_) { |
290 } | 290 devtools_frontend_ = ShellDevToolsFrontend::Show(web_contents()); |
| 291 devtools_observer_.reset(new DevToolsWebContentsObserver( |
| 292 this, devtools_frontend_->frontend_shell()->web_contents())); |
| 293 } |
291 | 294 |
292 void Shell::ShowDevToolsForElementAt(int x, int y) { | 295 devtools_frontend_->Activate(); |
293 InnerShowDevTools(); | 296 devtools_frontend_->Focus(); |
294 devtools_frontend_->InspectElementAt(x, y); | |
295 } | 297 } |
296 | 298 |
297 void Shell::CloseDevTools() { | 299 void Shell::CloseDevTools() { |
298 if (!devtools_frontend_) | 300 if (!devtools_frontend_) |
299 return; | 301 return; |
300 devtools_observer_.reset(); | 302 devtools_observer_.reset(); |
301 devtools_frontend_->Close(); | 303 devtools_frontend_->Close(); |
302 devtools_frontend_ = NULL; | 304 devtools_frontend_ = NULL; |
303 } | 305 } |
304 | 306 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 | 433 |
432 void Shell::RendererUnresponsive(WebContents* source) { | 434 void Shell::RendererUnresponsive(WebContents* source) { |
433 if (switches::IsRunLayoutTestSwitchPresent()) | 435 if (switches::IsRunLayoutTestSwitchPresent()) |
434 BlinkTestController::Get()->RendererUnresponsive(); | 436 BlinkTestController::Get()->RendererUnresponsive(); |
435 } | 437 } |
436 | 438 |
437 void Shell::ActivateContents(WebContents* contents) { | 439 void Shell::ActivateContents(WebContents* contents) { |
438 contents->GetRenderViewHost()->GetWidget()->Focus(); | 440 contents->GetRenderViewHost()->GetWidget()->Focus(); |
439 } | 441 } |
440 | 442 |
441 bool Shell::HandleContextMenu(const content::ContextMenuParams& params) { | |
442 return PlatformHandleContextMenu(params); | |
443 } | |
444 | |
445 gfx::Size Shell::GetShellDefaultSize() { | 443 gfx::Size Shell::GetShellDefaultSize() { |
446 static gfx::Size default_shell_size; | 444 static gfx::Size default_shell_size; |
447 if (!default_shell_size.IsEmpty()) | 445 if (!default_shell_size.IsEmpty()) |
448 return default_shell_size; | 446 return default_shell_size; |
449 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 447 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
450 if (command_line->HasSwitch(switches::kContentShellHostWindowSize)) { | 448 if (command_line->HasSwitch(switches::kContentShellHostWindowSize)) { |
451 const std::string size_str = command_line->GetSwitchValueASCII( | 449 const std::string size_str = command_line->GetSwitchValueASCII( |
452 switches::kContentShellHostWindowSize); | 450 switches::kContentShellHostWindowSize); |
453 int width, height; | 451 int width, height; |
454 CHECK_EQ(2, sscanf(size_str.c_str(), "%dx%d", &width, &height)); | 452 CHECK_EQ(2, sscanf(size_str.c_str(), "%dx%d", &width, &height)); |
455 default_shell_size = gfx::Size(width, height); | 453 default_shell_size = gfx::Size(width, height); |
456 } else { | 454 } else { |
457 default_shell_size = gfx::Size( | 455 default_shell_size = gfx::Size( |
458 kDefaultTestWindowWidthDip, kDefaultTestWindowHeightDip); | 456 kDefaultTestWindowWidthDip, kDefaultTestWindowHeightDip); |
459 } | 457 } |
460 return default_shell_size; | 458 return default_shell_size; |
461 } | 459 } |
462 | 460 |
463 void Shell::TitleWasSet(NavigationEntry* entry, bool explicit_set) { | 461 void Shell::TitleWasSet(NavigationEntry* entry, bool explicit_set) { |
464 if (entry) | 462 if (entry) |
465 PlatformSetTitle(entry->GetTitle()); | 463 PlatformSetTitle(entry->GetTitle()); |
466 } | 464 } |
467 | 465 |
468 void Shell::InnerShowDevTools() { | |
469 if (!devtools_frontend_) { | |
470 devtools_frontend_ = ShellDevToolsFrontend::Show(web_contents()); | |
471 devtools_observer_.reset(new DevToolsWebContentsObserver( | |
472 this, devtools_frontend_->frontend_shell()->web_contents())); | |
473 } | |
474 | |
475 devtools_frontend_->Activate(); | |
476 devtools_frontend_->Focus(); | |
477 } | |
478 | |
479 void Shell::OnDevToolsWebContentsDestroyed() { | 466 void Shell::OnDevToolsWebContentsDestroyed() { |
480 devtools_observer_.reset(); | 467 devtools_observer_.reset(); |
481 devtools_frontend_ = NULL; | 468 devtools_frontend_ = NULL; |
482 } | 469 } |
483 | 470 |
484 } // namespace content | 471 } // namespace content |
OLD | NEW |