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

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: 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..2c24fb5227836d3b292be8684feed352bc0fa886 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,34 +104,39 @@ 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(
output_configurator->output_state() == chromeos::STATE_DUAL_MIRROR);
base::ListValue displays;
+ scoped_ptr<base::Value> layout_value(base::Value::CreateNullValue());
+ scoped_ptr<base::Value> offset_value(base::Value::CreateNullValue());
for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
const gfx::Display* display = display_manager->GetDisplayAt(i);
const gfx::Rect& bounds = display->bounds();
+ const std::string& display_name = display_manager->GetDisplayNameAt(i);
base::DictionaryValue* js_display = new base::DictionaryValue();
js_display->SetDouble("id", display->id());
js_display->SetDouble("x", bounds.x());
js_display->SetDouble("y", bounds.y());
js_display->SetDouble("width", bounds.width());
js_display->SetDouble("height", bounds.height());
- js_display->SetString("name", display_manager->GetDisplayNameAt(i));
+ js_display->SetString("name", display_name);
displays.Set(i, js_display);
+ if (i > 0) {
oshima 2012/08/29 00:10:44 I assume we're dropping 0 because 0 is primary and
Jun Mukai 2012/08/29 02:15:03 Hmm, I'm afraid no. the layout and offset are spe
+ const DisplayLayout& layout =
+ display_controller->GetLayoutForDisplayName(display_name);
+ layout_value.reset(new base::FundamentalValue(layout.position));
+ offset_value.reset(new base::FundamentalValue(layout.offset));
+ }
}
- PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
- base::FundamentalValue layout(
- pref_service->GetInteger(prefs::kSecondaryDisplayLayout));
- base::FundamentalValue offset(
- pref_service->GetInteger(prefs::kSecondaryDisplayOffset));
-
web_ui()->CallJavascriptFunction(
"options.DisplayOptions.setDisplayInfo",
- mirroring, displays, layout, offset);
+ mirroring, displays, *layout_value, *offset_value);
}
void DisplayOptionsHandler::FadeOutForMirroringFinished(bool is_mirroring) {
@@ -147,8 +152,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 +190,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