OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/ash/palette_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/palette_delegate_chromeos.h" |
6 | 6 |
7 #include "ash/accelerators/accelerator_controller_delegate_aura.h" | 7 #include "ash/accelerators/accelerator_controller_delegate_aura.h" |
| 8 #include "ash/common/system/chromeos/palette/palette_utils.h" |
8 #include "ash/magnifier/partial_magnification_controller.h" | 9 #include "ash/magnifier/partial_magnification_controller.h" |
9 #include "ash/screenshot_delegate.h" | 10 #include "ash/screenshot_delegate.h" |
10 #include "ash/shell.h" | 11 #include "ash/shell.h" |
11 #include "ash/utility/screenshot_controller.h" | 12 #include "ash/utility/screenshot_controller.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
13 #include "chrome/browser/chromeos/note_taking_app_utils.h" | 14 #include "chrome/browser/chromeos/note_taking_app_utils.h" |
14 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 15 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
18 #include "components/prefs/pref_change_registrar.h" | 19 #include "components/prefs/pref_change_registrar.h" |
19 #include "components/prefs/pref_service.h" | 20 #include "components/prefs/pref_service.h" |
20 #include "components/user_manager/user_manager.h" | 21 #include "components/user_manager/user_manager.h" |
21 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
22 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
23 #include "ui/events/devices/input_device_manager.h" | 24 #include "ui/events/devices/input_device_manager.h" |
24 | 25 |
25 namespace chromeos { | 26 namespace chromeos { |
26 | 27 |
| 28 // static |
| 29 std::unique_ptr<PaletteDelegateChromeOS> PaletteDelegateChromeOS::Create() { |
| 30 if (!ash::IsPaletteFeatureEnabled()) |
| 31 return nullptr; |
| 32 return base::WrapUnique(new PaletteDelegateChromeOS()); |
| 33 } |
| 34 |
27 PaletteDelegateChromeOS::PaletteDelegateChromeOS() { | 35 PaletteDelegateChromeOS::PaletteDelegateChromeOS() { |
28 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED, | 36 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED, |
29 content::NotificationService::AllSources()); | 37 content::NotificationService::AllSources()); |
30 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 38 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
31 content::NotificationService::AllSources()); | 39 content::NotificationService::AllSources()); |
32 | 40 |
33 ui::InputDeviceManager::GetInstance()->AddObserver(this); | 41 ui::InputDeviceManager::GetInstance()->AddObserver(this); |
34 } | 42 } |
35 | 43 |
36 PaletteDelegateChromeOS::~PaletteDelegateChromeOS() { | 44 PaletteDelegateChromeOS::~PaletteDelegateChromeOS() { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 on_stylus_state_changed_ = on_stylus_state_changed; | 135 on_stylus_state_changed_ = on_stylus_state_changed; |
128 } | 136 } |
129 | 137 |
130 bool PaletteDelegateChromeOS::ShouldAutoOpenPalette() { | 138 bool PaletteDelegateChromeOS::ShouldAutoOpenPalette() { |
131 if (!profile_) | 139 if (!profile_) |
132 return false; | 140 return false; |
133 | 141 |
134 return profile_->GetPrefs()->GetBoolean(prefs::kLaunchPaletteOnEjectEvent); | 142 return profile_->GetPrefs()->GetBoolean(prefs::kLaunchPaletteOnEjectEvent); |
135 } | 143 } |
136 | 144 |
| 145 bool PaletteDelegateChromeOS::ShouldShowPalette() { |
| 146 if (!profile_) |
| 147 return false; |
| 148 |
| 149 return profile_->GetPrefs()->GetBoolean(prefs::kEnableStylusTools); |
| 150 } |
| 151 |
137 void PaletteDelegateChromeOS::TakeScreenshot() { | 152 void PaletteDelegateChromeOS::TakeScreenshot() { |
138 auto* screenshot_delegate = ash::Shell::GetInstance() | 153 auto* screenshot_delegate = ash::Shell::GetInstance() |
139 ->accelerator_controller_delegate() | 154 ->accelerator_controller_delegate() |
140 ->screenshot_delegate(); | 155 ->screenshot_delegate(); |
141 screenshot_delegate->HandleTakeScreenshotForAllRootWindows(); | 156 screenshot_delegate->HandleTakeScreenshotForAllRootWindows(); |
142 } | 157 } |
143 | 158 |
144 void PaletteDelegateChromeOS::TakePartialScreenshot() { | 159 void PaletteDelegateChromeOS::TakePartialScreenshot() { |
145 auto* screenshot_controller = | 160 auto* screenshot_controller = |
146 ash::Shell::GetInstance()->screenshot_controller(); | 161 ash::Shell::GetInstance()->screenshot_controller(); |
147 auto* screenshot_delegate = ash::Shell::GetInstance() | 162 auto* screenshot_delegate = ash::Shell::GetInstance() |
148 ->accelerator_controller_delegate() | 163 ->accelerator_controller_delegate() |
149 ->screenshot_delegate(); | 164 ->screenshot_delegate(); |
150 | 165 |
151 screenshot_controller->set_pen_events_only(true); | 166 screenshot_controller->set_pen_events_only(true); |
152 screenshot_controller->StartPartialScreenshotSession( | 167 screenshot_controller->StartPartialScreenshotSession( |
153 screenshot_delegate, false /* draw_overlay_immediately */); | 168 screenshot_delegate, false /* draw_overlay_immediately */); |
154 } | 169 } |
155 | 170 |
156 void PaletteDelegateChromeOS::OnStylusStateChanged(ui::StylusState state) { | 171 void PaletteDelegateChromeOS::OnStylusStateChanged(ui::StylusState state) { |
157 on_stylus_state_changed_.Run(state); | 172 on_stylus_state_changed_.Run(state); |
158 } | 173 } |
159 | 174 |
160 } // namespace chromeos | 175 } // namespace chromeos |
OLD | NEW |