| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/sys_info.h" |
| 9 #include "content/public/browser/context_factory.h" | 10 #include "content/public/browser/context_factory.h" |
| 10 #include "content/public/browser/render_widget_host_view.h" | 11 #include "content/public/browser/render_widget_host_view.h" |
| 11 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 12 #include "content/public/common/context_menu_params.h" | 13 #include "content/public/common/context_menu_params.h" |
| 13 #include "content/shell/browser/shell_platform_data_aura.h" | 14 #include "content/shell/browser/shell_platform_data_aura.h" |
| 14 #include "device/bluetooth/bluetooth_adapter_factory.h" | 15 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 15 #include "ui/aura/client/screen_position_client.h" | 16 #include "ui/aura/client/screen_position_client.h" |
| 16 #include "ui/aura/env.h" | 17 #include "ui/aura/env.h" |
| 17 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 18 #include "ui/aura/window_event_dispatcher.h" | 19 #include "ui/aura/window_event_dispatcher.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 32 #include "ui/views/layout/fill_layout.h" | 33 #include "ui/views/layout/fill_layout.h" |
| 33 #include "ui/views/layout/grid_layout.h" | 34 #include "ui/views/layout/grid_layout.h" |
| 34 #include "ui/views/test/desktop_test_views_delegate.h" | 35 #include "ui/views/test/desktop_test_views_delegate.h" |
| 35 #include "ui/views/view.h" | 36 #include "ui/views/view.h" |
| 36 #include "ui/views/widget/widget.h" | 37 #include "ui/views/widget/widget.h" |
| 37 #include "ui/views/widget/widget_delegate.h" | 38 #include "ui/views/widget/widget_delegate.h" |
| 38 | 39 |
| 39 #if defined(OS_CHROMEOS) | 40 #if defined(OS_CHROMEOS) |
| 40 #include "chromeos/dbus/dbus_thread_manager.h" | 41 #include "chromeos/dbus/dbus_thread_manager.h" |
| 41 #include "ui/aura/test/test_screen.h" | 42 #include "ui/aura/test/test_screen.h" |
| 43 #include "ui/display/chromeos/display_configurator.h" |
| 44 #include "ui/display/types/display_snapshot.h" |
| 42 #include "ui/wm/test/wm_test_helper.h" | 45 #include "ui/wm/test/wm_test_helper.h" |
| 43 #else // !defined(OS_CHROMEOS) | 46 #else // !defined(OS_CHROMEOS) |
| 44 #include "ui/views/widget/desktop_aura/desktop_screen.h" | 47 #include "ui/views/widget/desktop_aura/desktop_screen.h" |
| 45 #endif | 48 #endif |
| 46 | 49 |
| 47 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
| 48 #include <fcntl.h> | 51 #include <fcntl.h> |
| 49 #include <io.h> | 52 #include <io.h> |
| 50 #endif | 53 #endif |
| 51 | 54 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 Layout(); | 143 Layout(); |
| 141 | 144 |
| 142 // Resize the widget, keeping the same origin. | 145 // Resize the widget, keeping the same origin. |
| 143 gfx::Rect bounds = GetWidget()->GetWindowBoundsInScreen(); | 146 gfx::Rect bounds = GetWidget()->GetWindowBoundsInScreen(); |
| 144 bounds.set_size(GetWidget()->GetRootView()->GetPreferredSize()); | 147 bounds.set_size(GetWidget()->GetRootView()->GetPreferredSize()); |
| 145 GetWidget()->SetBounds(bounds); | 148 GetWidget()->SetBounds(bounds); |
| 146 | 149 |
| 147 // Resizing a widget on chromeos doesn't automatically resize the root, need | 150 // Resizing a widget on chromeos doesn't automatically resize the root, need |
| 148 // to explicitly do that. | 151 // to explicitly do that. |
| 149 #if defined(OS_CHROMEOS) | 152 #if defined(OS_CHROMEOS) |
| 150 GetWidget()->GetNativeWindow()->GetHost()->SetBounds(bounds); | 153 if (!base::SysInfo::IsRunningOnChromeOS()) |
| 154 GetWidget()->GetNativeWindow()->GetHost()->SetBounds(bounds); |
| 151 #endif | 155 #endif |
| 152 } | 156 } |
| 153 | 157 |
| 154 void SetWindowTitle(const base::string16& title) { title_ = title; } | 158 void SetWindowTitle(const base::string16& title) { title_ = title; } |
| 155 void EnableUIControl(UIControl control, bool is_enabled) { | 159 void EnableUIControl(UIControl control, bool is_enabled) { |
| 156 if (control == BACK_BUTTON) { | 160 if (control == BACK_BUTTON) { |
| 157 back_button_->SetState(is_enabled ? views::CustomButton::STATE_NORMAL | 161 back_button_->SetState(is_enabled ? views::CustomButton::STATE_NORMAL |
| 158 : views::CustomButton::STATE_DISABLED); | 162 : views::CustomButton::STATE_DISABLED); |
| 159 } else if (control == FORWARD_BUTTON) { | 163 } else if (control == FORWARD_BUTTON) { |
| 160 forward_button_->SetState(is_enabled ? views::CustomButton::STATE_NORMAL | 164 forward_button_->SetState(is_enabled ? views::CustomButton::STATE_NORMAL |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 View* contents_view_; | 397 View* contents_view_; |
| 394 views::WebView* web_view_; | 398 views::WebView* web_view_; |
| 395 | 399 |
| 396 DISALLOW_COPY_AND_ASSIGN(ShellWindowDelegateView); | 400 DISALLOW_COPY_AND_ASSIGN(ShellWindowDelegateView); |
| 397 }; | 401 }; |
| 398 | 402 |
| 399 } // namespace | 403 } // namespace |
| 400 | 404 |
| 401 #if defined(OS_CHROMEOS) | 405 #if defined(OS_CHROMEOS) |
| 402 wm::WMTestHelper* Shell::wm_test_helper_ = NULL; | 406 wm::WMTestHelper* Shell::wm_test_helper_ = NULL; |
| 407 ui::DisplayConfigurator* Shell::display_configurator_ = nullptr; |
| 403 gfx::Screen* Shell::test_screen_ = NULL; | 408 gfx::Screen* Shell::test_screen_ = NULL; |
| 404 #endif | 409 #endif |
| 405 views::ViewsDelegate* Shell::views_delegate_ = NULL; | 410 views::ViewsDelegate* Shell::views_delegate_ = NULL; |
| 406 | 411 |
| 407 // static | 412 // static |
| 408 void Shell::PlatformInitialize(const gfx::Size& default_window_size) { | 413 void Shell::PlatformInitialize(const gfx::Size& default_window_size) { |
| 409 #if defined(OS_WIN) | 414 #if defined(OS_WIN) |
| 410 _setmode(_fileno(stdout), _O_BINARY); | 415 _setmode(_fileno(stdout), _O_BINARY); |
| 411 _setmode(_fileno(stderr), _O_BINARY); | 416 _setmode(_fileno(stderr), _O_BINARY); |
| 412 #endif | 417 #endif |
| 413 #if defined(OS_CHROMEOS) | 418 #if defined(OS_CHROMEOS) |
| 414 chromeos::DBusThreadManager::Initialize(); | 419 chromeos::DBusThreadManager::Initialize(); |
| 420 |
| 421 gfx::Size display_size = default_window_size; |
| 422 if (base::SysInfo::IsRunningOnChromeOS()) { |
| 423 display_configurator_ = new ui::DisplayConfigurator(); |
| 424 display_configurator_->Init(false); |
| 425 display_configurator_->ForceInitialConfigure(0); |
| 426 |
| 427 const auto& displays = display_configurator_->cached_displays(); |
| 428 if (!displays.empty()) |
| 429 display_size = displays[0]->current_mode()->size(); |
| 430 } |
| 431 |
| 415 test_screen_ = aura::TestScreen::Create(gfx::Size()); | 432 test_screen_ = aura::TestScreen::Create(gfx::Size()); |
| 416 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_); | 433 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_); |
| 417 wm_test_helper_ = new wm::WMTestHelper(default_window_size, | 434 wm_test_helper_ = new wm::WMTestHelper(display_size, |
| 418 GetContextFactory()); | 435 GetContextFactory()); |
| 419 #else | 436 #else |
| 420 gfx::Screen::SetScreenInstance( | 437 gfx::Screen::SetScreenInstance( |
| 421 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); | 438 gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); |
| 422 #endif | 439 #endif |
| 423 views_delegate_ = new ShellViewsDelegateAura(); | 440 views_delegate_ = new ShellViewsDelegateAura(); |
| 424 } | 441 } |
| 425 | 442 |
| 426 void Shell::PlatformExit() { | 443 void Shell::PlatformExit() { |
| 427 #if defined(OS_CHROMEOS) | 444 #if defined(OS_CHROMEOS) |
| 445 if (display_configurator_) { |
| 446 delete display_configurator_; |
| 447 display_configurator_ = nullptr; |
| 448 } |
| 449 |
| 428 delete wm_test_helper_; | 450 delete wm_test_helper_; |
| 429 wm_test_helper_ = NULL; | 451 wm_test_helper_ = NULL; |
| 430 | 452 |
| 431 delete test_screen_; | 453 delete test_screen_; |
| 432 test_screen_ = NULL; | 454 test_screen_ = NULL; |
| 433 #endif | 455 #endif |
| 434 delete views_delegate_; | 456 delete views_delegate_; |
| 435 views_delegate_ = NULL; | 457 views_delegate_ = NULL; |
| 436 delete platform_; | 458 delete platform_; |
| 437 platform_ = NULL; | 459 platform_ = NULL; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 const content::ContextMenuParams& params) { | 570 const content::ContextMenuParams& params) { |
| 549 if (headless_) | 571 if (headless_) |
| 550 return true; | 572 return true; |
| 551 ShellWindowDelegateView* delegate_view = | 573 ShellWindowDelegateView* delegate_view = |
| 552 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); | 574 static_cast<ShellWindowDelegateView*>(window_widget_->widget_delegate()); |
| 553 delegate_view->ShowWebViewContextMenu(params); | 575 delegate_view->ShowWebViewContextMenu(params); |
| 554 return true; | 576 return true; |
| 555 } | 577 } |
| 556 | 578 |
| 557 } // namespace content | 579 } // namespace content |
| OLD | NEW |