OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/keyboard_overlay_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "ash/display/display_manager.h" | |
10 #include "ash/shell.h" | 9 #include "ash/shell.h" |
11 #include "base/bind.h" | 10 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 12 #include "base/command_line.h" |
14 #include "base/feature_list.h" | 13 #include "base/feature_list.h" |
15 #include "base/macros.h" | 14 #include "base/macros.h" |
16 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
17 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
18 #include "base/values.h" | 17 #include "base/values.h" |
19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/common/chrome_features.h" | 19 #include "chrome/common/chrome_features.h" |
21 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
22 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
23 #include "chrome/grit/browser_resources.h" | 22 #include "chrome/grit/browser_resources.h" |
24 #include "chrome/grit/chromium_strings.h" | 23 #include "chrome/grit/chromium_strings.h" |
25 #include "chrome/grit/generated_resources.h" | 24 #include "chrome/grit/generated_resources.h" |
26 #include "chromeos/chromeos_switches.h" | 25 #include "chromeos/chromeos_switches.h" |
27 #include "components/prefs/pref_service.h" | 26 #include "components/prefs/pref_service.h" |
28 #include "content/public/browser/page_navigator.h" | 27 #include "content/public/browser/page_navigator.h" |
29 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
30 #include "content/public/browser/web_contents_delegate.h" | 29 #include "content/public/browser/web_contents_delegate.h" |
31 #include "content/public/browser/web_ui.h" | 30 #include "content/public/browser/web_ui.h" |
32 #include "content/public/browser/web_ui_data_source.h" | 31 #include "content/public/browser/web_ui_data_source.h" |
33 #include "content/public/browser/web_ui_message_handler.h" | 32 #include "content/public/browser/web_ui_message_handler.h" |
34 #include "ui/base/ime/chromeos/ime_keyboard.h" | 33 #include "ui/base/ime/chromeos/ime_keyboard.h" |
35 #include "ui/base/ime/chromeos/input_method_manager.h" | 34 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 35 #include "ui/display/manager/display_manager.h" |
36 | 36 |
37 using chromeos::input_method::ModifierKey; | 37 using chromeos::input_method::ModifierKey; |
38 using content::WebUIMessageHandler; | 38 using content::WebUIMessageHandler; |
39 using ui::WebDialogUI; | 39 using ui::WebDialogUI; |
40 | 40 |
41 namespace { | 41 namespace { |
42 | 42 |
43 const char kLearnMoreURL[] = | 43 const char kLearnMoreURL[] = |
44 #if defined(OFFICIAL_BUILD) | 44 #if defined(OFFICIAL_BUILD) |
45 "chrome-extension://honijodknafkokifofgiaalefdiedpko/" | 45 "chrome-extension://honijodknafkokifofgiaalefdiedpko/" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } | 299 } |
300 | 300 |
301 source->AddString("keyboardOverlayLearnMoreURL", | 301 source->AddString("keyboardOverlayLearnMoreURL", |
302 base::UTF8ToUTF16(kLearnMoreURL)); | 302 base::UTF8ToUTF16(kLearnMoreURL)); |
303 source->AddBoolean("keyboardOverlayHasChromeOSDiamondKey", | 303 source->AddBoolean("keyboardOverlayHasChromeOSDiamondKey", |
304 base::CommandLine::ForCurrentProcess()->HasSwitch( | 304 base::CommandLine::ForCurrentProcess()->HasSwitch( |
305 chromeos::switches::kHasChromeOSDiamondKey)); | 305 chromeos::switches::kHasChromeOSDiamondKey)); |
306 source->AddBoolean("keyboardOverlayTopRowKeysAreFunctionKeys", | 306 source->AddBoolean("keyboardOverlayTopRowKeysAreFunctionKeys", |
307 TopRowKeysAreFunctionKeys(profile)); | 307 TopRowKeysAreFunctionKeys(profile)); |
308 ash::Shell* shell = ash::Shell::GetInstance(); | 308 ash::Shell* shell = ash::Shell::GetInstance(); |
309 ash::DisplayManager* display_manager = shell->display_manager(); | 309 display::DisplayManager* display_manager = shell->display_manager(); |
310 source->AddBoolean("keyboardOverlayIsDisplayUIScalingEnabled", | 310 source->AddBoolean("keyboardOverlayIsDisplayUIScalingEnabled", |
311 display_manager->IsDisplayUIScalingEnabled()); | 311 display_manager->IsDisplayUIScalingEnabled()); |
312 source->AddBoolean( | 312 source->AddBoolean( |
313 "backspaceGoesBackFeatureEnabled", | 313 "backspaceGoesBackFeatureEnabled", |
314 base::FeatureList::IsEnabled(features::kBackspaceGoesBackFeature)); | 314 base::FeatureList::IsEnabled(features::kBackspaceGoesBackFeature)); |
315 source->SetJsonPath("strings.js"); | 315 source->SetJsonPath("strings.js"); |
316 source->AddResourcePath("keyboard_overlay.js", IDR_KEYBOARD_OVERLAY_JS); | 316 source->AddResourcePath("keyboard_overlay.js", IDR_KEYBOARD_OVERLAY_JS); |
317 source->SetDefaultResource(IDR_KEYBOARD_OVERLAY_HTML); | 317 source->SetDefaultResource(IDR_KEYBOARD_OVERLAY_HTML); |
318 return source; | 318 return source; |
319 } | 319 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui) | 421 KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui) |
422 : WebDialogUI(web_ui) { | 422 : WebDialogUI(web_ui) { |
423 Profile* profile = Profile::FromWebUI(web_ui); | 423 Profile* profile = Profile::FromWebUI(web_ui); |
424 KeyboardOverlayHandler* handler = new KeyboardOverlayHandler(profile); | 424 KeyboardOverlayHandler* handler = new KeyboardOverlayHandler(profile); |
425 web_ui->AddMessageHandler(handler); | 425 web_ui->AddMessageHandler(handler); |
426 | 426 |
427 // Set up the chrome://keyboardoverlay/ source. | 427 // Set up the chrome://keyboardoverlay/ source. |
428 content::WebUIDataSource::Add(profile, | 428 content::WebUIDataSource::Add(profile, |
429 CreateKeyboardOverlayUIHTMLSource(profile)); | 429 CreateKeyboardOverlayUIHTMLSource(profile)); |
430 } | 430 } |
OLD | NEW |