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

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

Issue 1881263002: Generalize support for per-display shelf prefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. Created 4 years, 8 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/ash/launcher/chrome_mash_shelf_controller.cc
diff --git a/chrome/browser/ui/ash/launcher/chrome_mash_shelf_controller.cc b/chrome/browser/ui/ash/launcher/chrome_mash_shelf_controller.cc
index c3dfa93c90d7266788c990f66881b3fa7f652a01..c4a0e1aba667875d64c8fe0821caa3c6059e6e19 100644
--- a/chrome/browser/ui/ash/launcher/chrome_mash_shelf_controller.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_mash_shelf_controller.cc
@@ -6,13 +6,12 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
-#include "chrome/common/pref_names.h"
#include "chrome/grit/theme_resources.h"
-#include "components/prefs/pref_service.h"
#include "content/public/common/mojo_shell_connection.h"
#include "mojo/shell/public/cpp/connector.h"
#include "skia/public/type_converters.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/screen.h"
class ChromeShelfItemDelegate : public mash::shelf::mojom::ShelfItemDelegate {
public:
@@ -65,17 +64,12 @@ void ChromeMashShelfController::Init() {
// Set shelf alignment and auto-hide behavior from preferences.
Profile* profile = ProfileManager::GetActiveUserProfile();
-
- const std::string& alignment_value =
- profile->GetPrefs()->GetString(prefs::kShelfAlignmentLocal);
+ int64_t display_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id();
shelf_controller_->SetAlignment(static_cast<mash::shelf::mojom::Alignment>(
- ash::AlignmentFromPref(alignment_value)));
-
- const std::string& auto_hide_value =
- profile->GetPrefs()->GetString(prefs::kShelfAutoHideBehaviorLocal);
+ ash::GetShelfAlignmentPref(profile, display_id)));
shelf_controller_->SetAutoHideBehavior(
static_cast<mash::shelf::mojom::AutoHideBehavior>(
- ash::AutoHideBehaviorFromPref(auto_hide_value)));
+ ash::GetShelfAutoHideBehaviorPref(profile, display_id)));
// Create a test shortcut item to a fake application.
mash::shelf::mojom::ShelfItemPtr item(mash::shelf::mojom::ShelfItem::New());
@@ -99,18 +93,15 @@ void ChromeMashShelfController::Init() {
void ChromeMashShelfController::OnAlignmentChanged(
mash::shelf::mojom::Alignment alignment) {
- const char* value =
- ash::AlignmentToPref(static_cast<ash::ShelfAlignment>(alignment));
- Profile* profile = ProfileManager::GetActiveUserProfile();
- profile->GetPrefs()->SetString(prefs::kShelfAlignmentLocal, value);
+ ash::SetShelfAlignmentPref(ProfileManager::GetActiveUserProfile(),
+ gfx::Screen::GetScreen()->GetPrimaryDisplay().id(),
+ static_cast<ash::ShelfAlignment>(alignment));
}
void ChromeMashShelfController::OnAutoHideBehaviorChanged(
mash::shelf::mojom::AutoHideBehavior auto_hide) {
- const char* value = ash::AutoHideBehaviorToPref(
+ ash::SetShelfAutoHideBehaviorPref(
+ ProfileManager::GetActiveUserProfile(),
+ gfx::Screen::GetScreen()->GetPrimaryDisplay().id(),
static_cast<ash::ShelfAutoHideBehavior>(auto_hide));
- if (!value)
- return;
- Profile* profile = ProfileManager::GetActiveUserProfile();
- profile->GetPrefs()->SetString(prefs::kShelfAutoHideBehaviorLocal, value);
}

Powered by Google App Engine
This is Rietveld 408576698