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

Unified Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc

Issue 11418114: Add policy for ash launcher auto-hide behavior (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed. Created 8 years, 1 month 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/ash/launcher/chrome_launcher_controller.cc
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
index f48a8158ebfe134bc451c7dee7ebe0ab40f81169..66336782c5f435e85ce8c02f1ce3a6a7c86d09c7 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
@@ -126,12 +126,12 @@ std::string GetLocalOrRemotePref(PrefService* pref_service,
return value.empty() ? pref_service->GetString(synced_path) : value;
}
-// If prefs have synced and the pref value at |local_path| is empty the value
+// If prefs have synced and no user-set value exists at |local_path|, the value
// from |synced_path| is copied to |local_path|.
void MaybePropagatePrefToLocal(PrefService* pref_service,
const char* local_path,
const char* synced_path) {
- if (pref_service->GetString(local_path).empty() &&
+ if (!pref_service->FindPreference(local_path)->HasUserSetting() &&
sky 2012/11/29 23:46:06 I'm not familiar with HasUserSetting. How does thi
bartfab (slow) 2012/11/30 11:55:47 A quick bit of context: There are multiple sources
pref_service->IsSyncing()) {
// First time the user is using this machine, propagate from remote to
// local.
@@ -176,6 +176,8 @@ ChromeLauncherController::ChromeLauncherController(Profile* profile,
content::Source<Profile>(profile_));
pref_change_registrar_.Init(profile_->GetPrefs());
pref_change_registrar_.Add(prefs::kPinnedLauncherApps, this);
+ pref_change_registrar_.Add(prefs::kShelfAlignmentLocal, this);
+ pref_change_registrar_.Add(prefs::kShelfAutoHideBehaviorLocal, this);
}
ChromeLauncherController::~ChromeLauncherController() {
@@ -557,28 +559,39 @@ bool ChromeLauncherController::CanPin() const {
return pref && pref->IsUserModifiable();
}
-void ChromeLauncherController::SetAutoHideBehavior(
- ash::ShelfAutoHideBehavior behavior,
- aura::RootWindow* root_window) {
- ash::Shell::GetInstance()->SetShelfAutoHideBehavior(
- behavior,
- root_window);
- // TODO(oshima): Support multiple launcher.
- if (root_window != ash::Shell::GetPrimaryRootWindow())
- return;
+ash::ShelfAutoHideBehavior ChromeLauncherController::GetShelfAutoHideBehavior(
+ aura::RootWindow* root_window) const {
+ // TODO(oshima): Support multiple launchers.
- const char* value = NULL;
- switch (behavior) {
- case ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS:
- value = ash::kShelfAutoHideBehaviorAlways;
- break;
- case ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER:
- value = ash::kShelfAutoHideBehaviorNever;
- break;
- }
- // See comment in |kShelfAlignment| about why we have two prefs here.
- profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehaviorLocal, value);
- profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehavior, value);
+ // See comment in |kShelfAlignment| as to why we consider two prefs.
+ const std::string behavior_value(
+ GetLocalOrRemotePref(profile_->GetPrefs(),
+ prefs::kShelfAutoHideBehaviorLocal,
+ prefs::kShelfAutoHideBehavior));
+
+ // Note: To maintain sync compatibility with old images of chrome/chromeos
+ // the set of values that may be encountered includes the now-extinct
+ // "Default" as well as "Never" and "Always", "Default" should now
+ // be treated as "Never" (http://crbug.com/146773).
+ if (behavior_value == ash::kShelfAutoHideBehaviorAlways)
+ return ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
+ return ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER;
+}
+
+bool ChromeLauncherController::CanUserModifyShelfAutoHideBehavior(
+ aura::RootWindow* root_window) const {
+ // TODO(oshima): Support multiple launchers.
+ return profile_->GetPrefs()->
+ FindPreference(prefs::kShelfAutoHideBehaviorLocal)->IsUserModifiable();
+}
+
+void ChromeLauncherController::ToggleShelfAutoHideBehavior(
+ aura::RootWindow* root_window) {
+ ash::ShelfAutoHideBehavior behavior = GetShelfAutoHideBehavior(root_window) ==
+ ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ?
+ ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER :
+ ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
+ SetShelfAutoHideBehaviorPrefs(behavior, root_window);
}
void ChromeLauncherController::RemoveTabFromRunningApp(
@@ -979,25 +992,32 @@ void ChromeLauncherController::UpdateAppLaunchersFromPref() {
DoPinAppWithID(*pref_app_id);
}
-void ChromeLauncherController::SetShelfAutoHideBehaviorFromPrefs() {
- // See comment in |kShelfAlignment| as to why we consider two prefs.
- const std::string behavior_value(
- GetLocalOrRemotePref(profile_->GetPrefs(),
- prefs::kShelfAutoHideBehaviorLocal,
- prefs::kShelfAutoHideBehavior));
+void ChromeLauncherController::SetShelfAutoHideBehaviorPrefs(
+ ash::ShelfAutoHideBehavior behavior,
+ aura::RootWindow* root_window) {
+ // TODO(oshima): Support multiple launchers.
+ if (root_window != ash::Shell::GetPrimaryRootWindow())
+ return;
- // Note: To maintain sync compatibility with old images of chrome/chromeos
- // the set of values that may be encountered includes the now-extinct
- // "Default" as well as "Never" and "Always", "Default" should now
- // be treated as "Never".
- // (http://code.google.com/p/chromium/issues/detail?id=146773)
- ash::ShelfAutoHideBehavior behavior =
- ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER;
- if (behavior_value == ash::kShelfAutoHideBehaviorAlways)
- behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
+ const char* value = NULL;
+ switch (behavior) {
+ case ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS:
+ value = ash::kShelfAutoHideBehaviorAlways;
+ break;
+ case ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER:
+ value = ash::kShelfAutoHideBehaviorNever;
+ break;
+ }
+ // See comment in |kShelfAlignment| about why we have two prefs here.
+ profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehaviorLocal, value);
+ profile_->GetPrefs()->SetString(prefs::kShelfAutoHideBehavior, value);
+}
+
+void ChromeLauncherController::SetShelfAutoHideBehaviorFromPrefs() {
// TODO(oshima): Support multiple displays.
+ aura::RootWindow* root_window = ash::Shell::GetPrimaryRootWindow();
ash::Shell::GetInstance()->SetShelfAutoHideBehavior(
- behavior, ash::Shell::GetPrimaryRootWindow());
+ GetShelfAutoHideBehavior(root_window), root_window);
}
void ChromeLauncherController::SetShelfAlignmentFromPrefs() {
« no previous file with comments | « chrome/browser/ui/ash/launcher/chrome_launcher_controller.h ('k') | chrome/browser/ui/ash/launcher/launcher_context_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698