| 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/location.h" | 9 #include "base/location.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 16 #include "content/public/browser/devtools_agent_host.h" | 16 #include "content/public/browser/devtools_agent_host.h" |
| 17 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
| 18 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
| 19 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/render_widget_host.h" | 20 #include "content/public/browser/render_widget_host.h" |
| 21 #include "content/public/browser/render_widget_host_view.h" | |
| 22 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/browser/web_contents_observer.h" | 22 #include "content/public/browser/web_contents_observer.h" |
| 24 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 25 #include "content/public/common/renderer_preferences.h" | 24 #include "content/public/common/renderer_preferences.h" |
| 26 #include "content/public/common/webrtc_ip_handling_policy.h" | 25 #include "content/public/common/webrtc_ip_handling_policy.h" |
| 27 #include "content/shell/browser/blink_test_controller.h" | 26 #include "content/shell/browser/blink_test_controller.h" |
| 28 #include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factor
y.h" | 27 #include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factor
y.h" |
| 29 #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h" | 28 #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h" |
| 30 #include "content/shell/browser/layout_test/layout_test_javascript_dialog_manage
r.h" | 29 #include "content/shell/browser/layout_test/layout_test_javascript_dialog_manage
r.h" |
| 31 #include "content/shell/browser/notify_done_forwarder.h" | 30 #include "content/shell/browser/notify_done_forwarder.h" |
| 32 #include "content/shell/browser/shell_browser_main_parts.h" | 31 #include "content/shell/browser/shell_browser_main_parts.h" |
| 33 #include "content/shell/browser/shell_content_browser_client.h" | 32 #include "content/shell/browser/shell_content_browser_client.h" |
| 34 #include "content/shell/browser/shell_devtools_frontend.h" | 33 #include "content/shell/browser/shell_devtools_frontend.h" |
| 35 #include "content/shell/browser/shell_javascript_dialog_manager.h" | 34 #include "content/shell/browser/shell_javascript_dialog_manager.h" |
| 36 #include "content/shell/common/shell_messages.h" | 35 #include "content/shell/common/shell_messages.h" |
| 37 #include "content/shell/common/shell_switches.h" | 36 #include "content/shell/common/shell_switches.h" |
| 38 #include "ui/gfx/display.h" | |
| 39 #include "ui/gfx/switches.h" | |
| 40 | |
| 41 #if defined(USE_X11) && !defined(OS_CHROMEOS) | |
| 42 #include "ui/views/test/desktop_screen_x11_test_api.h" | |
| 43 #endif | |
| 44 | 37 |
| 45 namespace content { | 38 namespace content { |
| 46 | 39 |
| 47 const int kDefaultTestWindowWidthDip = 800; | 40 const int kDefaultTestWindowWidthDip = 800; |
| 48 const int kDefaultTestWindowHeightDip = 600; | 41 const int kDefaultTestWindowHeightDip = 600; |
| 49 | 42 |
| 50 std::vector<Shell*> Shell::windows_; | 43 std::vector<Shell*> Shell::windows_; |
| 51 base::Callback<void(Shell*)> Shell::shell_created_callback_; | 44 base::Callback<void(Shell*)> Shell::shell_created_callback_; |
| 52 | 45 |
| 53 bool Shell::quit_message_loop_ = true; | 46 bool Shell::quit_message_loop_ = true; |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 } | 376 } |
| 384 | 377 |
| 385 void Shell::ActivateContents(WebContents* contents) { | 378 void Shell::ActivateContents(WebContents* contents) { |
| 386 contents->GetRenderViewHost()->GetWidget()->Focus(); | 379 contents->GetRenderViewHost()->GetWidget()->Focus(); |
| 387 } | 380 } |
| 388 | 381 |
| 389 bool Shell::HandleContextMenu(const content::ContextMenuParams& params) { | 382 bool Shell::HandleContextMenu(const content::ContextMenuParams& params) { |
| 390 return PlatformHandleContextMenu(params); | 383 return PlatformHandleContextMenu(params); |
| 391 } | 384 } |
| 392 | 385 |
| 393 void Shell::SetDeviceScaleFactor(float scale) { | |
| 394 #if !defined(OS_CHROMEOS) | |
| 395 gfx::Display::ResetForceDeviceScaleFactorForTesting(); | |
| 396 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
| 397 switches::kForceDeviceScaleFactor, base::StringPrintf("%f", scale)); | |
| 398 #if defined(USE_X11) | |
| 399 views::test::DesktopScreenX11TestApi::UpdateDisplays(); | |
| 400 #endif | |
| 401 #endif | |
| 402 RenderWidgetHostView* host_view = web_contents_->GetRenderWidgetHostView(); | |
| 403 host_view->SetSize(host_view->GetViewBounds().size()); | |
| 404 } | |
| 405 | |
| 406 gfx::Size Shell::GetShellDefaultSize() { | 386 gfx::Size Shell::GetShellDefaultSize() { |
| 407 static gfx::Size default_shell_size; | 387 static gfx::Size default_shell_size; |
| 408 if (!default_shell_size.IsEmpty()) | 388 if (!default_shell_size.IsEmpty()) |
| 409 return default_shell_size; | 389 return default_shell_size; |
| 410 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 390 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 411 if (command_line->HasSwitch(switches::kContentShellHostWindowSize)) { | 391 if (command_line->HasSwitch(switches::kContentShellHostWindowSize)) { |
| 412 const std::string size_str = command_line->GetSwitchValueASCII( | 392 const std::string size_str = command_line->GetSwitchValueASCII( |
| 413 switches::kContentShellHostWindowSize); | 393 switches::kContentShellHostWindowSize); |
| 414 int width, height; | 394 int width, height; |
| 415 CHECK_EQ(2, sscanf(size_str.c_str(), "%dx%d", &width, &height)); | 395 CHECK_EQ(2, sscanf(size_str.c_str(), "%dx%d", &width, &height)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 436 devtools_frontend_->Activate(); | 416 devtools_frontend_->Activate(); |
| 437 devtools_frontend_->Focus(); | 417 devtools_frontend_->Focus(); |
| 438 } | 418 } |
| 439 | 419 |
| 440 void Shell::OnDevToolsWebContentsDestroyed() { | 420 void Shell::OnDevToolsWebContentsDestroyed() { |
| 441 devtools_observer_.reset(); | 421 devtools_observer_.reset(); |
| 442 devtools_frontend_ = NULL; | 422 devtools_frontend_ = NULL; |
| 443 } | 423 } |
| 444 | 424 |
| 445 } // namespace content | 425 } // namespace content |
| OLD | NEW |