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

Unified Diff: ash/common/system/chromeos/palette/tools/create_note_action.cc

Issue 2235063002: Add create note palette action. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@app-runtime-changes
Patch Set: Pull MockPaletteToolDelegate into a separate file 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/tools/create_note_action.cc
diff --git a/ash/common/system/chromeos/palette/tools/create_note_action.cc b/ash/common/system/chromeos/palette/tools/create_note_action.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c88d486eed6c69cd3f26c0f785b1d4af8767f99f
--- /dev/null
+++ b/ash/common/system/chromeos/palette/tools/create_note_action.cc
@@ -0,0 +1,56 @@
+// Copyright 2016 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/common/system/chromeos/palette/tools/create_note_action.h"
+
+#include "ash/common/palette_delegate.h"
+#include "ash/common/system/chromeos/palette/palette_ids.h"
+#include "ash/common/wm_shell.h"
+#include "grit/ash_strings.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace ash {
+namespace {
+
+bool IsNoteAppAvailable() {
Evan Stade 2016/08/22 15:12:21 why not just inline this in the one place it's use
jdufault 2016/08/22 16:29:20 Done.
+ return WmShell::Get()->palette_delegate()->HasNoteApp();
+}
+
+} // namespace
+
+CreateNoteAction::CreateNoteAction(Delegate* delegate)
+ : CommonPaletteTool(delegate) {}
+
+CreateNoteAction::~CreateNoteAction() {}
+
+PaletteGroup CreateNoteAction::GetGroup() const {
+ return PaletteGroup::ACTION;
+}
+
+PaletteToolId CreateNoteAction::GetToolId() const {
+ return PaletteToolId::CREATE_NOTE;
+}
+
+void CreateNoteAction::OnEnable() {
+ CommonPaletteTool::OnEnable();
+
+ WmShell::Get()->palette_delegate()->CreateNote();
+
+ delegate()->DisableTool(GetToolId());
+ delegate()->HidePalette();
+}
+
+views::View* CreateNoteAction::CreateView() {
+ if (!IsNoteAppAvailable())
+ return nullptr;
+
+ return CreateDefaultView(
+ l10n_util::GetStringUTF16(IDS_ASH_PALETTE_CREATE_NOTE_ACTION));
+}
+
+gfx::VectorIconId CreateNoteAction::GetPaletteIconId() {
+ return gfx::VectorIconId::PALETTE_ACTION_CREATE_NOTE;
+}
+
+} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698