diff options
author | ben <ben@chromium.org> | 2015-10-06 14:29:28 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-06 21:30:07 +0000 |
commit | f6de985ddb1ee40a38cafdad70928f9304f124d0 (patch) | |
tree | d36fa88201c2e4ad1159a182e577fdbbce851191 /ash | |
parent | 3ef2644f5b822155c2eb7edff674f73840253282 (diff) | |
download | chromium_src-f6de985ddb1ee40a38cafdad70928f9304f124d0.zip chromium_src-f6de985ddb1ee40a38cafdad70928f9304f124d0.tar.gz chromium_src-f6de985ddb1ee40a38cafdad70928f9304f124d0.tar.bz2 |
Make ScreenOrientationController not depend on content.
R=sky@chromium.org
http://crbug.com/332504
Review URL: https://codereview.chromium.org/1386983002
Cr-Commit-Position: refs/heads/master@{#352689}
Diffstat (limited to 'ash')
31 files changed, 255 insertions, 173 deletions
@@ -15,6 +15,7 @@ include_rules = [ "+ui", "+win8", "-ash/host", + "-content", ] specific_include_rules = { diff --git a/ash/ash.gyp b/ash/ash.gyp index 8d96a6c..4994964 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -45,10 +45,6 @@ 'cancel_mode.h', 'cast_config_delegate.cc', 'cast_config_delegate.h', - 'content/display/display_color_manager_chromeos.cc', - 'content/display/display_color_manager_chromeos.h', - 'content/display/screen_orientation_controller_chromeos.cc', - 'content/display/screen_orientation_controller_chromeos.h', 'debug.cc', 'debug.h', 'default_accessibility_delegate.cc', @@ -67,6 +63,8 @@ 'display/cursor_window_controller.h', 'display/display_change_observer_chromeos.cc', 'display/display_change_observer_chromeos.h', + 'display/display_color_manager_chromeos.cc', + 'display/display_color_manager_chromeos.h', 'display/display_configurator_animation.cc', 'display/display_configurator_animation.h', 'display/window_tree_host_manager.cc', @@ -103,6 +101,8 @@ 'display/root_window_transformers.h', 'display/screen_ash.cc', 'display/screen_ash.h', + 'display/screen_orientation_controller_chromeos.cc', + 'display/screen_orientation_controller_chromeos.h', 'display/screen_position_controller.cc', 'display/screen_position_controller.h', 'display/shared_display_edge_indicator.cc', @@ -676,12 +676,14 @@ 'content/ash_with_content_export.h', 'content/gpu_support_impl.cc', 'content/gpu_support_impl.h', + 'content/keyboard_overlay/keyboard_overlay_delegate.cc', + 'content/keyboard_overlay/keyboard_overlay_delegate.h', + 'content/keyboard_overlay/keyboard_overlay_view.cc', + 'content/keyboard_overlay/keyboard_overlay_view.h', + 'content/screen_orientation_delegate_chromeos.cc', + 'content/screen_orientation_delegate_chromeos.h', 'content/shell_content_state.cc', 'content/shell_content_state.h', - 'keyboard_overlay/keyboard_overlay_delegate.cc', - 'keyboard_overlay/keyboard_overlay_delegate.h', - 'keyboard_overlay/keyboard_overlay_view.cc', - 'keyboard_overlay/keyboard_overlay_view.h', ], 'ash_test_support_sources': [ 'desktop_background/desktop_background_controller_test_api.cc', @@ -809,6 +811,8 @@ 'ash_touch_exploration_manager_chromeos_unittest.cc', 'autoclick/autoclick_unittest.cc', 'content/display/screen_orientation_controller_chromeos_unittest.cc', + 'content/keyboard_overlay/keyboard_overlay_delegate_unittest.cc', + 'content/keyboard_overlay/keyboard_overlay_view_unittest.cc', 'desktop_background/desktop_background_controller_unittest.cc', 'dip_unittest.cc', 'display/cursor_window_controller_unittest.cc', @@ -835,8 +839,6 @@ 'frame/custom_frame_view_ash_unittest.cc', 'frame/default_header_painter_unittest.cc', 'host/ash_window_tree_host_x11_unittest.cc', - 'keyboard_overlay/keyboard_overlay_delegate_unittest.cc', - 'keyboard_overlay/keyboard_overlay_view_unittest.cc', 'magnifier/magnification_controller_unittest.cc', 'metrics/desktop_task_switch_metric_recorder_unittest.cc', 'metrics/task_switch_metrics_recorder_unittest.cc', diff --git a/ash/content/DEPS b/ash/content/DEPS index 5ed73eb..726b15c 100644 --- a/ash/content/DEPS +++ b/ash/content/DEPS @@ -3,3 +3,13 @@ include_rules = [ # in this file, but I'm starting out conservative. "+content/public/browser/gpu_data_manager.h", ] + +specific_include_rules = { + "screen_orientation_delegate_chromeos.cc": [ + "+content/public/browser/screen_orientation_provider.h", + "+content/public/browser/web_contents.h", + ], + "screen_orientation_delegate_chromeos.h": [ + "+content/public/browser/screen_orientation_delegate.h", + ], +} diff --git a/ash/content/display/DEPS b/ash/content/display/DEPS index 5f74158..8706cc9 100644 --- a/ash/content/display/DEPS +++ b/ash/content/display/DEPS @@ -1,14 +1,9 @@ -include_rules = [ - "+content/public/browser/screen_orientation_delegate.h", - "+content/public/browser/screen_orientation_provider.h", - "+content/public/browser/browser_context.h", - "+content/public/browser/browser_thread.h", - "+content/public/browser/web_contents.h", - "+third_party/qcms/src/qcms.h", - "+third_party/WebKit/public/platform/modules/screen_orientation/WebScreenOrientationLockType.h", -] - specific_include_rules = { + "screen_orientation_controller_chromeos_unittest.cc": [ + "+content/public/browser/browser_context.h", + "+content/public/browser/web_contents.h", + "+third_party/WebKit/public/platform/modules/screen_orientation/WebScreenOrientationLockType.h", + ], ".*test\.cc": [ "+content/public/test/test_browser_context.h" ], diff --git a/ash/content/display/screen_orientation_controller_chromeos_unittest.cc b/ash/content/display/screen_orientation_controller_chromeos_unittest.cc index f866c56..f5df053 100644 --- a/ash/content/display/screen_orientation_controller_chromeos_unittest.cc +++ b/ash/content/display/screen_orientation_controller_chromeos_unittest.cc @@ -5,13 +5,14 @@ #include <vector> #include "ash/ash_switches.h" -#include "ash/content/display/screen_orientation_controller_chromeos.h" #include "ash/content/shell_content_state.h" #include "ash/display/display_info.h" #include "ash/display/display_manager.h" +#include "ash/display/screen_orientation_controller_chromeos.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/test/ash_test_helper.h" +#include "ash/test/content/test_shell_content_state.h" #include "ash/test/display_manager_test_api.h" #include "ash/test/test_shell_delegate.h" #include "ash/test/test_system_tray_delegate.h" @@ -103,8 +104,10 @@ class ScreenOrientationControllerTest : public test::AshTestBase { ScreenOrientationControllerTest(); ~ScreenOrientationControllerTest() override; - ScreenOrientationController* delegate() { - return screen_orientation_controller_; + content::ScreenOrientationDelegate* delegate() { + return ash_test_helper() + ->test_shell_content_state() + ->screen_orientation_delegate(); } // Creates and initializes and empty content::WebContents that is backed by a @@ -119,8 +122,6 @@ class ScreenOrientationControllerTest : public test::AshTestBase { void SetUp() override; private: - ScreenOrientationController* screen_orientation_controller_; - // Optional content::BrowserContext used for two window tests. scoped_ptr<content::BrowserContext> secondary_browser_context_; @@ -156,8 +157,6 @@ void ScreenOrientationControllerTest::SetUp() { base::CommandLine::ForCurrentProcess()->AppendSwitch( switches::kAshEnableTouchViewTesting); test::AshTestBase::SetUp(); - screen_orientation_controller_ = - Shell::GetInstance()->screen_orientation_controller(); } // Tests that a content::WebContents can lock rotation. @@ -647,8 +646,8 @@ TEST_F(ScreenOrientationControllerTest, RotateInactiveDisplay) { ASSERT_NE(kNewRotation, display_manager->GetDisplayInfo(kInternalDisplayId) .GetActiveRotation()); - delegate()->SetDisplayRotation(kNewRotation, - gfx::Display::ROTATION_SOURCE_ACTIVE); + Shell::GetInstance()->screen_orientation_controller()->SetDisplayRotation( + kNewRotation, gfx::Display::ROTATION_SOURCE_ACTIVE); EXPECT_EQ(kNewRotation, display_manager->GetDisplayInfo(kInternalDisplayId) .GetActiveRotation()); diff --git a/ash/keyboard_overlay/DEPS b/ash/content/keyboard_overlay/DEPS index 1c35d9c..1c35d9c 100644 --- a/ash/keyboard_overlay/DEPS +++ b/ash/content/keyboard_overlay/DEPS diff --git a/ash/keyboard_overlay/keyboard_overlay_delegate.cc b/ash/content/keyboard_overlay/keyboard_overlay_delegate.cc index 76563f5b..91f299a 100644 --- a/ash/keyboard_overlay/keyboard_overlay_delegate.cc +++ b/ash/content/keyboard_overlay/keyboard_overlay_delegate.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/keyboard_overlay/keyboard_overlay_delegate.h" +#include "ash/content/keyboard_overlay/keyboard_overlay_delegate.h" #include <algorithm> @@ -28,9 +28,8 @@ const int kBaseHeight = 516; const int kHorizontalMargin = 28; // A message handler for detecting the timing when the web contents is painted. -class PaintMessageHandler - : public WebUIMessageHandler, - public base::SupportsWeakPtr<PaintMessageHandler> { +class PaintMessageHandler : public WebUIMessageHandler, + public base::SupportsWeakPtr<PaintMessageHandler> { public: explicit PaintMessageHandler(views::Widget* widget) : widget_(widget) {} ~PaintMessageHandler() override {} @@ -48,8 +47,7 @@ class PaintMessageHandler void PaintMessageHandler::RegisterMessages() { web_ui()->RegisterMessageCallback( - "didPaint", - base::Bind(&PaintMessageHandler::DidPaint, AsWeakPtr())); + "didPaint", base::Bind(&PaintMessageHandler::DidPaint, AsWeakPtr())); } void PaintMessageHandler::DidPaint(const base::ListValue* args) { @@ -63,13 +61,9 @@ namespace ash { KeyboardOverlayDelegate::KeyboardOverlayDelegate(const base::string16& title, const GURL& url) - : title_(title), - url_(url), - widget_(NULL) { -} + : title_(title), url_(url), widget_(NULL) {} -KeyboardOverlayDelegate::~KeyboardOverlayDelegate() { -} +KeyboardOverlayDelegate::~KeyboardOverlayDelegate() {} views::Widget* KeyboardOverlayDelegate::Show(views::WebDialogView* view) { widget_ = new views::Widget; @@ -82,12 +76,12 @@ views::Widget* KeyboardOverlayDelegate::Show(views::WebDialogView* view) { // Show the widget at the bottom of the work area. gfx::Size size; GetDialogSize(&size); - const gfx::Rect& rect = Shell::GetScreen()->GetDisplayNearestWindow( - widget_->GetNativeView()).work_area(); + const gfx::Rect& rect = + Shell::GetScreen() + ->GetDisplayNearestWindow(widget_->GetNativeView()) + .work_area(); gfx::Rect bounds(rect.x() + (rect.width() - size.width()) / 2, - rect.bottom() - size.height(), - size.width(), - size.height()); + rect.bottom() - size.height(), size.width(), size.height()); widget_->SetBounds(bounds); // The widget will be shown when the web contents gets ready to display. @@ -111,12 +105,12 @@ void KeyboardOverlayDelegate::GetWebUIMessageHandlers( handlers->push_back(new PaintMessageHandler(widget_)); } -void KeyboardOverlayDelegate::GetDialogSize( - gfx::Size* size) const { +void KeyboardOverlayDelegate::GetDialogSize(gfx::Size* size) const { using std::min; DCHECK(widget_); - gfx::Rect rect = ash::Shell::GetScreen()->GetDisplayNearestWindow( - widget_->GetNativeView()).work_area(); + gfx::Rect rect = ash::Shell::GetScreen() + ->GetDisplayNearestWindow(widget_->GetNativeView()) + .work_area(); const int width = min(kBaseWidth, rect.width() - kHorizontalMargin); const int height = width * kBaseHeight / kBaseWidth; size->SetSize(width, height); @@ -126,15 +120,13 @@ std::string KeyboardOverlayDelegate::GetDialogArgs() const { return "[]"; } -void KeyboardOverlayDelegate::OnDialogClosed( - const std::string& json_retval) { +void KeyboardOverlayDelegate::OnDialogClosed(const std::string& json_retval) { delete this; return; } void KeyboardOverlayDelegate::OnCloseContents(WebContents* source, - bool* out_close_dialog) { -} + bool* out_close_dialog) {} bool KeyboardOverlayDelegate::ShouldShowDialogTitle() const { return false; diff --git a/ash/keyboard_overlay/keyboard_overlay_delegate.h b/ash/content/keyboard_overlay/keyboard_overlay_delegate.h index eebc044..eebc044 100644 --- a/ash/keyboard_overlay/keyboard_overlay_delegate.h +++ b/ash/content/keyboard_overlay/keyboard_overlay_delegate.h diff --git a/ash/keyboard_overlay/keyboard_overlay_delegate_unittest.cc b/ash/content/keyboard_overlay/keyboard_overlay_delegate_unittest.cc index 2605263..ff206b3 100644 --- a/ash/keyboard_overlay/keyboard_overlay_delegate_unittest.cc +++ b/ash/content/keyboard_overlay/keyboard_overlay_delegate_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/keyboard_overlay/keyboard_overlay_delegate.h" +#include "ash/content/keyboard_overlay/keyboard_overlay_delegate.h" #include "ash/shelf/shelf_types.h" #include "ash/shell.h" diff --git a/ash/keyboard_overlay/keyboard_overlay_view.cc b/ash/content/keyboard_overlay/keyboard_overlay_view.cc index fe7c585..9673df2 100644 --- a/ash/keyboard_overlay/keyboard_overlay_view.cc +++ b/ash/content/keyboard_overlay/keyboard_overlay_view.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/keyboard_overlay/keyboard_overlay_view.h" +#include "ash/content/keyboard_overlay/keyboard_overlay_view.h" -#include "ash/keyboard_overlay/keyboard_overlay_delegate.h" +#include "ash/content/keyboard_overlay/keyboard_overlay_delegate.h" #include "ash/shell.h" #include "base/strings/utf_string_conversions.h" #include "grit/ash_strings.h" @@ -20,26 +20,22 @@ namespace { // Keys to invoke Cancel (Escape, Ctrl+Alt+/, or Shift+Ctrl+Alt+/, Help, F14). const ash::KeyboardOverlayView::KeyEventData kCancelKeys[] = { - { ui::VKEY_ESCAPE, ui::EF_NONE}, - { ui::VKEY_OEM_2, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN }, - { ui::VKEY_OEM_2, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN }, - { ui::VKEY_HELP, ui::EF_NONE }, - { ui::VKEY_F14, ui::EF_NONE }, + {ui::VKEY_ESCAPE, ui::EF_NONE}, + {ui::VKEY_OEM_2, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN}, + {ui::VKEY_OEM_2, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN}, + {ui::VKEY_HELP, ui::EF_NONE}, + {ui::VKEY_F14, ui::EF_NONE}, }; - } namespace ash { -KeyboardOverlayView::KeyboardOverlayView( - content::BrowserContext* context, - WebDialogDelegate* delegate, - WebContentsHandler* handler) - : views::WebDialogView(context, delegate, handler) { -} +KeyboardOverlayView::KeyboardOverlayView(content::BrowserContext* context, + WebDialogDelegate* delegate, + WebContentsHandler* handler) + : views::WebDialogView(context, delegate, handler) {} -KeyboardOverlayView::~KeyboardOverlayView() { -} +KeyboardOverlayView::~KeyboardOverlayView() {} void KeyboardOverlayView::Cancel() { Shell::GetInstance()->overlay_filter()->Deactivate(this); @@ -66,10 +62,9 @@ aura::Window* KeyboardOverlayView::GetWindow() { } // static -void KeyboardOverlayView::ShowDialog( - content::BrowserContext* context, - WebContentsHandler* handler, - const GURL& url) { +void KeyboardOverlayView::ShowDialog(content::BrowserContext* context, + WebContentsHandler* handler, + const GURL& url) { if (Shell::GetInstance()->overlay_filter()->IsActive()) return; diff --git a/ash/keyboard_overlay/keyboard_overlay_view.h b/ash/content/keyboard_overlay/keyboard_overlay_view.h index 99d0354..99d0354 100644 --- a/ash/keyboard_overlay/keyboard_overlay_view.h +++ b/ash/content/keyboard_overlay/keyboard_overlay_view.h diff --git a/ash/keyboard_overlay/keyboard_overlay_view_unittest.cc b/ash/content/keyboard_overlay/keyboard_overlay_view_unittest.cc index 1b2f297..62cdde7 100644 --- a/ash/keyboard_overlay/keyboard_overlay_view_unittest.cc +++ b/ash/content/keyboard_overlay/keyboard_overlay_view_unittest.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/keyboard_overlay/keyboard_overlay_view.h" +#include "ash/content/keyboard_overlay/keyboard_overlay_view.h" #include <algorithm> #include "ash/accelerators/accelerator_table.h" +#include "ash/content/keyboard_overlay/keyboard_overlay_delegate.h" #include "ash/content/shell_content_state.h" -#include "ash/keyboard_overlay/keyboard_overlay_delegate.h" #include "ash/shell.h" #include "ash/shell_delegate.h" #include "ash/test/ash_test_base.h" @@ -34,10 +34,9 @@ TEST_F(KeyboardOverlayViewTest, OpenAcceleratorsClose) { if (kAcceleratorData[i].action != SHOW_KEYBOARD_OVERLAY) continue; const AcceleratorData& open_key_data = kAcceleratorData[i]; - ui::KeyEvent open_key(open_key_data.trigger_on_press ? - ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED, - open_key_data.keycode, - open_key_data.modifiers); + ui::KeyEvent open_key(open_key_data.trigger_on_press ? ui::ET_KEY_PRESSED + : ui::ET_KEY_RELEASED, + open_key_data.keycode, open_key_data.modifiers); EXPECT_TRUE(view.IsCancelingKeyEvent(&open_key)); } } @@ -50,8 +49,7 @@ TEST_F(KeyboardOverlayViewTest, NoRedundantCancelingKeys) { continue; // Escape is used just for canceling. KeyboardOverlayView::KeyEventData open_key = { - kAcceleratorData[i].keycode, - kAcceleratorData[i].modifiers, + kAcceleratorData[i].keycode, kAcceleratorData[i].modifiers, }; open_keys.push_back(open_key); } @@ -61,7 +59,7 @@ TEST_F(KeyboardOverlayViewTest, NoRedundantCancelingKeys) { // Escape is used just for canceling, so exclude it from the comparison with // open keys. - KeyboardOverlayView::KeyEventData escape = { ui::VKEY_ESCAPE, ui::EF_NONE }; + KeyboardOverlayView::KeyEventData escape = {ui::VKEY_ESCAPE, ui::EF_NONE}; std::vector<KeyboardOverlayView::KeyEventData>::iterator escape_itr = std::find(canceling_keys.begin(), canceling_keys.end(), escape); canceling_keys.erase(escape_itr); diff --git a/ash/content/screen_orientation_delegate_chromeos.cc b/ash/content/screen_orientation_delegate_chromeos.cc new file mode 100644 index 0000000..68777e6 --- /dev/null +++ b/ash/content/screen_orientation_delegate_chromeos.cc @@ -0,0 +1,47 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/content/screen_orientation_delegate_chromeos.h" + +#include "ash/display/screen_orientation_controller_chromeos.h" +#include "ash/shell.h" +#include "content/public/browser/screen_orientation_provider.h" +#include "content/public/browser/web_contents.h" + +namespace ash { + +ScreenOrientationDelegateChromeos::ScreenOrientationDelegateChromeos() { + content::ScreenOrientationProvider::SetDelegate(this); +} +ScreenOrientationDelegateChromeos::~ScreenOrientationDelegateChromeos() { + content::ScreenOrientationProvider::SetDelegate(nullptr); +} + +bool ScreenOrientationDelegateChromeos::FullScreenRequired( + content::WebContents* web_contents) { + return true; +} + +void ScreenOrientationDelegateChromeos::Lock( + content::WebContents* web_contents, + blink::WebScreenOrientationLockType lock_orientation) { + Shell::GetInstance() + ->screen_orientation_controller() + ->LockOrientationForWindow(web_contents->GetNativeView(), + lock_orientation); +} + +bool ScreenOrientationDelegateChromeos::ScreenOrientationProviderSupported() { + return Shell::GetInstance() + ->screen_orientation_controller() + ->ScreenOrientationProviderSupported(); +} +void ScreenOrientationDelegateChromeos::Unlock( + content::WebContents* web_contents) { + Shell::GetInstance() + ->screen_orientation_controller() + ->UnlockOrientationForWindow(web_contents->GetNativeView()); +} + +} // namespace ash diff --git a/ash/content/screen_orientation_delegate_chromeos.h b/ash/content/screen_orientation_delegate_chromeos.h new file mode 100644 index 0000000..ce96841 --- /dev/null +++ b/ash/content/screen_orientation_delegate_chromeos.h @@ -0,0 +1,31 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/public/browser/screen_orientation_delegate.h" + +#ifndef ASH_CONTENT_SCREEN_ORIENTATION_DELEGATE_CHROMEOS_H_ +#define ASH_CONTENT_SCREEN_ORIENTATION_DELEGATE_CHROMEOS_H_ + +namespace ash { + +class ScreenOrientationDelegateChromeos + : public content::ScreenOrientationDelegate { + public: + ScreenOrientationDelegateChromeos(); + ~ScreenOrientationDelegateChromeos() override; + + private: + // content::ScreenOrientationDelegate: + bool FullScreenRequired(content::WebContents* web_contents) override; + void Lock(content::WebContents* web_contents, + blink::WebScreenOrientationLockType lock_orientation) override; + bool ScreenOrientationProviderSupported() override; + void Unlock(content::WebContents* web_contents) override; + + DISALLOW_COPY_AND_ASSIGN(ScreenOrientationDelegateChromeos); +}; + +} // namespace ash + +#endif // ASH_CONTENT_SCREEN_ORIENTATION_DELEGATE_CHROMEOS_H_
\ No newline at end of file diff --git a/ash/content/shell_content_state.h b/ash/content/shell_content_state.h index a9a6f8a..a1e79ba 100644 --- a/ash/content/shell_content_state.h +++ b/ash/content/shell_content_state.h @@ -9,6 +9,10 @@ #include "ash/session/session_types.h" #include "base/macros.h" +#if defined(OS_CHROMEOS) +#include "ash/content/screen_orientation_delegate_chromeos.h" +#endif + namespace aura { class Window; } @@ -46,6 +50,10 @@ class ASH_WITH_CONTENT_EXPORT ShellContentState { ShellContentState(); virtual ~ShellContentState(); +#if defined(OS_CHROMEOS) + ScreenOrientationDelegateChromeos orientation_delegate_; +#endif + private: static ShellContentState* instance_; diff --git a/ash/display/DEPS b/ash/display/DEPS index e2976071..66bd25d 100644 --- a/ash/display/DEPS +++ b/ash/display/DEPS @@ -1,4 +1,12 @@ include_rules = [ "+ash/host", ] - + +specific_include_rules = { + "display_color_manager_chromeos.cc": [ + "+third_party/qcms/src/qcms.h", + ], + "screen_orientation_controller_chromeos.h": [ + "+third_party/WebKit/public/platform/modules/screen_orientation/WebScreenOrientationLockType.h", + ], +} diff --git a/ash/content/display/display_color_manager_chromeos.cc b/ash/display/display_color_manager_chromeos.cc index f054bb0..060ee62 100644 --- a/ash/content/display/display_color_manager_chromeos.cc +++ b/ash/display/display_color_manager_chromeos.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/content/display/display_color_manager_chromeos.h" +#include "ash/display/display_color_manager_chromeos.h" #include "base/bind.h" #include "base/bind_helpers.h" @@ -11,13 +11,14 @@ #include "base/files/file_util.h" #include "base/format_macros.h" #include "base/logging.h" +#include "base/message_loop/message_loop.h" #include "base/path_service.h" #include "base/stl_util.h" #include "base/strings/stringprintf.h" +#include "base/task_runner_util.h" #include "base/threading/sequenced_worker_pool.h" #include "chromeos/chromeos_paths.h" #include "chromeos/chromeos_switches.h" -#include "content/public/browser/browser_thread.h" #include "third_party/qcms/src/qcms.h" #include "ui/display/types/display_snapshot.h" #include "ui/display/types/gamma_ramp_rgb_entry.h" @@ -90,8 +91,7 @@ base::FilePath PathForDisplaySnapshot(const ui::DisplaySnapshot* snapshot) { DisplayColorManager::DisplayColorManager( ui::DisplayConfigurator* configurator, base::SequencedWorkerPool* blocking_pool) - : configurator_(configurator), - blocking_pool_(blocking_pool) { + : configurator_(configurator), blocking_pool_(blocking_pool) { configurator_->AddObserver(this); } @@ -148,7 +148,7 @@ void DisplayColorManager::UpdateCalibrationData( int64_t product_id, scoped_ptr<ColorCalibrationData> data, bool success) { - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + DCHECK_EQ(base::MessageLoop::current()->type(), base::MessageLoop::TYPE_UI); if (success) { // The map takes over ownership of the underlying memory. calibration_map_[product_id] = data.release(); @@ -156,10 +156,8 @@ void DisplayColorManager::UpdateCalibrationData( } } -DisplayColorManager::ColorCalibrationData::ColorCalibrationData() { -} +DisplayColorManager::ColorCalibrationData::ColorCalibrationData() {} -DisplayColorManager::ColorCalibrationData::~ColorCalibrationData() { -} +DisplayColorManager::ColorCalibrationData::~ColorCalibrationData() {} } // namespace ash diff --git a/ash/content/display/display_color_manager_chromeos.h b/ash/display/display_color_manager_chromeos.h index 0613a9e..0613a9e 100644 --- a/ash/content/display/display_color_manager_chromeos.h +++ b/ash/display/display_color_manager_chromeos.h diff --git a/ash/content/display/screen_orientation_controller_chromeos.cc b/ash/display/screen_orientation_controller_chromeos.cc index 974dd65..31583563 100644 --- a/ash/content/display/screen_orientation_controller_chromeos.cc +++ b/ash/display/screen_orientation_controller_chromeos.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/content/display/screen_orientation_controller_chromeos.h" +#include "ash/display/screen_orientation_controller_chromeos.h" #include "ash/ash_switches.h" #include "ash/display/display_info.h" @@ -14,8 +14,6 @@ #include "base/command_line.h" #include "chromeos/accelerometer/accelerometer_reader.h" #include "chromeos/accelerometer/accelerometer_types.h" -#include "content/public/browser/screen_orientation_provider.h" -#include "content/public/browser/web_contents.h" #include "ui/aura/window.h" #include "ui/aura/window_observer.h" #include "ui/chromeos/accelerometer/accelerometer_util.h" @@ -71,12 +69,10 @@ ScreenOrientationController::ScreenOrientationController() rotation_locked_orientation_(blink::WebScreenOrientationLockAny), user_rotation_(gfx::Display::ROTATE_0), current_rotation_(gfx::Display::ROTATE_0) { - content::ScreenOrientationProvider::SetDelegate(this); Shell::GetInstance()->AddShellObserver(this); } ScreenOrientationController::~ScreenOrientationController() { - content::ScreenOrientationProvider::SetDelegate(NULL); Shell::GetInstance()->RemoveShellObserver(this); chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this); Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); @@ -93,6 +89,36 @@ void ScreenOrientationController::RemoveObserver(Observer* observer) { observers_.RemoveObserver(observer); } +void ScreenOrientationController::LockOrientationForWindow( + aura::Window* requesting_window, + blink::WebScreenOrientationLockType lock_orientation) { + if (locking_windows_.empty()) + Shell::GetInstance()->activation_client()->AddObserver(this); + + if (!requesting_window->HasObserver(this)) + requesting_window->AddObserver(this); + locking_windows_[requesting_window] = lock_orientation; + + ApplyLockForActiveWindow(); +} + +void ScreenOrientationController::UnlockOrientationForWindow( + aura::Window* window) { + locking_windows_.erase(window); + if (locking_windows_.empty()) + Shell::GetInstance()->activation_client()->RemoveObserver(this); + window->RemoveObserver(this); + ApplyLockForActiveWindow(); +} + +bool ScreenOrientationController::ScreenOrientationProviderSupported() const { + return Shell::GetInstance() + ->maximize_mode_controller() + ->IsMaximizeModeWindowManagerEnabled() && + !base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kAshDisableScreenOrientationLock); +} + void ScreenOrientationController::SetRotationLocked(bool rotation_locked) { if (rotation_locked_ == rotation_locked) return; @@ -151,7 +177,7 @@ void ScreenOrientationController::OnWindowVisibilityChanged( } void ScreenOrientationController::OnWindowDestroying(aura::Window* window) { - RemoveLockingWindow(window); + UnlockOrientationForWindow(window); } void ScreenOrientationController::OnAccelerometerUpdated( @@ -168,38 +194,6 @@ void ScreenOrientationController::OnAccelerometerUpdated( } } -bool ScreenOrientationController::FullScreenRequired( - content::WebContents* web_contents) { - return true; -} - -void ScreenOrientationController::Lock( - content::WebContents* web_contents, - blink::WebScreenOrientationLockType lock_orientation) { - if (locking_windows_.empty()) - Shell::GetInstance()->activation_client()->AddObserver(this); - - aura::Window* requesting_window = web_contents->GetNativeView(); - if (!requesting_window->HasObserver(this)) - requesting_window->AddObserver(this); - locking_windows_[requesting_window] = lock_orientation; - - ApplyLockForActiveWindow(); -} - -bool ScreenOrientationController::ScreenOrientationProviderSupported() { - return Shell::GetInstance() - ->maximize_mode_controller() - ->IsMaximizeModeWindowManagerEnabled() && - !base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kAshDisableScreenOrientationLock); -} - -void ScreenOrientationController::Unlock(content::WebContents* web_contents) { - aura::Window* requesting_window = web_contents->GetNativeView(); - RemoveLockingWindow(requesting_window); -} - void ScreenOrientationController::OnDisplayConfigurationChanged() { if (ignore_display_configuration_updates_) return; @@ -406,14 +400,6 @@ void ScreenOrientationController::ApplyLockForActiveWindow() { SetRotationLocked(false); } -void ScreenOrientationController::RemoveLockingWindow(aura::Window* window) { - locking_windows_.erase(window); - if (locking_windows_.empty()) - Shell::GetInstance()->activation_client()->RemoveObserver(this); - window->RemoveObserver(this); - ApplyLockForActiveWindow(); -} - bool ScreenOrientationController::IsRotationAllowedInLockedState( gfx::Display::Rotation rotation) { if (!rotation_locked_) diff --git a/ash/content/display/screen_orientation_controller_chromeos.h b/ash/display/screen_orientation_controller_chromeos.h index b387198..1157425 100644 --- a/ash/content/display/screen_orientation_controller_chromeos.h +++ b/ash/display/screen_orientation_controller_chromeos.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_CONTENT_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ -#define ASH_CONTENT_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ +#ifndef ASH_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ +#define ASH_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ #include <map> @@ -14,7 +14,6 @@ #include "base/observer_list.h" #include "chromeos/accelerometer/accelerometer_reader.h" #include "chromeos/accelerometer/accelerometer_types.h" -#include "content/public/browser/screen_orientation_delegate.h" #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScreenOrientationLockType.h" #include "ui/aura/window_observer.h" #include "ui/gfx/display.h" @@ -24,10 +23,6 @@ namespace aura { class Window; } -namespace content { -class WebContents; -} - namespace ash { // Implements ChromeOS specific functionality for ScreenOrientationProvider. @@ -35,7 +30,6 @@ class ASH_EXPORT ScreenOrientationController : public aura::client::ActivationChangeObserver, public aura::WindowObserver, public chromeos::AccelerometerReader::Observer, - public content::ScreenOrientationDelegate, public WindowTreeHostManager::Observer, public ShellObserver { public: @@ -57,6 +51,14 @@ class ASH_EXPORT ScreenOrientationController void AddObserver(Observer* observer); void RemoveObserver(Observer* observer); + // Allows/unallows a window to lock the screen orientation. + void LockOrientationForWindow( + aura::Window* requesting_windowwindow, + blink::WebScreenOrientationLockType lock_orientation); + void UnlockOrientationForWindow(aura::Window* window); + + bool ScreenOrientationProviderSupported() const; + bool ignore_display_configuration_updates() const { return ignore_display_configuration_updates_; } @@ -89,13 +91,6 @@ class ASH_EXPORT ScreenOrientationController void OnAccelerometerUpdated( scoped_refptr<const chromeos::AccelerometerUpdate> update) override; - // content::ScreenOrientationDelegate: - bool FullScreenRequired(content::WebContents* web_contents) override; - void Lock(content::WebContents* web_contents, - blink::WebScreenOrientationLockType lock_orientation) override; - bool ScreenOrientationProviderSupported() override; - void Unlock(content::WebContents* web_contents) override; - // WindowTreeHostManager::Observer: void OnDisplayConfigurationChanged() override; @@ -144,9 +139,6 @@ class ASH_EXPORT ScreenOrientationController // window, and applies it. If there is none, rotation lock will be removed. void ApplyLockForActiveWindow(); - // Removes a window and its locking preference. - void RemoveLockingWindow(aura::Window* window); - // Both |blink::WebScreenOrientationLockLandscape| and // |blink::WebScreenOrientationLockPortrait| allow for rotation between the // two angles of the same screen orientation @@ -192,4 +184,4 @@ class ASH_EXPORT ScreenOrientationController } // namespace ash -#endif // ASH_CONTENT_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ +#endif // ASH_DISPLAY_SCREEN_ORIENTATION_CONTROLLER_CHROMEOS_H_ diff --git a/ash/shell.cc b/ash/shell.cc index 2b73c98..20f464d 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -121,13 +121,13 @@ #include "ash/accelerators/magnifier_key_scroller.h" #include "ash/accelerators/spoken_feedback_toggler.h" #include "ash/ash_constants.h" -#include "ash/content/display/display_color_manager_chromeos.h" -#include "ash/content/display/screen_orientation_controller_chromeos.h" #include "ash/display/display_change_observer_chromeos.h" +#include "ash/display/display_color_manager_chromeos.h" #include "ash/display/display_configurator_animation.h" #include "ash/display/display_error_observer_chromeos.h" #include "ash/display/projecting_observer_chromeos.h" #include "ash/display/resolution_notification_controller.h" +#include "ash/display/screen_orientation_controller_chromeos.h" #include "ash/sticky_keys/sticky_keys_controller.h" #include "ash/system/chromeos/bluetooth/bluetooth_notification_controller.h" #include "ash/system/chromeos/brightness/brightness_controller_chromeos.h" diff --git a/ash/system/chromeos/rotation/tray_rotation_lock.cc b/ash/system/chromeos/rotation/tray_rotation_lock.cc index 060bc52..4704586 100644 --- a/ash/system/chromeos/rotation/tray_rotation_lock.cc +++ b/ash/system/chromeos/rotation/tray_rotation_lock.cc @@ -4,7 +4,7 @@ #include "ash/system/chromeos/rotation/tray_rotation_lock.h" -#include "ash/content/display/screen_orientation_controller_chromeos.h" +#include "ash/display/screen_orientation_controller_chromeos.h" #include "ash/shell.h" #include "ash/system/tray/system_tray.h" #include "ash/system/tray/tray_item_more.h" diff --git a/ash/system/chromeos/rotation/tray_rotation_lock.h b/ash/system/chromeos/rotation/tray_rotation_lock.h index aa4853e..a1df95a 100644 --- a/ash/system/chromeos/rotation/tray_rotation_lock.h +++ b/ash/system/chromeos/rotation/tray_rotation_lock.h @@ -5,7 +5,7 @@ #ifndef ASH_SYSTEM_CHROMEOS_ROTATION_TRAY_ROTATION_LOCK_H_ #define ASH_SYSTEM_CHROMEOS_ROTATION_TRAY_ROTATION_LOCK_H_ -#include "ash/content/display/screen_orientation_controller_chromeos.h" +#include "ash/display/screen_orientation_controller_chromeos.h" #include "ash/shell_observer.h" #include "ash/system/tray/tray_image_item.h" diff --git a/ash/system/chromeos/rotation/tray_rotation_lock_unittest.cc b/ash/system/chromeos/rotation/tray_rotation_lock_unittest.cc index 6d036e9..6ff259f 100644 --- a/ash/system/chromeos/rotation/tray_rotation_lock_unittest.cc +++ b/ash/system/chromeos/rotation/tray_rotation_lock_unittest.cc @@ -5,8 +5,8 @@ #include "ash/system/chromeos/rotation/tray_rotation_lock.h" #include "ash/ash_switches.h" -#include "ash/content/display/screen_orientation_controller_chromeos.h" #include "ash/display/display_manager.h" +#include "ash/display/screen_orientation_controller_chromeos.h" #include "ash/root_window_controller.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" diff --git a/ash/system/chromeos/tray_display.cc b/ash/system/chromeos/tray_display.cc index 1445d03..f8a0157 100644 --- a/ash/system/chromeos/tray_display.cc +++ b/ash/system/chromeos/tray_display.cc @@ -6,8 +6,8 @@ #include <vector> -#include "ash/content/display/screen_orientation_controller_chromeos.h" #include "ash/display/display_manager.h" +#include "ash/display/screen_orientation_controller_chromeos.h" #include "ash/display/window_tree_host_manager.h" #include "ash/shell.h" #include "ash/system/chromeos/devicetype_utils.h" diff --git a/ash/system/tray/media_security/multi_profile_media_tray_item.cc b/ash/system/tray/media_security/multi_profile_media_tray_item.cc index 468aa64..75c2190 100644 --- a/ash/system/tray/media_security/multi_profile_media_tray_item.cc +++ b/ash/system/tray/media_security/multi_profile_media_tray_item.cc @@ -5,7 +5,6 @@ #include "ash/system/tray/media_security/multi_profile_media_tray_item.h" #include "ash/ash_view_ids.h" -#include "ash/content/shell_content_state.h" #include "ash/media_delegate.h" #include "ash/session/session_state_delegate.h" #include "ash/shell.h" diff --git a/ash/system/user/user_card_view.cc b/ash/system/user/user_card_view.cc index e582c8a..6ce0c18 100644 --- a/ash/system/user/user_card_view.cc +++ b/ash/system/user/user_card_view.cc @@ -7,7 +7,6 @@ #include <algorithm> #include <vector> -#include "ash/content/shell_content_state.h" #include "ash/session/session_state_delegate.h" #include "ash/shell.h" #include "ash/system/tray/system_tray_delegate.h" diff --git a/ash/test/ash_test_helper.cc b/ash/test/ash_test_helper.cc index a01da66..995b9f5 100644 --- a/ash/test/ash_test_helper.cc +++ b/ash/test/ash_test_helper.cc @@ -49,7 +49,8 @@ AshTestHelper::AshTestHelper(base::MessageLoopForUI* message_loop) : message_loop_(message_loop), test_shell_delegate_(nullptr), test_screenshot_delegate_(nullptr), - content_state_(nullptr) { + content_state_(nullptr), + test_shell_content_state_(nullptr) { CHECK(message_loop_); #if defined(OS_CHROMEOS) dbus_thread_manager_initialized_ = false; @@ -94,8 +95,12 @@ void AshTestHelper::SetUp(bool start_session) { // created in AshTestBase tests. chromeos::CrasAudioHandler::InitializeForTesting(); #endif - ShellContentState::SetInstance(content_state_ ? content_state_ - : new TestShellContentState); + ShellContentState* content_state = content_state_; + if (!content_state) { + test_shell_content_state_ = new TestShellContentState; + content_state = test_shell_content_state_; + } + ShellContentState::SetInstance(content_state); ShellInitParams init_params; init_params.delegate = test_shell_delegate_; diff --git a/ash/test/ash_test_helper.h b/ash/test/ash_test_helper.h index eb5bf66..daa3316 100644 --- a/ash/test/ash_test_helper.h +++ b/ash/test/ash_test_helper.h @@ -29,6 +29,7 @@ class ShellContentState; namespace test { class TestScreenshotDelegate; +class TestShellContentState; class TestShellDelegate; class TestSessionStateDelegate; @@ -64,6 +65,9 @@ class AshTestHelper { TestScreenshotDelegate* test_screenshot_delegate() { return test_screenshot_delegate_; } + TestShellContentState* test_shell_content_state() { + return test_shell_content_state_; + } void set_content_state(ShellContentState* content_state) { content_state_ = content_state; } @@ -86,7 +90,13 @@ class AshTestHelper { scoped_ptr<views::ViewsDelegate> views_delegate_; + // An implementation of ShellContentState supplied by the user prior to + // SetUp(). ShellContentState* content_state_; + // If |content_state_| is not set prior to SetUp(), this value will be + // set to an instance of TestShellContentState created by this class. If + // |content_state_| is non-null, this will be nullptr. + TestShellContentState* test_shell_content_state_; #if defined(OS_CHROMEOS) // Check if DBus Thread Manager was initialized here. diff --git a/ash/test/content/test_shell_content_state.cc b/ash/test/content/test_shell_content_state.cc index a46094b..b34200a 100644 --- a/ash/test/content/test_shell_content_state.cc +++ b/ash/test/content/test_shell_content_state.cc @@ -7,10 +7,8 @@ #include "content/public/test/test_browser_context.h" namespace ash { +namespace test { -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. TestShellContentState::TestShellContentState() {} TestShellContentState::~TestShellContentState() {} @@ -35,4 +33,5 @@ TestShellContentState::GetUserPresentingBrowserContextForWindow( return nullptr; } +} // namespace test } // namespace ash diff --git a/ash/test/content/test_shell_content_state.h b/ash/test/content/test_shell_content_state.h index 1f96795..9b06dbe 100644 --- a/ash/test/content/test_shell_content_state.h +++ b/ash/test/content/test_shell_content_state.h @@ -13,11 +13,18 @@ class BrowserContext; } namespace ash { +namespace test { class TestShellContentState : public ShellContentState { public: TestShellContentState(); +#if defined(OS_CHROMEOS) + content::ScreenOrientationDelegate* screen_orientation_delegate() { + return &orientation_delegate_; + } +#endif + private: ~TestShellContentState() override; @@ -34,6 +41,7 @@ class TestShellContentState : public ShellContentState { DISALLOW_COPY_AND_ASSIGN(TestShellContentState); }; +} // namespace test } // namespace ash #endif // ASH_TEST_CONTENT_TEST_SHELL_CONTENT_STATE_H_ |