| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/api/virtual_keyboard_private/chrome_virtual_
keyboard_delegate.h" | 5 #include "chrome/browser/extensions/api/virtual_keyboard_private/chrome_virtual_
keyboard_delegate.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/metrics/user_metrics_action.h" | 11 #include "base/metrics/user_metrics_action.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 13 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 14 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 14 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/browser/ui/chrome_pages.h" | 16 #include "chrome/browser/ui/chrome_pages.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "components/user_manager/user_manager.h" | 18 #include "components/user_manager/user_manager.h" |
| 19 #include "content/public/browser/user_metrics.h" | 19 #include "content/public/browser/user_metrics.h" |
| 20 #include "extensions/common/api/virtual_keyboard_private.h" | 20 #include "extensions/common/api/virtual_keyboard_private.h" |
| 21 #include "ui/aura/window_tree_host.h" | 21 #include "ui/aura/window_tree_host.h" |
| 22 #include "ui/keyboard/keyboard_controller.h" | 22 #include "ui/keyboard/keyboard_controller.h" |
| 23 #include "ui/keyboard/keyboard_switches.h" | 23 #include "ui/keyboard/keyboard_switches.h" |
| 24 #include "ui/keyboard/keyboard_util.h" | 24 #include "ui/keyboard/keyboard_util.h" |
| 25 | 25 |
| 26 namespace SetMode = extensions::core_api::virtual_keyboard_private::SetMode; | 26 namespace keyboard_api = extensions::core_api::virtual_keyboard_private; |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 aura::Window* GetKeyboardContainer() { | 30 aura::Window* GetKeyboardContainer() { |
| 31 keyboard::KeyboardController* controller = | 31 keyboard::KeyboardController* controller = |
| 32 keyboard::KeyboardController::GetInstance(); | 32 keyboard::KeyboardController::GetInstance(); |
| 33 return controller ? controller->GetContainerWindow() : nullptr; | 33 return controller ? controller->GetContainerWindow() : nullptr; |
| 34 } | 34 } |
| 35 | 35 |
| 36 std::string GenerateFeatureFlag(std::string feature, bool enabled) { | 36 std::string GenerateFeatureFlag(std::string feature, bool enabled) { |
| 37 return feature + (enabled ? "-enabled" : "-disabled"); | 37 return feature + (enabled ? "-enabled" : "-disabled"); |
| 38 } | 38 } |
| 39 | 39 |
| 40 keyboard::KeyboardMode getKeyboardModeEnum(SetMode::Params::Mode mode) { | 40 keyboard::KeyboardMode getKeyboardModeEnum(keyboard_api::KeyboardMode mode) { |
| 41 switch (mode) { | 41 switch (mode) { |
| 42 case SetMode::Params::MODE_NONE: | 42 case keyboard_api::KEYBOARD_MODE_NONE: |
| 43 return keyboard::NONE; | 43 return keyboard::NONE; |
| 44 case SetMode::Params::MODE_FULL_WIDTH: | 44 case keyboard_api::KEYBOARD_MODE_FULL_WIDTH: |
| 45 return keyboard::FULL_WIDTH; | 45 return keyboard::FULL_WIDTH; |
| 46 case SetMode::Params::MODE_FLOATING: | 46 case keyboard_api::KEYBOARD_MODE_FLOATING: |
| 47 return keyboard::FLOATING; | 47 return keyboard::FLOATING; |
| 48 } | 48 } |
| 49 return keyboard::NONE; | 49 return keyboard::NONE; |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace | 52 } // namespace |
| 53 | 53 |
| 54 namespace extensions { | 54 namespace extensions { |
| 55 | 55 |
| 56 bool ChromeVirtualKeyboardDelegate::GetKeyboardConfig( | 56 bool ChromeVirtualKeyboardDelegate::GetKeyboardConfig( |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 bool ChromeVirtualKeyboardDelegate::ShowLanguageSettings() { | 145 bool ChromeVirtualKeyboardDelegate::ShowLanguageSettings() { |
| 146 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 146 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 147 content::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog")); | 147 content::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog")); |
| 148 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), | 148 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), |
| 149 chrome::kLanguageOptionsSubPage); | 149 chrome::kLanguageOptionsSubPage); |
| 150 return true; | 150 return true; |
| 151 } | 151 } |
| 152 | 152 |
| 153 bool ChromeVirtualKeyboardDelegate::SetVirtualKeyboardMode(int mode_enum) { | 153 bool ChromeVirtualKeyboardDelegate::SetVirtualKeyboardMode(int mode_enum) { |
| 154 keyboard::KeyboardMode keyboard_mode = | 154 keyboard::KeyboardMode keyboard_mode = |
| 155 getKeyboardModeEnum(static_cast<SetMode::Params::Mode>(mode_enum)); | 155 getKeyboardModeEnum(static_cast<keyboard_api::KeyboardMode>(mode_enum)); |
| 156 keyboard::KeyboardController* controller = | 156 keyboard::KeyboardController* controller = |
| 157 keyboard::KeyboardController::GetInstance(); | 157 keyboard::KeyboardController::GetInstance(); |
| 158 if (!controller) | 158 if (!controller) |
| 159 return false; | 159 return false; |
| 160 | 160 |
| 161 controller->SetKeyboardMode(keyboard_mode); | 161 controller->SetKeyboardMode(keyboard_mode); |
| 162 return true; | 162 return true; |
| 163 } | 163 } |
| 164 | 164 |
| 165 bool ChromeVirtualKeyboardDelegate::IsLanguageSettingsEnabled() { | 165 bool ChromeVirtualKeyboardDelegate::IsLanguageSettingsEnabled() { |
| 166 return (user_manager::UserManager::Get()->IsUserLoggedIn() && | 166 return (user_manager::UserManager::Get()->IsUserLoggedIn() && |
| 167 !chromeos::UserAddingScreen::Get()->IsRunning() && | 167 !chromeos::UserAddingScreen::Get()->IsRunning() && |
| 168 !(chromeos::ScreenLocker::default_screen_locker() && | 168 !(chromeos::ScreenLocker::default_screen_locker() && |
| 169 chromeos::ScreenLocker::default_screen_locker()->locked())); | 169 chromeos::ScreenLocker::default_screen_locker()->locked())); |
| 170 } | 170 } |
| 171 | 171 |
| 172 } // namespace extensions | 172 } // namespace extensions |
| OLD | NEW |