OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_ASH_PALETTE_DELEGATE_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_PALETTE_DELEGATE_CHROMEOS_H_ |
6 #define CHROME_BROWSER_UI_ASH_PALETTE_DELEGATE_CHROMEOS_H_ | 6 #define CHROME_BROWSER_UI_ASH_PALETTE_DELEGATE_CHROMEOS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ash/common/palette_delegate.h" | 10 #include "ash/common/palette_delegate.h" |
11 #include "ash/common/session/session_state_observer.h" | 11 #include "ash/common/session/session_state_observer.h" |
12 #include "base/callback_list.h" | 12 #include "base/callback_list.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
18 #include "ui/events/devices/input_device_event_observer.h" | |
19 | 18 |
20 class PrefChangeRegistrar; | 19 class PrefChangeRegistrar; |
21 class Profile; | 20 class Profile; |
22 | 21 |
23 namespace ash { | 22 namespace ash { |
24 class ScopedSessionStateObserver; | 23 class ScopedSessionStateObserver; |
25 } | 24 } |
26 | 25 |
27 namespace chromeos { | 26 namespace chromeos { |
28 | 27 |
29 // A class which allows the Ash palette to perform chrome actions. | 28 // A class which allows the Ash palette to perform chrome actions. |
30 class PaletteDelegateChromeOS : public ash::PaletteDelegate, | 29 class PaletteDelegateChromeOS : public ash::PaletteDelegate, |
31 public ui::InputDeviceEventObserver, | |
32 public ash::SessionStateObserver, | 30 public ash::SessionStateObserver, |
33 public content::NotificationObserver { | 31 public content::NotificationObserver { |
34 public: | 32 public: |
35 // Attempts to create a palette delegate. This will return null if the palette | 33 PaletteDelegateChromeOS(); |
36 // feature is not enabled. | |
37 static std::unique_ptr<PaletteDelegateChromeOS> Create(); | |
38 | |
39 ~PaletteDelegateChromeOS() override; | 34 ~PaletteDelegateChromeOS() override; |
40 | 35 |
41 private: | 36 private: |
42 PaletteDelegateChromeOS(); | |
43 | |
44 // ash::PaletteDelegate: | 37 // ash::PaletteDelegate: |
45 std::unique_ptr<EnableListenerSubscription> AddPaletteEnableListener( | 38 std::unique_ptr<EnableListenerSubscription> AddPaletteEnableListener( |
46 const EnableListener& on_state_changed) override; | 39 const EnableListener& on_state_changed) override; |
47 void CreateNote() override; | 40 void CreateNote() override; |
48 bool HasNoteApp() override; | 41 bool HasNoteApp() override; |
49 void SetPartialMagnifierState(bool enabled) override; | 42 void SetPartialMagnifierState(bool enabled) override; |
50 void SetStylusStateChangedCallback( | |
51 const OnStylusStateChangedCallback& on_stylus_state_changed) override; | |
52 bool ShouldAutoOpenPalette() override; | 43 bool ShouldAutoOpenPalette() override; |
53 bool ShouldShowPalette() override; | 44 bool ShouldShowPalette() override; |
54 void TakeScreenshot() override; | 45 void TakeScreenshot() override; |
55 void TakePartialScreenshot(const base::Closure& done) override; | 46 void TakePartialScreenshot(const base::Closure& done) override; |
56 void CancelPartialScreenshot() override; | 47 void CancelPartialScreenshot() override; |
57 | 48 |
58 // ash::SessionStateObserver: | 49 // ash::SessionStateObserver: |
59 void ActiveUserChanged(const AccountId& account_id) override; | 50 void ActiveUserChanged(const AccountId& account_id) override; |
60 | 51 |
61 // content::NotificationObserver: | 52 // content::NotificationObserver: |
62 void Observe(int type, | 53 void Observe(int type, |
63 const content::NotificationSource& source, | 54 const content::NotificationSource& source, |
64 const content::NotificationDetails& details) override; | 55 const content::NotificationDetails& details) override; |
65 | 56 |
66 // ui::InputDeviceObserver: | |
67 void OnStylusStateChanged(ui::StylusState state) override; | |
68 | |
69 // Called when the palette enabled pref has changed. | 57 // Called when the palette enabled pref has changed. |
70 void OnPaletteEnabledPrefChanged(); | 58 void OnPaletteEnabledPrefChanged(); |
71 | 59 |
72 void SetProfile(Profile* profile); | 60 void SetProfile(Profile* profile); |
73 void OnPartialScreenshotDone(const base::Closure& then); | 61 void OnPartialScreenshotDone(const base::Closure& then); |
74 | 62 |
75 base::CallbackList<void(bool)> palette_enabled_callback_list_; | 63 base::CallbackList<void(bool)> palette_enabled_callback_list_; |
76 OnStylusStateChangedCallback on_stylus_state_changed_; | |
77 | 64 |
78 // Unowned pointer to the active profile. | 65 // Unowned pointer to the active profile. |
79 Profile* profile_ = nullptr; | 66 Profile* profile_ = nullptr; |
80 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; | 67 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; |
81 std::unique_ptr<ash::ScopedSessionStateObserver> session_state_observer_; | 68 std::unique_ptr<ash::ScopedSessionStateObserver> session_state_observer_; |
82 content::NotificationRegistrar registrar_; | 69 content::NotificationRegistrar registrar_; |
83 | 70 |
84 base::WeakPtrFactory<PaletteDelegateChromeOS> weak_factory_; | 71 base::WeakPtrFactory<PaletteDelegateChromeOS> weak_factory_; |
85 | 72 |
86 DISALLOW_COPY_AND_ASSIGN(PaletteDelegateChromeOS); | 73 DISALLOW_COPY_AND_ASSIGN(PaletteDelegateChromeOS); |
87 }; | 74 }; |
88 | 75 |
89 } // namespace chromeos | 76 } // namespace chromeos |
90 | 77 |
91 #endif // CHROME_BROWSER_UI_ASH_PALETTE_DELEGATE_CHROMEOS_H_ | 78 #endif // CHROME_BROWSER_UI_ASH_PALETTE_DELEGATE_CHROMEOS_H_ |
OLD | NEW |