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