common_palette_tool.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2016 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. #ifndef ASH_SYSTEM_PALETTE_COMMON_PALETTE_TOOL_H_
  5. #define ASH_SYSTEM_PALETTE_COMMON_PALETTE_TOOL_H_
  6. #include <string>
  7. #include "ash/system/palette/palette_tool.h"
  8. #include "ash/system/tray/view_click_listener.h"
  9. #include "base/time/time.h"
  10. namespace gfx {
  11. struct VectorIcon;
  12. }
  13. namespace ash {
  14. class HoverHighlightView;
  15. // A PaletteTool implementation with a standard view support.
  16. class CommonPaletteTool : public PaletteTool, public ViewClickListener {
  17. protected:
  18. explicit CommonPaletteTool(Delegate* delegate);
  19. CommonPaletteTool(const CommonPaletteTool&) = delete;
  20. CommonPaletteTool& operator=(const CommonPaletteTool&) = delete;
  21. ~CommonPaletteTool() override;
  22. // PaletteTool:
  23. void OnViewDestroyed() override;
  24. void OnEnable() override;
  25. void OnDisable() override;
  26. // ViewClickListener:
  27. void OnViewClicked(views::View* sender) override;
  28. // Returns the icon used in the palette tray on the left-most edge of the
  29. // tool. The icon will be the same as that used in the status area i.e.
  30. // PaletteTool::GetActiveTrayIcon().
  31. // TODO(michelefan): Consider using the same function to return
  32. // icon for palette menu and palette tray at the status area.
  33. virtual const gfx::VectorIcon& GetPaletteIcon() const = 0;
  34. // Creates a default view implementation to be returned by CreateView.
  35. views::View* CreateDefaultView(const std::u16string& name);
  36. HoverHighlightView* highlight_view_ = nullptr;
  37. private:
  38. // start_time_ is initialized when the tool becomes active.
  39. // Used for recording UMA metrics.
  40. base::TimeTicks start_time_;
  41. };
  42. } // namespace ash
  43. #endif // ASH_SYSTEM_PALETTE_COMMON_PALETTE_TOOL_H_