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

Unified Diff: ash/common/system/chromeos/palette/palette_tray.cc

Issue 2258553004: Add pref to enable/disable palette tray. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Rebase Created 4 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: ash/common/system/chromeos/palette/palette_tray.cc
diff --git a/ash/common/system/chromeos/palette/palette_tray.cc b/ash/common/system/chromeos/palette/palette_tray.cc
index 9c7fb8fdcd3d3b2f723ae0b08a0a75c6ddaf6aa9..d205b4b04d4f3e9ebcc5b51c010092a52725f658 100644
--- a/ash/common/system/chromeos/palette/palette_tray.cc
+++ b/ash/common/system/chromeos/palette/palette_tray.cc
@@ -4,7 +4,6 @@
#include "ash/common/system/chromeos/palette/palette_tray.h"
-#include "ash/common/palette_delegate.h"
#include "ash/common/shelf/shelf_constants.h"
#include "ash/common/shelf/wm_shelf.h"
#include "ash/common/shelf/wm_shelf_util.h"
@@ -124,6 +123,9 @@ PaletteTray::PaletteTray(WmShelf* wm_shelf)
: TrayBackgroundView(wm_shelf),
palette_tool_manager_(new PaletteToolManager(this)),
weak_factory_(this) {
+ // PaletteTray should only be instantiated if the palette feature is enabled.
+ DCHECK(IsPaletteFeatureEnabled());
+
PaletteTool::RegisterToolInstances(palette_tool_manager_.get());
SetContentsBackground();
@@ -143,7 +145,12 @@ PaletteTray::PaletteTray(WmShelf* wm_shelf)
weak_factory_.GetWeakPtr()));
}
- UpdateIconVisibility();
+ // OnPaletteEnabledPrefChanged will get called with the initial pref value,
+ // which will take care of showing the palette.
+ palette_enabled_subscription_ =
+ WmShell::Get()->palette_delegate()->AddPaletteEnableListener(
+ base::Bind(&PaletteTray::OnPaletteEnabledPrefChanged,
+ weak_factory_.GetWeakPtr()));
}
PaletteTray::~PaletteTray() {
@@ -333,10 +340,14 @@ void PaletteTray::OnStylusStateChanged(ui::StylusState stylus_state) {
bubble_.reset();
}
-void PaletteTray::UpdateIconVisibility() {
- if (!IsPaletteEnabled())
- return;
+void PaletteTray::OnPaletteEnabledPrefChanged(bool enabled) {
+ if (!enabled)
+ SetVisible(false);
+ else
+ UpdateIconVisibility();
+}
+void PaletteTray::UpdateIconVisibility() {
SessionStateDelegate* session_state_delegate =
WmShell::Get()->GetSessionStateDelegate();
« no previous file with comments | « ash/common/system/chromeos/palette/palette_tray.h ('k') | ash/common/system/chromeos/palette/palette_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698