Commit 3efa2b5c authored by mukai@chromium.org's avatar mukai@chromium.org

Store secondary display layout to the user's preferences


BUG=137516
TEST=manually checked on lumpy


Review URL: https://chromiumcodereview.appspot.com/10829034

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148724 0039d316-1c4b-4281-b951-d872f2087c98
parent 5e36c180
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "chrome/browser/chromeos/preferences.h" #include "chrome/browser/chromeos/preferences.h"
#include "ash/display/display_controller.h"
#include "ash/shell.h"
#include "base/chromeos/chromeos_version.h" #include "base/chromeos/chromeos_version.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/i18n/time_formatting.h" #include "base/i18n/time_formatting.h"
...@@ -47,6 +49,8 @@ bool IsLumpy() { ...@@ -47,6 +49,8 @@ bool IsLumpy() {
} // namespace } // namespace
using ash::internal::DisplayController;
static const char kFallbackInputMethodLocale[] = "en-US"; static const char kFallbackInputMethodLocale[] = "en-US";
Preferences::Preferences() Preferences::Preferences()
...@@ -242,6 +246,11 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) { ...@@ -242,6 +246,11 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) {
false, false,
PrefService::SYNCABLE_PREF); PrefService::SYNCABLE_PREF);
// Secondary display layout.
prefs->RegisterIntegerPref(prefs::kSecondaryDisplayLayout,
static_cast<int>(DisplayController::RIGHT),
PrefService::UNSYNCABLE_PREF);
// Mobile plan notifications default to on. // Mobile plan notifications default to on.
prefs->RegisterBooleanPref(prefs::kShowPlanNotifications, prefs->RegisterBooleanPref(prefs::kShowPlanNotifications,
true, true,
...@@ -349,6 +358,8 @@ void Preferences::InitUserPrefs(PrefService* prefs) { ...@@ -349,6 +358,8 @@ void Preferences::InitUserPrefs(PrefService* prefs) {
enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, this); enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, this);
secondary_display_layout_.Init(prefs::kSecondaryDisplayLayout, prefs, this);
enable_drm_.Init(prefs::kEnableCrosDRM, prefs, this); enable_drm_.Init(prefs::kEnableCrosDRM, prefs, this);
} }
...@@ -566,6 +577,16 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) { ...@@ -566,6 +577,16 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) {
enable_screen_lock_.GetValue()); enable_screen_lock_.GetValue());
} }
if (!pref_name || *pref_name == prefs::kSecondaryDisplayLayout) {
int layout = secondary_display_layout_.GetValue();
if (static_cast<int>(DisplayController::TOP) <= layout &&
layout <= static_cast<int>(DisplayController::LEFT)) {
ash::Shell::GetInstance()->display_controller()->
SetSecondaryDisplayLayout(
static_cast<DisplayController::SecondaryDisplayLayout>(layout));
}
}
// Init or update protected content (DRM) support. // Init or update protected content (DRM) support.
if (!pref_name || *pref_name == prefs::kEnableCrosDRM) { if (!pref_name || *pref_name == prefs::kEnableCrosDRM) {
system::ToggleDrm(enable_drm_.GetValue()); system::ToggleDrm(enable_drm_.GetValue());
......
...@@ -144,6 +144,8 @@ class Preferences : public content::NotificationObserver { ...@@ -144,6 +144,8 @@ class Preferences : public content::NotificationObserver {
BooleanPrefMember enable_screen_lock_; BooleanPrefMember enable_screen_lock_;
IntegerPrefMember secondary_display_layout_;
BooleanPrefMember enable_drm_; BooleanPrefMember enable_drm_;
DISALLOW_COPY_AND_ASSIGN(Preferences); DISALLOW_COPY_AND_ASSIGN(Preferences);
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
#include "base/json/json_value_converter.h" #include "base/json/json_value_converter.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "chromeos/display/output_configurator.h" #include "chromeos/display/output_configurator.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
...@@ -116,10 +119,9 @@ void DisplayOptionsHandler::SendDisplayInfo() { ...@@ -116,10 +119,9 @@ void DisplayOptionsHandler::SendDisplayInfo() {
displays.Set(i, js_display); displays.Set(i, js_display);
} }
DisplayController* display_controller = PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
ash::Shell::GetInstance()->display_controller(); base::FundamentalValue layout(
base::FundamentalValue layout(static_cast<int>( pref_service->GetInteger(prefs::kSecondaryDisplayLayout));
display_controller->secondary_display_layout()));
web_ui()->CallJavascriptFunction( web_ui()->CallJavascriptFunction(
"options.DisplayOptions.setDisplayInfo", "options.DisplayOptions.setDisplayInfo",
...@@ -152,8 +154,8 @@ void DisplayOptionsHandler::HandleDisplayLayout(const base::ListValue* args) { ...@@ -152,8 +154,8 @@ void DisplayOptionsHandler::HandleDisplayLayout(const base::ListValue* args) {
DCHECK_LE(DisplayController::TOP, layout); DCHECK_LE(DisplayController::TOP, layout);
DCHECK_GE(DisplayController::LEFT, layout); DCHECK_GE(DisplayController::LEFT, layout);
ash::Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
static_cast<DisplayController::SecondaryDisplayLayout>(layout)); pref_service->SetInteger(prefs::kSecondaryDisplayLayout, layout);
SendDisplayInfo(); SendDisplayInfo();
} }
......
...@@ -723,6 +723,14 @@ const char kOAuth1Secret[] = "settings.account.oauth1_secret"; ...@@ -723,6 +723,14 @@ const char kOAuth1Secret[] = "settings.account.oauth1_secret";
// A boolean pref that enables the (private) pepper GetID() call. // A boolean pref that enables the (private) pepper GetID() call.
const char kEnableCrosDRM[] = "settings.privacy.drm_enabled"; const char kEnableCrosDRM[] = "settings.privacy.drm_enabled";
// An enumeration that specifies the layout of the secondary display.
// 0 - The secondary display is at the top of the primary display.
// 1 - The secondary display is at the right of the primary display.
// 2 - The secondary display is at the bottom of the primary display.
// 3 - The secondary display is at the left of the primary display.
// TODO(mukai,oshima): update the format of the multi-display settings.
const char kSecondaryDisplayLayout[] = "settings.display.secondary_layout";
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
// The disabled messages in IPC logging. // The disabled messages in IPC logging.
......
...@@ -264,6 +264,7 @@ extern const char kUseSharedProxies[]; ...@@ -264,6 +264,7 @@ extern const char kUseSharedProxies[];
extern const char kOAuth1Token[]; extern const char kOAuth1Token[];
extern const char kOAuth1Secret[]; extern const char kOAuth1Secret[];
extern const char kEnableCrosDRM[]; extern const char kEnableCrosDRM[];
extern const char kSecondaryDisplayLayout[];
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
extern const char kIpcDisabledMessages[]; extern const char kIpcDisabledMessages[];
extern const char kShowHomeButton[]; extern const char kShowHomeButton[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment