OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/system/palette/tools/metalayer_mode.h" |
| 6 |
| 7 #include "ash/palette_delegate.h" |
| 8 #include "ash/resources/vector_icons/vector_icons.h" |
| 9 #include "ash/shell.h" |
| 10 #include "ash/strings/grit/ash_strings.h" |
| 11 #include "ash/system/palette/palette_ids.h" |
| 12 #include "ui/base/l10n/l10n_util.h" |
| 13 |
| 14 namespace ash { |
| 15 |
| 16 MetalayerMode::MetalayerMode(Delegate* delegate) |
| 17 : CommonPaletteTool(delegate), weak_factory_(this) {} |
| 18 |
| 19 MetalayerMode::~MetalayerMode() {} |
| 20 |
| 21 PaletteGroup MetalayerMode::GetGroup() const { |
| 22 return PaletteGroup::MODE; |
| 23 } |
| 24 |
| 25 PaletteToolId MetalayerMode::GetToolId() const { |
| 26 return PaletteToolId::METALAYER; |
| 27 } |
| 28 |
| 29 void MetalayerMode::OnEnable() { |
| 30 CommonPaletteTool::OnEnable(); |
| 31 |
| 32 Shell::Get()->palette_delegate()->ShowMetalayer( |
| 33 base::Bind(&MetalayerMode::OnMetalayerDone, weak_factory_.GetWeakPtr())); |
| 34 delegate()->HidePalette(); |
| 35 } |
| 36 |
| 37 void MetalayerMode::OnDisable() { |
| 38 CommonPaletteTool::OnDisable(); |
| 39 |
| 40 Shell::Get()->palette_delegate()->HideMetalayer(); |
| 41 } |
| 42 |
| 43 const gfx::VectorIcon& MetalayerMode::GetActiveTrayIcon() const { |
| 44 // TODO(kaznacheev) replace with the correct icon when it is available |
| 45 return kPaletteTrayIconCaptureRegionIcon; |
| 46 } |
| 47 |
| 48 const gfx::VectorIcon& MetalayerMode::GetPaletteIcon() const { |
| 49 // TODO(kaznacheev) replace with the correct icon when it is available |
| 50 return kPaletteActionCaptureRegionIcon; |
| 51 } |
| 52 |
| 53 views::View* MetalayerMode::CreateView() { |
| 54 if (!Shell::Get()->palette_delegate()->IsMetalayerSupported()) |
| 55 return nullptr; |
| 56 |
| 57 return CreateDefaultView( |
| 58 l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_METALAYER_MODE)); |
| 59 } |
| 60 |
| 61 void MetalayerMode::OnMetalayerDone() { |
| 62 delegate()->DisableTool(GetToolId()); |
| 63 } |
| 64 |
| 65 } // namespace ash |
OLD | NEW |