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

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

Issue 2234203002: Auto open and close the palette on an eject event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tool-note
Patch Set: Initial upload 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 95db0eb52129b14519923333ddcda48946a8de90..b47ed1900bf025112871158848dafd07149bf4af 100644
--- a/ash/common/system/chromeos/palette/palette_tray.cc
+++ b/ash/common/system/chromeos/palette/palette_tray.cc
@@ -4,10 +4,12 @@
#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"
#include "ash/common/shell_window_ids.h"
+#include "ash/common/system/chromeos/palette/eject_controller.h"
#include "ash/common/system/chromeos/palette/palette_tool_manager.h"
#include "ash/common/system/chromeos/palette/palette_utils.h"
#include "ash/common/system/tray/system_tray_delegate.h"
@@ -118,6 +120,9 @@ class TitleView : public views::View, public views::ButtonListener {
PaletteTray::PaletteTray(WmShelf* wm_shelf)
: TrayBackgroundView(wm_shelf),
palette_tool_manager_(new PaletteToolManager(this)) {
+ eject_controller_.reset(new EjectController(
+ base::Bind(&PaletteTray::OnEject, base::Unretained(this))));
+
PaletteTool::RegisterToolInstances(palette_tool_manager_.get());
SetContentsBackground();
@@ -308,6 +313,17 @@ void PaletteTray::UpdateTrayIcon() {
icon_->SetImage(CreateVectorIcon(icon, kShelfIconColor));
}
+void PaletteTray::OnEject(bool eject) {
+ if (!WmShell::Get()->palette_delegate()->ShouldAutoOpenPalette())
+ return;
+
+ if (eject && !bubble_)
+ OpenBubble();
+
+ if (!eject && bubble_)
+ HidePalette();
+}
+
void PaletteTray::UpdateIconVisibility() {
if (!IsPaletteEnabled())
return;

Powered by Google App Engine
This is Rietveld 408576698