diff options
-rw-r--r-- | ash/display/display_controller.cc | 15 | ||||
-rw-r--r-- | ash/display/display_controller.h | 3 | ||||
-rw-r--r-- | ash/shell.cc | 6 | ||||
-rw-r--r-- | ash/shell.h | 6 | ||||
-rw-r--r-- | ash/test/ash_test_base.cc | 2 | ||||
-rw-r--r-- | ash/test/shell_test_api.cc | 15 | ||||
-rw-r--r-- | ash/test/shell_test_api.h | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/display/display_preferences.cc | 62 | ||||
-rw-r--r-- | chrome/browser/chromeos/display/display_preferences.h | 20 | ||||
-rw-r--r-- | chrome/browser/chromeos/display/display_preferences_unittest.cc | 52 | ||||
-rw-r--r-- | chrome/browser/ui/webui/options/chromeos/display_options_handler.cc | 49 | ||||
-rw-r--r-- | chrome/browser/ui/webui/options/chromeos/display_options_handler.h | 15 |
12 files changed, 135 insertions, 112 deletions
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc index d16af04..8ce4c2f 100644 --- a/ash/display/display_controller.cc +++ b/ash/display/display_controller.cc @@ -199,6 +199,11 @@ void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root, //////////////////////////////////////////////////////////////////////////////// // DisplayLayout +// static +DisplayLayout DisplayLayout::FromInts(int position, int offsets) { + return DisplayLayout(static_cast<Position>(position), offsets); +} + DisplayLayout::DisplayLayout() : position(RIGHT), offset(0) {} @@ -532,12 +537,10 @@ DisplayIdPair DisplayController::GetCurrentDisplayIdPair() const { DisplayIdPair pair; if (primary.IsInternal() || GetDisplayManager()->first_display_id() == primary.id()) { - pair.first = primary.id(); - pair.second = secondary.id(); + pair = std::make_pair(primary.id(), secondary.id()); } else { // Display has been Swapped. - pair.first = secondary.id(); - pair.second = primary.id(); + pair = std::make_pair(secondary.id(), primary.id()); } return pair; } @@ -864,9 +867,7 @@ void DisplayController::RegisterLayoutForDisplayIdPairInternal( int64 id2, const DisplayLayout& layout, bool override) { - DisplayIdPair pair; - pair.first = id1; - pair.second = id2; + DisplayIdPair pair = std::make_pair(id1, id2); if (override || paired_layouts_.find(pair) == paired_layouts_.end()) paired_layouts_[pair] = layout; } diff --git a/ash/display/display_controller.h b/ash/display/display_controller.h index f58dc12..051704c 100644 --- a/ash/display/display_controller.h +++ b/ash/display/display_controller.h @@ -44,6 +44,9 @@ struct ASH_EXPORT DisplayLayout { BOTTOM, LEFT }; + // Factory method to create DisplayLayout from int values. + // Used for persistence and webui. + static DisplayLayout FromInts(int position, int offsets); DisplayLayout(); DisplayLayout(Position position, int offset); diff --git a/ash/shell.cc b/ash/shell.cc index 366d2e3..8660194 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -417,15 +417,15 @@ bool Shell::IsLauncherPerDisplayEnabled() { void Shell::Init() { #if defined(OS_CHROMEOS) + output_configurator_animation_.reset( + new internal::OutputConfiguratorAnimation()); + output_configurator_->AddObserver(output_configurator_animation_.get()); if (base::chromeos::IsRunningOnChromeOS()) { display_change_observer_.reset(new internal::DisplayChangeObserverX11); // Register |display_change_observer_| first so that the rest of // observer gets invoked after the root windows are configured. output_configurator_->AddObserver(display_change_observer_.get()); - output_configurator_animation_.reset( - new internal::OutputConfiguratorAnimation()); display_error_observer_.reset(new internal::DisplayErrorObserver()); - output_configurator_->AddObserver(output_configurator_animation_.get()); output_configurator_->AddObserver(display_error_observer_.get()); display_change_observer_->OnDisplayModeChanged(); } diff --git a/ash/shell.h b/ash/shell.h index 1b659b8..7e3fab3c 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -425,6 +425,7 @@ class ASH_EXPORT Shell void DoInitialWorkspaceAnimation(); #if defined(OS_CHROMEOS) + // TODO(oshima): Move these objects to DisplayController. chromeos::OutputConfigurator* output_configurator() { return output_configurator_.get(); } @@ -466,11 +467,6 @@ class ASH_EXPORT Shell // can host browser windows. void InitRootWindowController(internal::RootWindowController* root); - // Initializes the layout managers and event filters specific for - // primary display. - void InitLayoutManagersForPrimaryDisplay( - internal::RootWindowController* root_window_controller); - // ash::internal::SystemModalContainerEventFilterDelegate overrides: virtual bool CanWindowReceiveEvents(aura::Window* window) OVERRIDE; diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc index 2e2dd3e..ce7dad2 100644 --- a/ash/test/ash_test_base.cc +++ b/ash/test/ash_test_base.cc @@ -13,6 +13,7 @@ #include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/test/display_manager_test_api.h" +#include "ash/test/shell_test_api.h" #include "ash/test/test_shell_delegate.h" #include "ash/wm/coordinate_conversion.h" #include "base/command_line.h" @@ -119,6 +120,7 @@ void AshTestBase::SetUp() { // interfere test expectations. Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000)); shell->cursor_manager()->EnableMouseEvents(); + ShellTestApi(shell).DisableOutputConfiguratorAnimation(); #if defined(OS_WIN) if (base::win::GetVersion() >= base::win::VERSION_WIN8) { diff --git a/ash/test/shell_test_api.cc b/ash/test/shell_test_api.cc index f4ba794..72b869a 100644 --- a/ash/test/shell_test_api.cc +++ b/ash/test/shell_test_api.cc @@ -7,6 +7,11 @@ #include "ash/root_window_controller.h" #include "ash/shell.h" +#if defined(OS_CHROMEOS) +#include "ash/display/output_configurator_animation.h" +#include "chromeos/display/output_configurator.h" +#endif + namespace ash { namespace test { @@ -43,5 +48,15 @@ LauncherModel* ShellTestApi::launcher_model() { return shell_->launcher_model_.get(); } +void ShellTestApi::DisableOutputConfiguratorAnimation() { +#if defined(OS_CHROMEOS) + if (shell_->output_configurator_animation_.get()) { + shell_->output_configurator_->RemoveObserver( + shell_->output_configurator_animation_.get()); + shell_->output_configurator_animation_.reset(); + } +#endif // defined(OS_CHROMEOS) +} + } // namespace test } // namespace ash diff --git a/ash/test/shell_test_api.h b/ash/test/shell_test_api.h index 8f0ea44..f36716a 100644 --- a/ash/test/shell_test_api.h +++ b/ash/test/shell_test_api.h @@ -40,6 +40,8 @@ public: AshNativeCursorManager* ash_native_cursor_manager(); LauncherModel* launcher_model(); + void DisableOutputConfiguratorAnimation(); + private: Shell* shell_; // not owned diff --git a/chrome/browser/chromeos/display/display_preferences.cc b/chrome/browser/chromeos/display/display_preferences.cc index f62485e..259c829 100644 --- a/chrome/browser/chromeos/display/display_preferences.cc +++ b/chrome/browser/chromeos/display/display_preferences.cc @@ -76,9 +76,8 @@ void NotifyDisplayLayoutChanged() { PrefService* local_state = g_browser_process->local_state(); ash::DisplayController* display_controller = GetDisplayController(); - ash::DisplayLayout default_layout( - static_cast<ash::DisplayLayout::Position>(local_state->GetInteger( - prefs::kSecondaryDisplayLayout)), + ash::DisplayLayout default_layout = ash::DisplayLayout::FromInts( + local_state->GetInteger(prefs::kSecondaryDisplayLayout), local_state->GetInteger(prefs::kSecondaryDisplayOffset)); display_controller->SetDefaultDisplayLayout(default_layout); @@ -144,10 +143,10 @@ void NotifyDisplayOverscans() { } } -void StoreDisplayLayoutPref(int64 id1, - int64 id2, +void StoreDisplayLayoutPref(const ash::DisplayIdPair& pair, const ash::DisplayLayout& display_layout) { - std::string name = base::Int64ToString(id1) + "," + base::Int64ToString(id2); + std::string name = + base::Int64ToString(pair.first) + "," + base::Int64ToString(pair.second); PrefService* local_state = g_browser_process->local_state(); DictionaryPrefUpdate update(local_state, prefs::kSecondaryDisplays); @@ -160,10 +159,6 @@ void StoreDisplayLayoutPref(int64 id1, } if (ash::DisplayLayout::ConvertToValue(display_layout, layout_value.get())) pref_data->Set(name, layout_value.release()); - local_state->SetInteger(prefs::kSecondaryDisplayLayout, - static_cast<int>(display_layout.position)); - local_state->SetInteger(prefs::kSecondaryDisplayOffset, - display_layout.offset); } void StoreCurrentDisplayLayoutPrefs() { @@ -171,11 +166,10 @@ void StoreCurrentDisplayLayoutPrefs() { return; ash::DisplayController* display_controller = GetDisplayController(); - ash::DisplayLayout display_layout = - display_controller->GetCurrentDisplayLayout(); ash::DisplayIdPair pair = display_controller->GetCurrentDisplayIdPair(); - - StoreDisplayLayoutPref(pair.first, pair.second, display_layout); + ash::DisplayLayout display_layout = + display_controller->GetRegisteredDisplayLayout(pair); + StoreDisplayLayoutPref(pair, display_layout); } @@ -220,19 +214,22 @@ void StoreDisplayPrefs() { } } -void SetAndStoreDisplayLayoutPref(int layout, int offset) { - ash::DisplayLayout display_layout( - static_cast<ash::DisplayLayout::Position>(layout), offset); - ash::Shell::GetInstance()->display_controller()-> - SetLayoutForCurrentDisplays(display_layout); - StoreCurrentDisplayLayoutPrefs(); -} +void SetCurrentAndDefaultDisplayLayout(const ash::DisplayLayout& layout) { + ash::DisplayController* display_controller = GetDisplayController(); + display_controller->SetLayoutForCurrentDisplays(layout); -void StoreDisplayLayoutPref(int64 id1, int64 id2, - int layout, int offset) { - ash::DisplayLayout display_layout( - static_cast<ash::DisplayLayout::Position>(layout), offset); - StoreDisplayLayoutPref(id1, id2, display_layout); + if (IsValidUser()) { + PrefService* local_state = g_browser_process->local_state(); + ash::DisplayIdPair pair = display_controller->GetCurrentDisplayIdPair(); + // Use registered layout as the layout might have been inverted when + // the displays are swapped. + ash::DisplayLayout display_layout = + display_controller->GetRegisteredDisplayLayout(pair); + local_state->SetInteger(prefs::kSecondaryDisplayLayout, + static_cast<int>(display_layout.position)); + local_state->SetInteger(prefs::kSecondaryDisplayOffset, + display_layout.offset); + } } void SetAndStoreDisplayOverscan(const gfx::Display& display, @@ -252,12 +249,6 @@ void SetAndStoreDisplayOverscan(const gfx::Display& display, display.id(), insets); } -void SetAndStorePrimaryDisplayIDPref(int64 display_id) { - StorePrimaryDisplayIDPref(display_id); - ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplayId( - display_id); -} - void NotifyDisplayLocalStatePrefChanged() { PrefService* local_state = g_browser_process->local_state(); ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplayId( @@ -266,4 +257,11 @@ void NotifyDisplayLocalStatePrefChanged() { NotifyDisplayOverscans(); } +// Stores the display layout for given display pairs. +void StoreDisplayLayoutPrefForTest(int64 id1, + int64 id2, + const ash::DisplayLayout& layout) { + StoreDisplayLayoutPref(std::make_pair(id1, id2), layout); +} + } // namespace chromeos diff --git a/chrome/browser/chromeos/display/display_preferences.h b/chrome/browser/chromeos/display/display_preferences.h index 9e54511..a29845c 100644 --- a/chrome/browser/chromeos/display/display_preferences.h +++ b/chrome/browser/chromeos/display/display_preferences.h @@ -9,6 +9,10 @@ class PrefRegistrySimple; +namespace ash { +struct DisplayLayout; +} + namespace gfx { class Display; class Insets; @@ -24,15 +28,8 @@ void RegisterDisplayLocalStatePrefs(PrefRegistrySimple* registry); // dispay layout). void StoreDisplayPrefs(); -// Sets the display layout for the current displays and store them. -void SetAndStoreDisplayLayoutPref(int layout, int offset); - -// Stores the display layout for given display pairs. -void StoreDisplayLayoutPref(int64 id1, int64 id2, int layout, int offset); - -// Sets and stores the primary display device by its ID, and notifies -// the update to the system. -void SetAndStorePrimaryDisplayIDPref(int64 display_id); +// Sets the display layout for the current displays and default. +void SetCurrentAndDefaultDisplayLayout(const ash::DisplayLayout& layout); // Sets and saves the overscan preference for the specified |display| to Local // State. @@ -43,6 +40,11 @@ void SetAndStoreDisplayOverscan(const gfx::Display& display, // system. void NotifyDisplayLocalStatePrefChanged(); +// Stores the display layout for given display pairs. +void StoreDisplayLayoutPrefForTest(int64 id1, + int64 id2, + const ash::DisplayLayout& layout); + } // namespace chromeos #endif // CHROME_BROWSER_CHROMEOS_DISPLAY_DISPLAY_PREFERENCES_H_ diff --git a/chrome/browser/chromeos/display/display_preferences_unittest.cc b/chrome/browser/chromeos/display/display_preferences_unittest.cc index 31242cb..43c0b8b 100644 --- a/chrome/browser/chromeos/display/display_preferences_unittest.cc +++ b/chrome/browser/chromeos/display/display_preferences_unittest.cc @@ -11,6 +11,7 @@ #include "base/prefs/testing_pref_service.h" #include "base/strings/string_number_conversions.h" #include "base/values.h" +#include "chrome/browser/chromeos/display/display_configuration_observer.h" #include "chrome/browser/chromeos/login/mock_user_manager.h" #include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" @@ -20,6 +21,10 @@ namespace chromeos { namespace { +ash::DisplayController* GetDisplayController() { + return ash::Shell::GetInstance()->display_controller(); +} + class DisplayPreferencesTest : public ash::test::AshTestBase { protected: DisplayPreferencesTest() : ash::test::AshTestBase() {} @@ -29,9 +34,11 @@ class DisplayPreferencesTest : public ash::test::AshTestBase { ash::test::AshTestBase::SetUp(); RegisterDisplayLocalStatePrefs(local_state_.registry()); TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); + observer_.reset(new DisplayConfigurationObserver()); } virtual void TearDown() OVERRIDE { + observer_.reset(); TestingBrowserProcess::GetGlobal()->SetLocalState(NULL); ash::test::AshTestBase::TearDown(); } @@ -131,6 +138,7 @@ class DisplayPreferencesTest : public ash::test::AshTestBase { private: ScopedMockUserManagerEnabler mock_user_manager_; TestingPrefServiceSimple local_state_; + scoped_ptr<DisplayConfigurationObserver> observer_; DISALLOW_COPY_AND_ASSIGN(DisplayPreferencesTest); }; @@ -201,10 +209,13 @@ TEST_F(DisplayPreferencesTest, BasicStores) { LoggedInAsUser(); ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); - SetAndStoreDisplayLayoutPref(static_cast<int>(layout.position), - layout.offset); - StoreDisplayLayoutPref(id1, dummy_id, ash::DisplayLayout::LEFT, 20); - SetAndStorePrimaryDisplayIDPref(dummy_id); + SetCurrentAndDefaultDisplayLayout(layout); + StoreDisplayLayoutPrefForTest( + id1, dummy_id, ash::DisplayLayout(ash::DisplayLayout::LEFT, 20)); + // Can't switch to a display that does not exist. + GetDisplayController()->SetPrimaryDisplayId(dummy_id); + EXPECT_NE(dummy_id, local_state()->GetInt64(prefs::kPrimaryDisplayID)); + SetAndStoreDisplayOverscan( ash::ScreenAsh::GetNativeScreen()->GetPrimaryDisplay(), gfx::Insets(10, 11, 12, 13)); @@ -222,10 +233,10 @@ TEST_F(DisplayPreferencesTest, BasicStores) { EXPECT_TRUE(serialized_value->Equals(display_layout)); // The default value is set for the last call of - // StoreDisplayLayoutPref() - EXPECT_EQ(ash::DisplayLayout::LEFT, + // SetCurrentAndDefaultDisplayLayout + EXPECT_EQ(ash::DisplayLayout::TOP, local_state()->GetInteger(prefs::kSecondaryDisplayLayout)); - EXPECT_EQ(20, local_state()->GetInteger(prefs::kSecondaryDisplayOffset)); + EXPECT_EQ(10, local_state()->GetInteger(prefs::kSecondaryDisplayOffset)); const base::DictionaryValue* overscans = local_state()->GetDictionary(prefs::kDisplayOverscans); @@ -240,7 +251,23 @@ TEST_F(DisplayPreferencesTest, BasicStores) { EXPECT_EQ(11, left); EXPECT_EQ(12, bottom); EXPECT_EQ(13, right); - EXPECT_EQ(dummy_id, local_state()->GetInt64(prefs::kPrimaryDisplayID)); + + GetDisplayController()->SetPrimaryDisplayId(id2); + EXPECT_EQ(id2, local_state()->GetInt64(prefs::kPrimaryDisplayID)); + // The layout remains the same. + EXPECT_TRUE(displays->GetDictionary(key, &display_layout)); + EXPECT_TRUE(serialized_value->Equals(display_layout)); + // Default value should changte. + EXPECT_EQ(ash::DisplayLayout::TOP, + local_state()->GetInteger(prefs::kSecondaryDisplayLayout)); + EXPECT_EQ(10, local_state()->GetInteger(prefs::kSecondaryDisplayOffset)); + + SetCurrentAndDefaultDisplayLayout( + ash::DisplayLayout(ash::DisplayLayout::BOTTOM, 20)); + // Displays are swapped, so does the default layout. + EXPECT_EQ(ash::DisplayLayout::TOP, + local_state()->GetInteger(prefs::kSecondaryDisplayLayout)); + EXPECT_EQ(-20, local_state()->GetInteger(prefs::kSecondaryDisplayOffset)); } TEST_F(DisplayPreferencesTest, StoreForSwappedDisplay) { @@ -255,8 +282,8 @@ TEST_F(DisplayPreferencesTest, StoreForSwappedDisplay) { LoggedInAsUser(); ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); - SetAndStoreDisplayLayoutPref(static_cast<int>(layout.position), - layout.offset); + SetCurrentAndDefaultDisplayLayout(layout); + layout = layout.Invert(); scoped_ptr<base::DictionaryValue> layout_value( new base::DictionaryValue()); @@ -280,9 +307,8 @@ TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { LoggedInAsGuest(); int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id(); ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); - SetAndStoreDisplayLayoutPref(static_cast<int>(layout.position), - layout.offset); - SetAndStorePrimaryDisplayIDPref(id2); + SetCurrentAndDefaultDisplayLayout(layout); + GetDisplayController()->SetPrimaryDisplayId(id2); SetAndStoreDisplayOverscan( ash::ScreenAsh::GetNativeScreen()->GetPrimaryDisplay(), gfx::Insets(10, 11, 12, 13)); diff --git a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc index 8d77f14..8ab7729 100644 --- a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc @@ -38,11 +38,11 @@ DisplayManager* GetDisplayManager() { } // namespace DisplayOptionsHandler::DisplayOptionsHandler() { - ash::Shell::GetScreen()->AddObserver(this); + ash::Shell::GetInstance()->display_controller()->AddObserver(this); } DisplayOptionsHandler::~DisplayOptionsHandler() { - ash::Shell::GetScreen()->RemoveObserver(this); + ash::Shell::GetInstance()->display_controller()->RemoveObserver(this); } void DisplayOptionsHandler::GetLocalizedValues( @@ -67,7 +67,7 @@ void DisplayOptionsHandler::GetLocalizedValues( void DisplayOptionsHandler::InitializePage() { DCHECK(web_ui()); - UpdateDisplaySectionVisibility(GetDisplayManager()->GetNumDisplays()); + UpdateDisplaySectionVisibility(); } void DisplayOptionsHandler::RegisterMessages() { @@ -89,38 +89,19 @@ void DisplayOptionsHandler::RegisterMessages() { base::Unretained(this))); } -void DisplayOptionsHandler::OnDisplayBoundsChanged( - const gfx::Display& display) { +void DisplayOptionsHandler::OnDisplayConfigurationChanging() { } -void DisplayOptionsHandler::OnDisplayAdded(const gfx::Display& new_display) { - UpdateDisplaySectionVisibility(GetDisplayManager()->GetNumDisplays()); +void DisplayOptionsHandler::OnDisplayConfigurationChanged() { + UpdateDisplaySectionVisibility(); SendAllDisplayInfo(); } -void DisplayOptionsHandler::OnDisplayRemoved(const gfx::Display& old_display) { +void DisplayOptionsHandler::UpdateDisplaySectionVisibility() { DisplayManager* display_manager = GetDisplayManager(); - UpdateDisplaySectionVisibility(display_manager->GetNumDisplays() - 1); - - std::vector<const gfx::Display*> displays; - for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { - const gfx::Display* display = display_manager->GetDisplayAt(i); - if (display->id() != old_display.id()) - displays.push_back(display); - } - SendDisplayInfo(displays); -} - -void DisplayOptionsHandler::UpdateDisplaySectionVisibility( - size_t num_displays) { - DisplayManager* display_manager = GetDisplayManager(); - size_t min_displays_to_show = display_manager->HasInternalDisplay() ? 2 : 1; - - chromeos::OutputState output_state = - ash::Shell::GetInstance()->output_configurator()->output_state(); + size_t num_displays = display_manager->num_connected_displays(); base::FundamentalValue show_options( - num_displays >= min_displays_to_show || - output_state == chromeos::STATE_DUAL_MIRROR); + num_displays > 1 || !display_manager->HasInternalDisplay()); web_ui()->CallJavascriptFunction( "options.BrowserOptions.showDisplayOptions", show_options); } @@ -181,14 +162,13 @@ void DisplayOptionsHandler::OnFadeOutForMirroringFinished(bool is_mirroring) { chromeos::OutputState new_state = is_mirroring ? STATE_DUAL_MIRROR : STATE_DUAL_EXTENDED; ash::Shell::GetInstance()->output_configurator()->SetDisplayMode(new_state); - SendAllDisplayInfo(); // Not necessary to start fade-in animation. OutputConfigurator will do that. } void DisplayOptionsHandler::OnFadeOutForDisplayLayoutFinished( - int layout, int offset) { - SetAndStoreDisplayLayoutPref(layout, offset); - SendAllDisplayInfo(); + int position, int offset) { + SetCurrentAndDefaultDisplayLayout( + ash::DisplayLayout::FromInts(position, offset)); ash::Shell::GetInstance()->output_configurator_animation()-> StartFadeInAnimation(); } @@ -224,9 +204,8 @@ void DisplayOptionsHandler::HandleSetPrimary(const base::ListValue* args) { LOG(ERROR) << "Invalid parameter: " << id_value; return; } - - SetAndStorePrimaryDisplayIDPref(display_id); - SendAllDisplayInfo(); + ash::Shell::GetInstance()->display_controller()-> + SetPrimaryDisplayId(display_id); } void DisplayOptionsHandler::HandleDisplayLayout(const base::ListValue* args) { diff --git a/chrome/browser/ui/webui/options/chromeos/display_options_handler.h b/chrome/browser/ui/webui/options/chromeos/display_options_handler.h index 6b972d1..1093612 100644 --- a/chrome/browser/ui/webui/options/chromeos/display_options_handler.h +++ b/chrome/browser/ui/webui/options/chromeos/display_options_handler.h @@ -7,8 +7,8 @@ #include <vector> +#include "ash/display/display_controller.h" #include "chrome/browser/ui/webui/options/options_ui.h" -#include "ui/gfx/display_observer.h" namespace base { class DictionaryValue; @@ -20,7 +20,7 @@ namespace options { // Display options overlay page UI handler. class DisplayOptionsHandler : public ::options::OptionsPageUIHandler, - public gfx::DisplayObserver { + public ash::DisplayController::Observer { public: DisplayOptionsHandler(); virtual ~DisplayOptionsHandler(); @@ -33,15 +33,14 @@ class DisplayOptionsHandler : public ::options::OptionsPageUIHandler, // WebUIMessageHandler implementation. virtual void RegisterMessages() OVERRIDE; - // gfx::DisplayObserver implementation. - virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE; - virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE; - virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE; + // ash::DisplayController::Observer implementation. + virtual void OnDisplayConfigurationChanging() OVERRIDE; + virtual void OnDisplayConfigurationChanged() OVERRIDE; private: // Updates the display section visibility based on the current display - // configurations. Specify the number of display. - void UpdateDisplaySectionVisibility(size_t num_displays); + // configurations. + void UpdateDisplaySectionVisibility(); // Sends all of the current display information to the web_ui of options page. void SendAllDisplayInfo(); |