Chromium Code Reviews| Index: chrome/browser/ui/webui/options/chromeos/display_options_handler.cc |
| 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 dd76835945b7d9da6c8efd3986422e11876f3642..87812411640c78b4dd43a72e7a9e707a7ef0b773 100644 |
| --- a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc |
| +++ b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc |
| @@ -14,7 +14,7 @@ |
| #include "base/logging.h" |
| #include "base/stringprintf.h" |
| #include "base/values.h" |
| -#include "chrome/browser/prefs/pref_service.h" |
| +#include "chrome/browser/chromeos/display/display_preferences.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/common/pref_names.h" |
| #include "chromeos/display/output_configurator.h" |
| @@ -29,7 +29,7 @@ |
| namespace chromeos { |
| namespace options { |
| -using ash::internal::DisplayController; |
| +using ash::internal::DisplayLayout; |
| DisplayOptionsHandler::DisplayOptionsHandler() { |
| aura::Env::GetInstance()->display_manager()->AddObserver(this); |
| @@ -93,7 +93,7 @@ void DisplayOptionsHandler::UpdateDisplaySectionVisibility() { |
| chromeos::OutputState output_state = |
| ash::Shell::GetInstance()->output_configurator()->output_state(); |
| base::FundamentalValue show_options( |
| - DisplayController::IsExtendedDesktopEnabled() && |
| + ash::internal::DisplayController::IsExtendedDesktopEnabled() && |
| output_state != chromeos::STATE_INVALID && |
| output_state != chromeos::STATE_HEADLESS && |
| output_state != chromeos::STATE_SINGLE); |
| @@ -104,6 +104,8 @@ void DisplayOptionsHandler::UpdateDisplaySectionVisibility() { |
| void DisplayOptionsHandler::SendDisplayInfo() { |
| aura::DisplayManager* display_manager = |
| aura::Env::GetInstance()->display_manager(); |
| + ash::internal::DisplayController* display_controller = |
|
sky
2012/08/29 15:05:57
Classes that are needed outside of ash shouldn't b
Jun Mukai
2012/08/30 02:08:04
Done.
|
| + ash::Shell::GetInstance()->display_controller(); |
| chromeos::OutputConfigurator* output_configurator = |
| ash::Shell::GetInstance()->output_configurator(); |
| base::FundamentalValue mirroring( |
| @@ -123,15 +125,20 @@ void DisplayOptionsHandler::SendDisplayInfo() { |
| displays.Set(i, js_display); |
| } |
| - PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| - base::FundamentalValue layout( |
| - pref_service->GetInteger(prefs::kSecondaryDisplayLayout)); |
| - base::FundamentalValue offset( |
| - pref_service->GetInteger(prefs::kSecondaryDisplayOffset)); |
| + scoped_ptr<base::Value> layout_value(base::Value::CreateNullValue()); |
| + scoped_ptr<base::Value> offset_value(base::Value::CreateNullValue()); |
| + if (display_manager->GetNumDisplays() > 1) { |
| + const std::string& secondary_display_name = |
| + display_manager->GetDisplayNameAt(1); |
| + const DisplayLayout& layout = |
| + display_controller->GetLayoutForDisplayName(secondary_display_name); |
| + layout_value.reset(new base::FundamentalValue(layout.position)); |
| + offset_value.reset(new base::FundamentalValue(layout.offset)); |
| + } |
| web_ui()->CallJavascriptFunction( |
| "options.DisplayOptions.setDisplayInfo", |
| - mirroring, displays, layout, offset); |
| + mirroring, displays, *layout_value, *offset_value); |
| } |
| void DisplayOptionsHandler::FadeOutForMirroringFinished(bool is_mirroring) { |
| @@ -147,8 +154,15 @@ void DisplayOptionsHandler::FadeOutForMirroringFinished(bool is_mirroring) { |
| void DisplayOptionsHandler::FadeOutForDisplayLayoutFinished( |
| int layout, int offset) { |
| PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| - pref_service->SetInteger(prefs::kSecondaryDisplayLayout, layout); |
| - pref_service->SetInteger(prefs::kSecondaryDisplayOffset, offset); |
| + aura::DisplayManager* display_manager = |
| + aura::Env::GetInstance()->display_manager(); |
| + // Assumes that there are two displays at most and the second item is the |
| + // secondary display. |
| + if (display_manager->GetNumDisplays() > 1) { |
| + gfx::Display* display = display_manager->GetDisplayAt(1); |
| + SetDisplayLayoutPref(pref_service, *display, layout, offset); |
| + } |
| + |
| SendDisplayInfo(); |
| ash::Shell::GetInstance()->output_configurator_animation()-> |
| StartFadeInAnimation(); |
| @@ -178,8 +192,8 @@ void DisplayOptionsHandler::HandleDisplayLayout(const base::ListValue* args) { |
| SendDisplayInfo(); |
| return; |
| } |
| - DCHECK_LE(DisplayController::TOP, layout); |
| - DCHECK_GE(DisplayController::LEFT, layout); |
| + DCHECK_LE(DisplayLayout::TOP, layout); |
| + DCHECK_GE(DisplayLayout::LEFT, layout); |
| ash::Shell::GetInstance()->output_configurator_animation()-> |
| StartFadeOutAnimation(base::Bind( |
| &DisplayOptionsHandler::FadeOutForDisplayLayoutFinished, |