| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/system_tray_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "ash/login_status.h" | 16 #include "ash/login_status.h" |
| 17 #include "ash/shell.h" | 17 #include "ash/shell.h" |
| 18 #include "ash/shell_delegate.h" | 18 #include "ash/shell_delegate.h" |
| 19 #include "ash/system/date/clock_observer.h" | 19 #include "ash/system/date/clock_observer.h" |
| 20 #include "ash/system/ime/ime_observer.h" | 20 #include "ash/system/ime/ime_observer.h" |
| 21 #include "ash/system/power/power_status.h" | 21 #include "ash/system/power/power_status.h" |
| 22 #include "ash/system/session/logout_button_observer.h" | 22 #include "ash/system/session/logout_button_observer.h" |
| 23 #include "ash/system/tray/system_tray_notifier.h" | 23 #include "ash/system/tray/system_tray_notifier.h" |
| 24 #include "ash/system/tray_accessibility.h" | 24 #include "ash/system/tray_accessibility.h" |
| 25 #include "base/callback.h" | 25 #include "base/callback.h" |
| 26 #include "base/logging.h" | 26 #include "base/logging.h" |
| 27 #include "base/memory/ptr_util.h" | 27 #include "base/memory/ptr_util.h" |
| 28 #include "base/metrics/user_metrics.h" | 28 #include "base/metrics/user_metrics.h" |
| 29 #include "base/strings/utf_string_conversions.h" | |
| 30 #include "base/sys_info.h" | 29 #include "base/sys_info.h" |
| 31 #include "base/time/time.h" | 30 #include "base/time/time.h" |
| 32 #include "chrome/browser/browser_process.h" | 31 #include "chrome/browser/browser_process.h" |
| 33 #include "chrome/browser/chrome_notification_types.h" | 32 #include "chrome/browser/chrome_notification_types.h" |
| 34 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 33 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 35 #include "chrome/browser/chromeos/events/system_key_event_listener.h" | 34 #include "chrome/browser/chromeos/events/system_key_event_listener.h" |
| 36 #include "chrome/browser/chromeos/login/login_wizard.h" | 35 #include "chrome/browser/chromeos/login/login_wizard.h" |
| 37 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 36 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 38 #include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h" | 37 #include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h" |
| 39 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 38 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 50 #include "chromeos/login/login_state.h" | 49 #include "chromeos/login/login_state.h" |
| 51 #include "chromeos/network/portal_detector/network_portal_detector.h" | 50 #include "chromeos/network/portal_detector/network_portal_detector.h" |
| 52 #include "components/google/core/browser/google_util.h" | 51 #include "components/google/core/browser/google_util.h" |
| 53 #include "components/prefs/pref_service.h" | 52 #include "components/prefs/pref_service.h" |
| 54 #include "components/session_manager/core/session_manager.h" | 53 #include "components/session_manager/core/session_manager.h" |
| 55 #include "components/user_manager/user.h" | 54 #include "components/user_manager/user.h" |
| 56 #include "components/user_manager/user_manager.h" | 55 #include "components/user_manager/user_manager.h" |
| 57 #include "components/user_manager/user_type.h" | 56 #include "components/user_manager/user_type.h" |
| 58 #include "content/public/browser/notification_observer.h" | 57 #include "content/public/browser/notification_observer.h" |
| 59 #include "content/public/browser/notification_service.h" | 58 #include "content/public/browser/notification_service.h" |
| 60 #include "ui/base/ime/chromeos/extension_ime_util.h" | |
| 61 #include "ui/base/ime/chromeos/input_method_manager.h" | 59 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 62 #include "ui/base/ime/chromeos/input_method_util.h" | |
| 63 #include "ui/chromeos/events/pref_names.h" | 60 #include "ui/chromeos/events/pref_names.h" |
| 64 #include "ui/chromeos/ime/input_method_menu_item.h" | |
| 65 #include "ui/chromeos/ime/input_method_menu_manager.h" | 61 #include "ui/chromeos/ime/input_method_menu_manager.h" |
| 66 | 62 |
| 67 namespace chromeos { | 63 namespace chromeos { |
| 68 | 64 |
| 69 namespace { | 65 namespace { |
| 70 | 66 |
| 71 // The minimum session length limit that can be set. | 67 // The minimum session length limit that can be set. |
| 72 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds. | 68 const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds. |
| 73 | 69 |
| 74 // The maximum session length limit that can be set. | 70 // The maximum session length limit that can be set. |
| 75 const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours. | 71 const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours. |
| 76 | 72 |
| 77 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, | |
| 78 const input_method::InputMethodUtil& util, | |
| 79 ash::IMEInfo* info) { | |
| 80 info->id = ime.id(); | |
| 81 info->name = util.GetInputMethodLongName(ime); | |
| 82 info->medium_name = util.GetInputMethodMediumName(ime); | |
| 83 info->short_name = util.GetInputMethodShortName(ime); | |
| 84 info->third_party = extension_ime_util::IsExtensionIME(ime.id()); | |
| 85 } | |
| 86 | |
| 87 void OnAcceptMultiprofilesIntro(bool no_show_again) { | 73 void OnAcceptMultiprofilesIntro(bool no_show_again) { |
| 88 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); | 74 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); |
| 89 prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again); | 75 prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again); |
| 90 UserAddingScreen::Get()->Start(); | 76 UserAddingScreen::Get()->Start(); |
| 91 } | 77 } |
| 92 | 78 |
| 93 } // namespace | 79 } // namespace |
| 94 | 80 |
| 95 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() | 81 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() |
| 96 : networking_config_delegate_( | 82 : networking_config_delegate_( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 if (show_intro) { | 182 if (show_intro) { |
| 197 base::Callback<void(bool)> on_accept = | 183 base::Callback<void(bool)> on_accept = |
| 198 base::Bind(&OnAcceptMultiprofilesIntro); | 184 base::Bind(&OnAcceptMultiprofilesIntro); |
| 199 ShowMultiprofilesIntroDialog(on_accept); | 185 ShowMultiprofilesIntroDialog(on_accept); |
| 200 } else { | 186 } else { |
| 201 UserAddingScreen::Get()->Start(); | 187 UserAddingScreen::Get()->Start(); |
| 202 } | 188 } |
| 203 } | 189 } |
| 204 } | 190 } |
| 205 | 191 |
| 206 void SystemTrayDelegateChromeOS::GetCurrentIME(ash::IMEInfo* info) { | |
| 207 input_method::InputMethodManager* manager = | |
| 208 input_method::InputMethodManager::Get(); | |
| 209 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); | |
| 210 input_method::InputMethodDescriptor ime = | |
| 211 manager->GetActiveIMEState()->GetCurrentInputMethod(); | |
| 212 ExtractIMEInfo(ime, *util, info); | |
| 213 info->selected = true; | |
| 214 } | |
| 215 | |
| 216 void SystemTrayDelegateChromeOS::GetAvailableIMEList(ash::IMEInfoList* list) { | |
| 217 input_method::InputMethodManager* manager = | |
| 218 input_method::InputMethodManager::Get(); | |
| 219 input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); | |
| 220 std::unique_ptr<input_method::InputMethodDescriptors> ime_descriptors( | |
| 221 manager->GetActiveIMEState()->GetActiveInputMethods()); | |
| 222 std::string current = | |
| 223 manager->GetActiveIMEState()->GetCurrentInputMethod().id(); | |
| 224 for (size_t i = 0; i < ime_descriptors->size(); i++) { | |
| 225 input_method::InputMethodDescriptor& ime = ime_descriptors->at(i); | |
| 226 ash::IMEInfo info; | |
| 227 ExtractIMEInfo(ime, *util, &info); | |
| 228 info.selected = ime.id() == current; | |
| 229 list->push_back(info); | |
| 230 } | |
| 231 } | |
| 232 | |
| 233 void SystemTrayDelegateChromeOS::GetCurrentIMEProperties( | |
| 234 ash::IMEPropertyInfoList* list) { | |
| 235 ui::ime::InputMethodMenuItemList menu_list = | |
| 236 ui::ime::InputMethodMenuManager::GetInstance()-> | |
| 237 GetCurrentInputMethodMenuItemList(); | |
| 238 for (size_t i = 0; i < menu_list.size(); ++i) { | |
| 239 ash::IMEPropertyInfo property; | |
| 240 property.key = menu_list[i].key; | |
| 241 property.name = base::UTF8ToUTF16(menu_list[i].label); | |
| 242 property.selected = menu_list[i].is_selection_item_checked; | |
| 243 list->push_back(property); | |
| 244 } | |
| 245 } | |
| 246 | |
| 247 ash::NetworkingConfigDelegate* | 192 ash::NetworkingConfigDelegate* |
| 248 SystemTrayDelegateChromeOS::GetNetworkingConfigDelegate() const { | 193 SystemTrayDelegateChromeOS::GetNetworkingConfigDelegate() const { |
| 249 return networking_config_delegate_.get(); | 194 return networking_config_delegate_.get(); |
| 250 } | 195 } |
| 251 | 196 |
| 252 bool SystemTrayDelegateChromeOS::GetSessionStartTime( | 197 bool SystemTrayDelegateChromeOS::GetSessionStartTime( |
| 253 base::TimeTicks* session_start_time) { | 198 base::TimeTicks* session_start_time) { |
| 254 *session_start_time = session_start_time_; | 199 *session_start_time = session_start_time_; |
| 255 return have_session_start_time_; | 200 return have_session_start_time_; |
| 256 } | 201 } |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 439 |
| 495 void SystemTrayDelegateChromeOS::ImeMenuItemsChanged( | 440 void SystemTrayDelegateChromeOS::ImeMenuItemsChanged( |
| 496 const std::string& engine_id, | 441 const std::string& engine_id, |
| 497 const std::vector<input_method::InputMethodManager::MenuItem>& items) {} | 442 const std::vector<input_method::InputMethodManager::MenuItem>& items) {} |
| 498 | 443 |
| 499 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 444 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
| 500 return new SystemTrayDelegateChromeOS(); | 445 return new SystemTrayDelegateChromeOS(); |
| 501 } | 446 } |
| 502 | 447 |
| 503 } // namespace chromeos | 448 } // namespace chromeos |
| OLD | NEW |