Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1574)

Unified Diff: chrome/browser/ui/webui/options/chromeos/display_options_handler.cc

Issue 10870036: Allow storing display preferences per device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..67c08888e57bcb3acae4a60969e3d951355d06d7 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_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 =
+ 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,

Powered by Google App Engine
This is Rietveld 408576698