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

Side by Side Diff: chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.cc

Issue 1961133004: MD Settings: Add remaining buttons to keyboard subpage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: closure Created 4 years, 7 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
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/webui/settings/chromeos/device_keyboard_handler.h" 5 #include "chrome/browser/ui/webui/settings/chromeos/device_keyboard_handler.h"
6 6
7 #include "ash/new_window_delegate.h"
8 #include "ash/shell.h"
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/command_line.h" 10 #include "base/command_line.h"
9 #include "base/values.h" 11 #include "base/values.h"
10 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
11 #include "chromeos/chromeos_switches.h" 13 #include "chromeos/chromeos_switches.h"
12 #include "content/public/browser/web_ui.h" 14 #include "content/public/browser/web_ui.h"
13 #include "ui/events/devices/device_data_manager.h" 15 #include "ui/events/devices/device_data_manager.h"
14 #include "ui/events/devices/keyboard_device.h" 16 #include "ui/events/devices/keyboard_device.h"
15 17
16 namespace { 18 namespace {
(...skipping 20 matching lines...) Expand all
37 39
38 KeyboardHandler::~KeyboardHandler() { 40 KeyboardHandler::~KeyboardHandler() {
39 ui::DeviceDataManager::GetInstance()->RemoveObserver(this); 41 ui::DeviceDataManager::GetInstance()->RemoveObserver(this);
40 } 42 }
41 43
42 void KeyboardHandler::RegisterMessages() { 44 void KeyboardHandler::RegisterMessages() {
43 web_ui()->RegisterMessageCallback( 45 web_ui()->RegisterMessageCallback(
44 "initializeKeyboardSettings", 46 "initializeKeyboardSettings",
45 base::Bind(&KeyboardHandler::HandleInitialize, 47 base::Bind(&KeyboardHandler::HandleInitialize,
46 base::Unretained(this))); 48 base::Unretained(this)));
49 web_ui()->RegisterMessageCallback(
50 "showKeyboardShortcutsOverlay",
51 base::Bind(&KeyboardHandler::HandleShowKeyboardShortcutsOverlay,
52 base::Unretained(this)));
47 } 53 }
48 54
49 void KeyboardHandler::OnKeyboardDeviceConfigurationChanged() { 55 void KeyboardHandler::OnKeyboardDeviceConfigurationChanged() {
50 UpdateShowKeys(); 56 UpdateShowKeys();
51 } 57 }
52 58
53 void KeyboardHandler::HandleInitialize(const base::ListValue* args) { 59 void KeyboardHandler::HandleInitialize(const base::ListValue* args) {
54 UpdateShowKeys(); 60 UpdateShowKeys();
55 } 61 }
56 62
63 void KeyboardHandler::HandleShowKeyboardShortcutsOverlay(
64 const base::ListValue* args) const {
65 ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay();
66 }
67
57 void KeyboardHandler::UpdateShowKeys() const { 68 void KeyboardHandler::UpdateShowKeys() const {
58 const base::FundamentalValue has_caps_lock(HasExternalKeyboard()); 69 const base::FundamentalValue has_caps_lock(HasExternalKeyboard());
59 const base::FundamentalValue has_diamond_key( 70 const base::FundamentalValue has_diamond_key(
60 base::CommandLine::ForCurrentProcess()->HasSwitch( 71 base::CommandLine::ForCurrentProcess()->HasSwitch(
61 chromeos::switches::kHasChromeOSDiamondKey)); 72 chromeos::switches::kHasChromeOSDiamondKey));
62 web_ui()->CallJavascriptFunction("cr.webUIListenerCallback", 73 web_ui()->CallJavascriptFunction("cr.webUIListenerCallback",
63 base::StringValue("show-keys-changed"), 74 base::StringValue("show-keys-changed"),
64 has_caps_lock, 75 has_caps_lock,
65 has_diamond_key); 76 has_diamond_key);
66 } 77 }
67 78
68 } // namespace settings 79 } // namespace settings
69 } // namespace chromeos 80 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698