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/magnifier/partial_magnification_controller.h" | 8 #include "ash/magnifier/partial_magnification_controller.h" |
9 #include "ash/screenshot_delegate.h" | 9 #include "ash/screenshot_delegate.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/utility/screenshot_controller.h" | 11 #include "ash/utility/screenshot_controller.h" |
12 #include "chrome/browser/chromeos/note_taking_app_utils.h" | 12 #include "chrome/browser/chromeos/note_taking_app_utils.h" |
13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/common/pref_names.h" |
| 15 #include "components/prefs/pref_service.h" |
14 | 16 |
15 namespace chromeos { | 17 namespace chromeos { |
16 namespace { | 18 namespace { |
17 | 19 |
18 Profile* GetProfile() { | 20 Profile* GetProfile() { |
19 return ProfileManager::GetActiveUserProfile(); | 21 return ProfileManager::GetActiveUserProfile(); |
20 } | 22 } |
21 | 23 |
22 } // namespace | 24 } // namespace |
23 | 25 |
24 PaletteDelegateChromeOS::PaletteDelegateChromeOS() {} | 26 PaletteDelegateChromeOS::PaletteDelegateChromeOS() {} |
25 | 27 |
26 PaletteDelegateChromeOS::~PaletteDelegateChromeOS() {} | 28 PaletteDelegateChromeOS::~PaletteDelegateChromeOS() {} |
27 | 29 |
28 void PaletteDelegateChromeOS::CreateNote() { | 30 void PaletteDelegateChromeOS::CreateNote() { |
29 chromeos::LaunchNoteTakingAppForNewNote(GetProfile(), base::FilePath()); | 31 chromeos::LaunchNoteTakingAppForNewNote(GetProfile(), base::FilePath()); |
30 } | 32 } |
31 | 33 |
32 bool PaletteDelegateChromeOS::HasNoteApp() { | 34 bool PaletteDelegateChromeOS::HasNoteApp() { |
33 return chromeos::IsNoteTakingAppAvailable(GetProfile()); | 35 return chromeos::IsNoteTakingAppAvailable(GetProfile()); |
34 } | 36 } |
35 | 37 |
36 void PaletteDelegateChromeOS::SetPartialMagnifierState(bool enabled) { | 38 void PaletteDelegateChromeOS::SetPartialMagnifierState(bool enabled) { |
37 ash::PartialMagnificationController* controller = | 39 ash::PartialMagnificationController* controller = |
38 ash::Shell::GetInstance()->partial_magnification_controller(); | 40 ash::Shell::GetInstance()->partial_magnification_controller(); |
39 controller->SetEnabled(enabled); | 41 controller->SetEnabled(enabled); |
40 } | 42 } |
41 | 43 |
| 44 bool PaletteDelegateChromeOS::ShouldAutoOpenPalette() { |
| 45 return GetProfile()->GetPrefs()->GetBoolean( |
| 46 prefs::kLaunchPaletteOnEjectEvent); |
| 47 } |
| 48 |
42 void PaletteDelegateChromeOS::TakeScreenshot() { | 49 void PaletteDelegateChromeOS::TakeScreenshot() { |
43 auto* screenshot_delegate = ash::Shell::GetInstance() | 50 auto* screenshot_delegate = ash::Shell::GetInstance() |
44 ->accelerator_controller_delegate() | 51 ->accelerator_controller_delegate() |
45 ->screenshot_delegate(); | 52 ->screenshot_delegate(); |
46 screenshot_delegate->HandleTakeScreenshotForAllRootWindows(); | 53 screenshot_delegate->HandleTakeScreenshotForAllRootWindows(); |
47 } | 54 } |
48 | 55 |
49 void PaletteDelegateChromeOS::TakePartialScreenshot() { | 56 void PaletteDelegateChromeOS::TakePartialScreenshot() { |
50 auto* screenshot_controller = | 57 auto* screenshot_controller = |
51 ash::Shell::GetInstance()->screenshot_controller(); | 58 ash::Shell::GetInstance()->screenshot_controller(); |
52 auto* screenshot_delegate = ash::Shell::GetInstance() | 59 auto* screenshot_delegate = ash::Shell::GetInstance() |
53 ->accelerator_controller_delegate() | 60 ->accelerator_controller_delegate() |
54 ->screenshot_delegate(); | 61 ->screenshot_delegate(); |
55 | 62 |
56 screenshot_controller->set_pen_events_only(true); | 63 screenshot_controller->set_pen_events_only(true); |
57 screenshot_controller->StartPartialScreenshotSession( | 64 screenshot_controller->StartPartialScreenshotSession( |
58 screenshot_delegate, false /* draw_overlay_immediately */); | 65 screenshot_delegate, false /* draw_overlay_immediately */); |
59 } | 66 } |
60 | 67 |
61 } // namespace chromeos | 68 } // namespace chromeos |
OLD | NEW |