| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } | 301 } |
| 302 | 302 |
| 303 source->AddString("keyboardOverlayLearnMoreURL", | 303 source->AddString("keyboardOverlayLearnMoreURL", |
| 304 base::UTF8ToUTF16(kLearnMoreURL)); | 304 base::UTF8ToUTF16(kLearnMoreURL)); |
| 305 source->AddBoolean("keyboardOverlayHasChromeOSDiamondKey", | 305 source->AddBoolean("keyboardOverlayHasChromeOSDiamondKey", |
| 306 base::CommandLine::ForCurrentProcess()->HasSwitch( | 306 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 307 chromeos::switches::kHasChromeOSDiamondKey)); | 307 chromeos::switches::kHasChromeOSDiamondKey)); |
| 308 source->AddBoolean("keyboardOverlayTopRowKeysAreFunctionKeys", | 308 source->AddBoolean("keyboardOverlayTopRowKeysAreFunctionKeys", |
| 309 TopRowKeysAreFunctionKeys(profile)); | 309 TopRowKeysAreFunctionKeys(profile)); |
| 310 ash::Shell* shell = ash::Shell::GetInstance(); | 310 ash::Shell* shell = ash::Shell::GetInstance(); |
| 311 ash::DisplayManager* display_manager = shell->display_manager(); | 311 display::DisplayManager* display_manager = shell->display_manager(); |
| 312 source->AddBoolean("keyboardOverlayIsDisplayUIScalingEnabled", | 312 source->AddBoolean("keyboardOverlayIsDisplayUIScalingEnabled", |
| 313 display_manager->IsDisplayUIScalingEnabled()); | 313 display_manager->IsDisplayUIScalingEnabled()); |
| 314 source->AddBoolean( | 314 source->AddBoolean( |
| 315 "backspaceGoesBackFeatureEnabled", | 315 "backspaceGoesBackFeatureEnabled", |
| 316 base::FeatureList::IsEnabled(features::kBackspaceGoesBackFeature)); | 316 base::FeatureList::IsEnabled(features::kBackspaceGoesBackFeature)); |
| 317 source->SetJsonPath("strings.js"); | 317 source->SetJsonPath("strings.js"); |
| 318 source->AddResourcePath("keyboard_overlay.js", IDR_KEYBOARD_OVERLAY_JS); | 318 source->AddResourcePath("keyboard_overlay.js", IDR_KEYBOARD_OVERLAY_JS); |
| 319 source->SetDefaultResource(IDR_KEYBOARD_OVERLAY_HTML); | 319 source->SetDefaultResource(IDR_KEYBOARD_OVERLAY_HTML); |
| 320 return source; | 320 return source; |
| 321 } | 321 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui) | 423 KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui) |
| 424 : WebDialogUI(web_ui) { | 424 : WebDialogUI(web_ui) { |
| 425 Profile* profile = Profile::FromWebUI(web_ui); | 425 Profile* profile = Profile::FromWebUI(web_ui); |
| 426 KeyboardOverlayHandler* handler = new KeyboardOverlayHandler(profile); | 426 KeyboardOverlayHandler* handler = new KeyboardOverlayHandler(profile); |
| 427 web_ui->AddMessageHandler(handler); | 427 web_ui->AddMessageHandler(handler); |
| 428 | 428 |
| 429 // Set up the chrome://keyboardoverlay/ source. | 429 // Set up the chrome://keyboardoverlay/ source. |
| 430 content::WebUIDataSource::Add(profile, | 430 content::WebUIDataSource::Add(profile, |
| 431 CreateKeyboardOverlayUIHTMLSource(profile)); | 431 CreateKeyboardOverlayUIHTMLSource(profile)); |
| 432 } | 432 } |
| OLD | NEW |