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