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

Unified Diff: ash/system/palette/tools/metalayer_mode.cc

Issue 2824703006: Add MetalayerMode to the palette. (Closed)
Patch Set: Fixed copyright year Created 3 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
« no previous file with comments | « ash/system/palette/tools/metalayer_mode.h ('k') | ash/test/test_palette_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/palette/tools/metalayer_mode.cc
diff --git a/ash/system/palette/tools/metalayer_mode.cc b/ash/system/palette/tools/metalayer_mode.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ff3a8a7d99c6a446bcd4a4762a34d9e53c29d634
--- /dev/null
+++ b/ash/system/palette/tools/metalayer_mode.cc
@@ -0,0 +1,65 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/system/palette/tools/metalayer_mode.h"
+
+#include "ash/palette_delegate.h"
+#include "ash/resources/vector_icons/vector_icons.h"
+#include "ash/shell.h"
+#include "ash/strings/grit/ash_strings.h"
+#include "ash/system/palette/palette_ids.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace ash {
+
+MetalayerMode::MetalayerMode(Delegate* delegate)
+ : CommonPaletteTool(delegate), weak_factory_(this) {}
+
+MetalayerMode::~MetalayerMode() {}
+
+PaletteGroup MetalayerMode::GetGroup() const {
+ return PaletteGroup::MODE;
+}
+
+PaletteToolId MetalayerMode::GetToolId() const {
+ return PaletteToolId::METALAYER;
+}
+
+void MetalayerMode::OnEnable() {
+ CommonPaletteTool::OnEnable();
+
+ Shell::Get()->palette_delegate()->ShowMetalayer(
+ base::Bind(&MetalayerMode::OnMetalayerDone, weak_factory_.GetWeakPtr()));
+ delegate()->HidePalette();
+}
+
+void MetalayerMode::OnDisable() {
+ CommonPaletteTool::OnDisable();
+
+ Shell::Get()->palette_delegate()->HideMetalayer();
+}
+
+const gfx::VectorIcon& MetalayerMode::GetActiveTrayIcon() const {
+ // TODO(kaznacheev) replace with the correct icon when it is available
+ return kPaletteTrayIconCaptureRegionIcon;
+}
+
+const gfx::VectorIcon& MetalayerMode::GetPaletteIcon() const {
+ // TODO(kaznacheev) replace with the correct icon when it is available
+ return kPaletteActionCaptureRegionIcon;
+}
+
+views::View* MetalayerMode::CreateView() {
+ if (!Shell::Get()->palette_delegate()->IsMetalayerSupported())
+ return nullptr;
+
+ return CreateDefaultView(
+ l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_METALAYER_MODE));
+}
+
+void MetalayerMode::OnMetalayerDone() {
+ delegate()->DisableTool(GetToolId());
+}
+
+} // namespace ash
« no previous file with comments | « ash/system/palette/tools/metalayer_mode.h ('k') | ash/test/test_palette_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698