Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: chrome/browser/ui/ash/palette_delegate_chromeos.cc

Issue 2234203002: Auto open and close the palette on an eject event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tool-note
Patch Set: Use weak ptr Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/ash/palette_delegate_chromeos.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
16 #include "ui/events/devices/input_device_manager.h"
14 17
15 namespace chromeos { 18 namespace chromeos {
16 namespace { 19 namespace {
17 20
18 Profile* GetProfile() { 21 Profile* GetProfile() {
19 return ProfileManager::GetActiveUserProfile(); 22 return ProfileManager::GetActiveUserProfile();
20 } 23 }
21 24
22 } // namespace 25 } // namespace
23 26
24 PaletteDelegateChromeOS::PaletteDelegateChromeOS() {} 27 PaletteDelegateChromeOS::PaletteDelegateChromeOS() {
28 ui::InputDeviceManager::GetInstance()->AddObserver(this);
29 }
25 30
26 PaletteDelegateChromeOS::~PaletteDelegateChromeOS() {} 31 PaletteDelegateChromeOS::~PaletteDelegateChromeOS() {
32 ui::InputDeviceManager::GetInstance()->RemoveObserver(this);
33 }
27 34
28 void PaletteDelegateChromeOS::CreateNote() { 35 void PaletteDelegateChromeOS::CreateNote() {
29 chromeos::LaunchNoteTakingAppForNewNote(GetProfile(), base::FilePath()); 36 chromeos::LaunchNoteTakingAppForNewNote(GetProfile(), base::FilePath());
30 } 37 }
31 38
32 bool PaletteDelegateChromeOS::HasNoteApp() { 39 bool PaletteDelegateChromeOS::HasNoteApp() {
33 return chromeos::IsNoteTakingAppAvailable(GetProfile()); 40 return chromeos::IsNoteTakingAppAvailable(GetProfile());
34 } 41 }
35 42
36 void PaletteDelegateChromeOS::SetPartialMagnifierState(bool enabled) { 43 void PaletteDelegateChromeOS::SetPartialMagnifierState(bool enabled) {
37 ash::PartialMagnificationController* controller = 44 ash::PartialMagnificationController* controller =
38 ash::Shell::GetInstance()->partial_magnification_controller(); 45 ash::Shell::GetInstance()->partial_magnification_controller();
39 controller->SetEnabled(enabled); 46 controller->SetEnabled(enabled);
40 } 47 }
41 48
49 void PaletteDelegateChromeOS::SetStylusStateChangedCallback(
50 const OnStylusStateChangedCallback& on_stylus_state_changed) {
51 on_stylus_state_changed_ = on_stylus_state_changed;
52 }
53
54 bool PaletteDelegateChromeOS::ShouldAutoOpenPalette() {
55 return GetProfile()->GetPrefs()->GetBoolean(
56 prefs::kLaunchPaletteOnEjectEvent);
57 }
58
42 void PaletteDelegateChromeOS::TakeScreenshot() { 59 void PaletteDelegateChromeOS::TakeScreenshot() {
43 auto* screenshot_delegate = ash::Shell::GetInstance() 60 auto* screenshot_delegate = ash::Shell::GetInstance()
44 ->accelerator_controller_delegate() 61 ->accelerator_controller_delegate()
45 ->screenshot_delegate(); 62 ->screenshot_delegate();
46 screenshot_delegate->HandleTakeScreenshotForAllRootWindows(); 63 screenshot_delegate->HandleTakeScreenshotForAllRootWindows();
47 } 64 }
48 65
49 void PaletteDelegateChromeOS::TakePartialScreenshot() { 66 void PaletteDelegateChromeOS::TakePartialScreenshot() {
50 auto* screenshot_controller = 67 auto* screenshot_controller =
51 ash::Shell::GetInstance()->screenshot_controller(); 68 ash::Shell::GetInstance()->screenshot_controller();
52 auto* screenshot_delegate = ash::Shell::GetInstance() 69 auto* screenshot_delegate = ash::Shell::GetInstance()
53 ->accelerator_controller_delegate() 70 ->accelerator_controller_delegate()
54 ->screenshot_delegate(); 71 ->screenshot_delegate();
55 72
56 screenshot_controller->set_pen_events_only(true); 73 screenshot_controller->set_pen_events_only(true);
57 screenshot_controller->StartPartialScreenshotSession( 74 screenshot_controller->StartPartialScreenshotSession(
58 screenshot_delegate, false /* draw_overlay_immediately */); 75 screenshot_delegate, false /* draw_overlay_immediately */);
59 } 76 }
60 77
78 void PaletteDelegateChromeOS::OnStylusStateChanged(ui::StylusState state) {
79 on_stylus_state_changed_.Run(state);
80 }
81
61 } // namespace chromeos 82 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/palette_delegate_chromeos.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698