system_tray_delegate_chromeos.cc revision 116680a4aac90f2aa7413d9095a592090648e557
1a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <algorithm>
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <set>
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <string>
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <vector>
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/ash_switches.h"
13c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ash/desktop_background/desktop_background_controller.h"
14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ash/ime/input_method_menu_item.h"
15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ash/ime/input_method_menu_manager.h"
165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/metrics/user_metrics_recorder.h"
175c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "ash/session/session_state_delegate.h"
185c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "ash/session/session_state_observer.h"
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/shell.h"
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/shell_delegate.h"
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/shell_window_ids.h"
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/system/bluetooth/bluetooth_observer.h"
23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ash/system/chromeos/session/logout_button_observer.h"
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/system/date/clock_observer.h"
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/system/drive/drive_observer.h"
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/system/ime/ime_observer.h"
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/system/tray/system_tray.h"
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/system/tray/system_tray_delegate.h"
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ash/system/tray/system_tray_notifier.h"
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/system/tray_accessibility.h"
3158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "ash/system/user/login_status.h"
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/system/user/update_observer.h"
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/system/user/user_observer.h"
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/volume_control_delegate.h"
35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "ash/wm/lock_state_controller.h"
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/bind_helpers.h"
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/callback.h"
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/logging.h"
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/weak_ptr.h"
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/prefs/pref_service.h"
415e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles)#include "base/strings/stringprintf.h"
42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/utf_string_conversions.h"
434e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "base/sys_info.h"
44eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/time/time.h"
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/browser_process.h"
467dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "chrome/browser/chrome_notification_types.h"
47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/chromeos/accessibility/magnification_manager.h"
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h"
505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/chromeos/charger_replace/charger_replacement_dialog.h"
5190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/chromeos/drive/drive_integration_service.h"
52868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/chromeos/drive/job_list.h"
533551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "chrome/browser/chromeos/enrollment_dialog_view.h"
545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/chromeos/events/system_key_event_listener.h"
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chromeos/input_method/input_method_util.h"
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/chromeos/login/help_app_launcher.h"
58c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/chromeos/login/login_wizard.h"
59cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/chromeos/login/ui/login_display_host.h"
60cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
61cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
62cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
63cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/chromeos/login/users/user.h"
64cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/chromeos/login/users/user_manager.h"
6590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/chromeos/options/network_config_view.h"
665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h"
69116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "chrome/browser/chromeos/profiles/profile_helper.h"
705c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "chrome/browser/chromeos/set_time_dialog.h"
71bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch#include "chrome/browser/chromeos/settings/cros_settings.h"
7290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/chromeos/sim_dialog_delegate.h"
730529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h"
747d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "chrome/browser/drive/drive_service_interface.h"
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/lifetime/application_lifetime.h"
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/profiles/profile_manager.h"
775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
78cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/ui/ash/user_accounts_delegate_chromeos.h"
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/ash/volume_controller_chromeos.h"
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser.h"
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser_finder.h"
82a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "chrome/browser/ui/browser_list.h"
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/chrome_pages.h"
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/host_desktop.h"
850f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/singleton_tabs.h"
87eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "chrome/browser/ui/tabs/tab_strip_model.h"
885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/ui/webui/chromeos/charger_replacement_handler.h"
893551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/upgrade_detector.h"
91effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "chrome/common/chrome_switches.h"
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/pref_names.h"
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/url_constants.h"
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chromeos/dbus/dbus_thread_manager.h"
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chromeos/dbus/session_manager_client.h"
96c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chromeos/ime/extension_ime_util.h"
97a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#include "chromeos/ime/ime_keyboard.h"
98c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chromeos/ime/input_method_manager.h"
99c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chromeos/login/login_state.h"
100116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "chromeos/network/portal_detector/network_portal_detector.h"
1016d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "components/google/core/browser/google_util.h"
102a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "components/policy/core/common/cloud/cloud_policy_store.h"
103116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/user_manager/user_type.h"
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_observer.h"
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_service.h"
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/user_metrics.h"
107eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "content/public/browser/web_contents.h"
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "device/bluetooth/bluetooth_adapter.h"
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "device/bluetooth/bluetooth_adapter_factory.h"
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "device/bluetooth/bluetooth_device.h"
1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "grit/ash_strings.h"
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "grit/generated_resources.h"
1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "grit/locale_settings.h"
11490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "net/base/escape.h"
11590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "third_party/cros_system_api/dbus/service_constants.h"
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/l10n/l10n_util.h"
117bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch#include "ui/base/l10n/time_format.h"
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)using drive::DriveIntegrationService;
12090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)using drive::DriveIntegrationServiceFactory;
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace chromeos {
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace {
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// The minimum session length limit that can be set.
1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const int kSessionLengthLimitMinMs = 30 * 1000;  // 30 seconds.
1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// The maximum session length limit that can be set.
1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000;  // 24 hours.
1312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
132eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochconst char kDisplaySettingsSubPageName[] = "display";
133eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochconst char kDisplayOverscanSettingsSubPageName[] = "displayOverscan";
134eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
135f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// The URL for the Google Drive settings page.
136f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)const char kDriveSettingsPageURL[] = "https://drive.google.com";
137f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime,
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    const input_method::InputMethodUtil& util,
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    ash::IMEInfo* info) {
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  info->id = ime.id();
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  info->name = util.GetInputMethodLongName(ime);
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  info->medium_name = util.GetInputMethodMediumName(ime);
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  info->short_name = util.GetInputMethodShortName(ime);
145c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  info->third_party = extension_ime_util::IsExtensionIME(ime.id());
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)gfx::NativeWindow GetNativeWindowByStatus(ash::user::LoginStatus login_status,
1495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                          bool session_started) {
1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int container_id =
1515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      (!session_started || login_status == ash::user::LOGGED_IN_NONE ||
152c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch       login_status == ash::user::LOGGED_IN_LOCKED)
153c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch          ? ash::kShellWindowId_LockSystemModalContainer
154c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch          : ash::kShellWindowId_SystemModalContainer;
1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(),
1562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                  container_id);
1572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
159c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Converts drive::JobInfo to ash::DriveOperationStatus.
160c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// If the job is not of type that ash tray is interested, returns false.
161c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)bool ConvertToDriveOperationStatus(const drive::JobInfo& info,
162c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                                   ash::DriveOperationStatus* status) {
163c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  if (info.job_type == drive::TYPE_DOWNLOAD_FILE) {
164c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    status->type = ash::DriveOperationStatus::OPERATION_DOWNLOAD;
165c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  } else if (info.job_type == drive::TYPE_UPLOAD_NEW_FILE ||
1665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)             info.job_type == drive::TYPE_UPLOAD_EXISTING_FILE) {
167c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    status->type = ash::DriveOperationStatus::OPERATION_UPLOAD;
168c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  } else {
169c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return false;
170c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
171c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
172c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  if (info.state == drive::STATE_NONE)
173c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    status->state = ash::DriveOperationStatus::OPERATION_NOT_STARTED;
174c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  else
175c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    status->state = ash::DriveOperationStatus::OPERATION_IN_PROGRESS;
176c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
177c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  status->id = info.job_id;
178c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  status->file_path = info.file_path;
179c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  status->progress = info.num_total_bytes == 0 ? 0.0 :
180c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      static_cast<double>(info.num_completed_bytes) /
181c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)          static_cast<double>(info.num_total_bytes);
182c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  return true;
183c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
184c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
185c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Converts drive::JobInfo that has finished in |error| state
186c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// to ash::DriveOperationStatus.
187c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// If the job is not of type that ash tray is interested, returns false.
188c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)bool ConvertToFinishedDriveOperationStatus(const drive::JobInfo& info,
189c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                                           drive::FileError error,
190c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                                           ash::DriveOperationStatus* status) {
191c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  if (!ConvertToDriveOperationStatus(info, status))
192c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return false;
1935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  status->state = (error == drive::FILE_ERROR_OK)
1945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                      ? ash::DriveOperationStatus::OPERATION_COMPLETED
1955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                      : ash::DriveOperationStatus::OPERATION_FAILED;
196c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  return true;
197c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
198c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
199c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Converts a list of drive::JobInfo to a list of ash::DriveOperationStatusList.
200c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)ash::DriveOperationStatusList ConvertToDriveStatusList(
201c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    const std::vector<drive::JobInfo>& list) {
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ash::DriveOperationStatusList results;
203c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  for (size_t i = 0; i < list.size(); ++i) {
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    ash::DriveOperationStatus status;
205c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    if (ConvertToDriveOperationStatus(list[i], &status))
206c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      results.push_back(status);
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return results;
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void BluetoothPowerFailure() {
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(sad): Show an error bubble?
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void BluetoothSetDiscoveringError() {
2162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  LOG(ERROR) << "BluetoothSetDiscovering failed.";
2172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
2182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void BluetoothDeviceConnectError(
2202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    device::BluetoothDevice::ConnectErrorCode error_code) {
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(sad): Do something?
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
224effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochvoid ShowSettingsSubPageForActiveUser(const std::string& sub_page) {
225effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  chrome::ShowSettingsSubPageForProfile(
226effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch      ProfileManager::GetActiveUserProfile(), sub_page);
2270f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)}
2280f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
2293551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)void ShowNetworkSettingsPage(const std::string& service_path) {
2303551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  std::string page = chrome::kInternetOptionsSubPage;
2314e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  page += "?servicePath=" + net::EscapeUrlEncodedData(service_path, true);
2325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::RecordAction(base::UserMetricsAction("OpenInternetOptionsDialog"));
233effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser(page);
2345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
2355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void OnAcceptMultiprofilesIntro(bool no_show_again) {
2375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
2385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again);
2395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UserAddingScreen::Get()->Start();
2405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
2415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}  // namespace
2435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS()
2455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    : weak_ptr_factory_(this),
2465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      user_profile_(NULL),
2475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      clock_type_(base::GetHourClockType()),
2485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      search_key_mapped_to_(input_method::kSearchKey),
2495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      screen_locked_(false),
2505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      have_session_start_time_(false),
2515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      have_session_length_limit_(false),
252a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      should_run_bluetooth_discovery_(false),
2535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      volume_control_delegate_(new VolumeController()),
2545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      device_settings_observer_(CrosSettings::Get()->AddSettingsObserver(
2555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          kSystemUse24HourClock,
2565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          base::Bind(&SystemTrayDelegateChromeOS::UpdateClockType,
2575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                     base::Unretained(this)))) {
2585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Register notifications on construction so that events such as
2595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // PROFILE_CREATED do not get missed if they happen before Initialize().
2605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  registrar_.reset(new content::NotificationRegistrar);
2615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  registrar_->Add(this,
2625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
2635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  content::NotificationService::AllSources());
2645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  registrar_->Add(this,
2655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
2665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  content::NotificationService::AllSources());
2675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (GetUserLoginStatus() == ash::user::LOGGED_IN_NONE) {
26890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    registrar_->Add(this,
2695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                    chrome::NOTIFICATION_SESSION_STARTED,
2705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                    content::NotificationService::AllSources());
2715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
2725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  registrar_->Add(this,
2735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  chrome::NOTIFICATION_PROFILE_CREATED,
2745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  content::NotificationService::AllSources());
2755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  registrar_->Add(this,
2765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  chrome::NOTIFICATION_PROFILE_DESTROYED,
2775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  content::NotificationService::AllSources());
278a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
279a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
280a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  CHECK(accessibility_manager);
281a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  accessibility_subscription_ = accessibility_manager->RegisterCallback(
282a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged,
283a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                 base::Unretained(this)));
2845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::Initialize() {
2875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodManager::Get()->AddObserver(this);
290a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  ash::ime::InputMethodMenuManager::GetInstance()->AddObserver(this);
2915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateClockType();
2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  device::BluetoothAdapterFactory::GetAdapter(
2945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::InitializeOnAdapterReady,
2955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 weak_ptr_factory_.GetWeakPtr()));
296868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
2975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::Shell::GetInstance()->session_state_delegate()->AddSessionStateObserver(
2985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      this);
29958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
3005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (LoginState::IsInitialized())
3015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    LoginState::Get()->AddObserver(this);
302a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
303a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (CrasAudioHandler::IsInitialized())
304a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    CrasAudioHandler::Get()->AddAudioObserver(this);
305a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
306a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  BrowserList::AddObserver(this);
3075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::Shutdown() {
3105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  device_settings_observer_.reset();
3115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
312c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
3135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::InitializeOnAdapterReady(
3145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    scoped_refptr<device::BluetoothAdapter> adapter) {
3155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bluetooth_adapter_ = adapter;
3165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  CHECK(bluetooth_adapter_.get());
3175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bluetooth_adapter_->AddObserver(this);
3185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  local_state_registrar_.reset(new PrefChangeRegistrar);
3205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  local_state_registrar_->Init(g_browser_process->local_state());
3215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateSessionStartTime();
3235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateSessionLengthLimit();
3245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  local_state_registrar_->Add(
3265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kSessionStartTime,
3275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::UpdateSessionStartTime,
3285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this)));
3295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  local_state_registrar_->Add(
3305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kSessionLengthLimit,
3315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::UpdateSessionLengthLimit,
3325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this)));
3335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  policy::BrowserPolicyConnectorChromeOS* policy_connector =
3355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      g_browser_process->platform_part()->browser_policy_connector_chromeos();
3365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
3375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      policy_connector->GetDeviceCloudPolicyManager();
3385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (policy_manager)
3395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    policy_manager->core()->store()->AddObserver(this);
3405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateEnterpriseDomain();
3415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() {
3445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Unregister PrefChangeRegistrars.
3455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  local_state_registrar_.reset();
3465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_.reset();
3475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
348a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Unregister content notifications before destroying any components.
3495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  registrar_.reset();
3505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
351a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Unregister a11y status subscription.
352a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  accessibility_subscription_.reset();
353a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
3545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this);
3555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodManager::Get()->RemoveObserver(this);
356a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  ash::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this);
3575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bluetooth_adapter_->RemoveObserver(this);
3585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::Shell::GetInstance()
3595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ->session_state_delegate()
3605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ->RemoveSessionStateObserver(this);
3615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  LoginState::Get()->RemoveObserver(this);
3625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
363a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (CrasAudioHandler::IsInitialized())
364a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    CrasAudioHandler::Get()->RemoveAudioObserver(this);
365a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
366a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  BrowserList::RemoveObserver(this);
367a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  StopObservingAppWindowRegistry();
368a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
3695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Stop observing Drive operations.
3705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UnobserveDriveUpdates();
3715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  policy::BrowserPolicyConnectorChromeOS* connector =
3735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      g_browser_process->platform_part()->browser_policy_connector_chromeos();
3745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
3755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      connector->GetDeviceCloudPolicyManager();
3765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (policy_manager)
3775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    policy_manager->core()->store()->RemoveObserver(this);
3785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from ash::SystemTrayDelegate:
3815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetTrayVisibilityOnStartup() {
3825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // In case of OOBE / sign in screen tray will be shown later.
3835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return LoginState::Get()->IsUserLoggedIn();
3845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
3855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ash::user::LoginStatus SystemTrayDelegateChromeOS::GetUserLoginStatus() const {
3875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // All non-logged in ChromeOS specific LOGGED_IN states map to the same
3885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Ash specific LOGGED_IN state.
3895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!LoginState::Get()->IsUserLoggedIn())
3905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return ash::user::LOGGED_IN_NONE;
3915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (screen_locked_)
3935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return ash::user::LOGGED_IN_LOCKED;
3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  LoginState::LoggedInUserType user_type =
3965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      LoginState::Get()->GetLoggedInUserType();
3975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  switch (user_type) {
3985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_NONE:
3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      return ash::user::LOGGED_IN_NONE;
4005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_REGULAR:
4015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      return ash::user::LOGGED_IN_USER;
4025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_OWNER:
4035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      return ash::user::LOGGED_IN_OWNER;
4045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_GUEST:
4055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      return ash::user::LOGGED_IN_GUEST;
4065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_RETAIL_MODE:
4075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      return ash::user::LOGGED_IN_RETAIL_MODE;
4085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT:
4095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      return ash::user::LOGGED_IN_PUBLIC;
4105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_LOCALLY_MANAGED:
4115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      return ash::user::LOGGED_IN_LOCALLY_MANAGED;
4125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_KIOSK_APP:
4135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      return ash::user::LOGGED_IN_KIOSK_APP;
4145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
4155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  NOTREACHED();
4165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return ash::user::LOGGED_IN_NONE;
4175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
418d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
4195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ChangeProfilePicture() {
4205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::RecordAction(
4215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::UserMetricsAction("OpenChangeProfilePictureDialog"));
422effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser(chrome::kChangeProfilePictureSubPage);
4235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
424c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
4255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const std::string SystemTrayDelegateChromeOS::GetEnterpriseDomain() const {
4265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return enterprise_domain_;
4275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const base::string16 SystemTrayDelegateChromeOS::GetEnterpriseMessage() const {
4305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (GetEnterpriseDomain().empty())
4315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return base::string16();
4325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return l10n_util::GetStringFUTF16(IDS_DEVICE_OWNED_BY_NOTICE,
4335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                    base::UTF8ToUTF16(GetEnterpriseDomain()));
4345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const std::string SystemTrayDelegateChromeOS::GetLocallyManagedUserManager()
4375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const {
4385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED)
4395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return std::string();
4405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return UserManager::Get()->GetSupervisedUserManager()->GetManagerDisplayEmail(
4415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      chromeos::UserManager::Get()->GetActiveUser()->email());
4425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const base::string16
4455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SystemTrayDelegateChromeOS::GetLocallyManagedUserManagerName() const {
4465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED)
4475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return base::string16();
4485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return UserManager::Get()->GetSupervisedUserManager()->GetManagerDisplayName(
4495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      chromeos::UserManager::Get()->GetActiveUser()->email());
4505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
451c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
4525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const base::string16 SystemTrayDelegateChromeOS::GetLocallyManagedUserMessage()
4535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const {
4545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED)
4555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return base::string16();
4565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return l10n_util::GetStringFUTF16(
4575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      IDS_USER_IS_LOCALLY_MANAGED_BY_NOTICE,
4585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::UTF8ToUTF16(GetLocallyManagedUserManager()));
4595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
460eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
4615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::SystemShouldUpgrade() const {
4625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return UpgradeDetector::GetInstance()->notify_upgrade();
4635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
464c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
4655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)base::HourClockType SystemTrayDelegateChromeOS::GetHourClockType() const {
4665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return clock_type_;
4675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowSettings() {
470effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser("");
4715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::ShouldShowSettings() {
4745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return UserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings();
4755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowDateSettings() {
4785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::RecordAction(base::UserMetricsAction("ShowDateOptions"));
4795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  std::string sub_page =
4805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      std::string(chrome::kSearchSubPage) + "#" +
4815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME);
4825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Everybody can change the time zone (even though it is a device setting).
483effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser(sub_page);
4845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4853551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
4865c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liuvoid SystemTrayDelegateChromeOS::ShowSetTimeDialog() {
4875c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  SetTimeDialog::ShowDialog(GetNativeWindow());
4885c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu}
4895c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
4905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowNetworkSettings(
4915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::string& service_path) {
4925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!LoginState::Get()->IsUserLoggedIn())
4935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
4945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ShowNetworkSettingsPage(service_path);
4955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowBluetoothSettings() {
4985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(sad): Make this work.
4995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowDisplaySettings() {
5025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::RecordAction(base::UserMetricsAction("ShowDisplayOptions"));
503effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser(kDisplaySettingsSubPageName);
5045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowChromeSlow() {
5075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ScopedTabbedBrowserDisplayer displayer(
5085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ProfileManager::GetPrimaryUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
5095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ShowSlow(displayer.browser());
5105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
511eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
5125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::ShouldShowDisplayNotification() {
5135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Packaged app is not counted as 'last active', so if a browser opening the
5145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // display settings is in background of a packaged app, it will return true.
5155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(mukai): fix this.
5165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  Browser* active_browser =
5175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      chrome::FindLastActiveWithHostDesktopType(chrome::HOST_DESKTOP_TYPE_ASH);
5185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!active_browser)
5195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return true;
520ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch
5215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::WebContents* active_contents =
5225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      active_browser->tab_strip_model()->GetActiveWebContents();
5235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!active_contents)
5245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return true;
5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GURL visible_url = active_contents->GetLastCommittedURL();
527effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  GURL display_settings_url =
528effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch      chrome::GetSettingsUrl(kDisplaySettingsSubPageName);
529effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  GURL display_overscan_url =
530effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch      chrome::GetSettingsUrl(kDisplayOverscanSettingsSubPageName);
531effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  return (visible_url != display_settings_url &&
532effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch          visible_url != display_overscan_url);
5335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowDriveSettings() {
5365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(tengs): Open the drive-specific settings page once we put it in.
5375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // For now just show Google Drive main page.
5385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ScopedTabbedBrowserDisplayer displayer(
5395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
5405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ShowSingletonTabOverwritingNTP(
5415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      displayer.browser(),
5425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      chrome::GetSingletonTabNavigateParams(displayer.browser(),
5435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                            GURL(kDriveSettingsPageURL)));
5445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowIMESettings() {
5475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog"));
548effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser(chrome::kLanguageOptionsSubPage);
5495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowHelp() {
5525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(),
5535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                             chrome::HOST_DESKTOP_TYPE_ASH,
5545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                             chrome::HELP_SOURCE_MENU);
5555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowAccessibilityHelp() {
5585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ScopedTabbedBrowserDisplayer displayer(
5595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
5605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  accessibility::ShowAccessibilityHelp(displayer.browser());
5615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
562b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
5635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowAccessibilitySettings() {
5645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::RecordAction(base::UserMetricsAction("ShowAccessibilitySettings"));
5655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  std::string sub_page = std::string(chrome::kSearchSubPage) + "#" +
5665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                         l10n_util::GetStringUTF8(
5675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                             IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY);
568effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser(sub_page);
5695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowPublicAccountInfo() {
5725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ScopedTabbedBrowserDisplayer displayer(
5735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
5745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ShowPolicy(displayer.browser());
5755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
5775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowLocallyManagedUserInfo() {
5785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(antrim): find out what should we show in this case.
5795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // http://crbug.com/229762
5805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
5825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowEnterpriseInfo() {
5835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::user::LoginStatus status = GetUserLoginStatus();
5845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (status == ash::user::LOGGED_IN_NONE ||
5855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      status == ash::user::LOGGED_IN_LOCKED) {
5865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    scoped_refptr<chromeos::HelpAppLauncher> help_app(
5875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        new chromeos::HelpAppLauncher(GetNativeWindow()));
5885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    help_app->ShowHelpTopic(chromeos::HelpAppLauncher::HELP_ENTERPRISE);
5895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  } else {
5905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    chrome::ScopedTabbedBrowserDisplayer displayer(
5915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
592f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)    chrome::ShowSingletonTab(displayer.browser(),
593f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)                             GURL(chrome::kLearnMoreEnterpriseURL));
594c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
5955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
596c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
5975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowUserLogin() {
5985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::Shell* shell = ash::Shell::GetInstance();
5995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!shell->delegate()->IsMultiProfilesEnabled())
6005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
6015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
6025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Only regular users could add other users to current session.
6035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (UserManager::Get()->GetActiveUser()->GetType() !=
604116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch      user_manager::USER_TYPE_REGULAR) {
6055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
6065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
6075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
6085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (static_cast<int>(UserManager::Get()->GetLoggedInUsers().size()) >=
6095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers())
6105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
6115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
6125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Launch sign in screen to add another user to current session.
6135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (UserManager::Get()->GetUsersAdmittedForMultiProfile().size()) {
6145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // Don't show dialog if any logged in user in multi-profiles session
6155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // dismissed it.
6165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    bool show_intro = true;
6175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const UserList logged_in_users = UserManager::Get()->GetLoggedInUsers();
6185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    for (UserList::const_iterator it = logged_in_users.begin();
6195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)         it != logged_in_users.end();
6205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)         ++it) {
6215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      show_intro &= !multi_user_util::GetProfileFromUserID(
6225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                         multi_user_util::GetUserIDFromEmail((*it)->email()))
6235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                         ->GetPrefs()
6245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                         ->GetBoolean(prefs::kMultiProfileNeverShowIntro);
6255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      if (!show_intro)
6265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        break;
6275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    }
6285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    if (show_intro) {
6295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Callback<void(bool)> on_accept =
6305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          base::Bind(&OnAcceptMultiprofilesIntro);
6315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ShowMultiprofilesIntroDialog(on_accept);
6322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    } else {
6335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      UserAddingScreen::Get()->Start();
6342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    }
6352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
6365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
6372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
6385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::ShowSpringChargerReplacementDialog() {
6395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!ChargerReplacementDialog::ShouldShowDialog())
6405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return false;
641c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
6425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ChargerReplacementDialog* dialog =
6435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      new ChargerReplacementDialog(GetNativeWindow());
6445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  dialog->Show();
6455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return true;
6465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
647c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
6485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::IsSpringChargerReplacementDialogVisible() {
6495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return ChargerReplacementDialog::IsDialogVisible();
6505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
651c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
6525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::HasUserConfirmedSafeSpringCharger() {
6535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return ChargerReplacementHandler::GetChargerStatusPref() ==
6545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)         ChargerReplacementHandler::CONFIRM_SAFE_CHARGER;
6555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
656c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
6575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShutDown() {
6585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::Shell::GetInstance()->lock_state_controller()->RequestShutdown();
6595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
6605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::SignOut() {
6625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::AttemptUserExit();
6635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
6645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::RequestLockScreen() {
6665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(antrim) : additional logging for crbug/173178
6675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  LOG(WARNING) << "Requesting screen lock from AshSystemTrayDelegate";
6685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen();
6695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
6705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::RequestRestartForUpdate() {
6725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // We expect that UpdateEngine is in "Reboot for update" state now.
6735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::NotifyAndTerminate(true /* fast path */);
6745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
6755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::GetAvailableBluetoothDevices(
6775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::BluetoothDeviceList* list) {
6785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  device::BluetoothAdapter::DeviceList devices =
6795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      bluetooth_adapter_->GetDevices();
6805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  for (size_t i = 0; i < devices.size(); ++i) {
6815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothDevice* device = devices[i];
6825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::BluetoothDeviceInfo info;
6835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    info.address = device->GetAddress();
6845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    info.display_name = device->GetName();
6855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    info.connected = device->IsConnected();
6865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    info.connecting = device->IsConnecting();
6875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    info.paired = device->IsPaired();
6885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    list->push_back(info);
6895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
6905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
6915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::BluetoothStartDiscovering() {
693e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  if (GetBluetoothDiscovering()) {
694a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    LOG(WARNING) << "Already have active Bluetooth device discovery session.";
695a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return;
696a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
697a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  VLOG(1) << "Requesting new Bluetooth device discovery session.";
698a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  should_run_bluetooth_discovery_ = true;
699a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  bluetooth_adapter_->StartDiscoverySession(
700a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::OnStartBluetoothDiscoverySession,
701a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                 weak_ptr_factory_.GetWeakPtr()),
702a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      base::Bind(&BluetoothSetDiscoveringError));
7035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
7055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::BluetoothStopDiscovering() {
706a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  should_run_bluetooth_discovery_ = false;
707e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  if (!GetBluetoothDiscovering()) {
708a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    LOG(WARNING) << "No active Bluetooth device discovery session.";
709a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return;
710a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
711a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  VLOG(1) << "Stopping Bluetooth device discovery session.";
712a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  bluetooth_discovery_session_->Stop(
7135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&base::DoNothing), base::Bind(&BluetoothSetDiscoveringError));
7145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
7165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ConnectToBluetoothDevice(
7175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::string& address) {
7185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  device::BluetoothDevice* device = bluetooth_adapter_->GetDevice(address);
7195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!device || device->IsConnecting() ||
7205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      (device->IsConnected() && device->IsPaired())) {
7215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
7225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
7235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (device->IsPaired() && !device->IsConnectable())
7245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
7255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (device->IsPaired() || !device->IsPairable()) {
7265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction(
7275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        ash::UMA_STATUS_AREA_BLUETOOTH_CONNECT_KNOWN_DEVICE);
7285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device->Connect(NULL,
7295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                    base::Bind(&base::DoNothing),
7305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                    base::Bind(&BluetoothDeviceConnectError));
7315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  } else {  // Show paring dialog for the unpaired device.
7325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction(
7335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        ash::UMA_STATUS_AREA_BLUETOOTH_CONNECT_UNKNOWN_DEVICE);
7345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    BluetoothPairingDialog* dialog =
7355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        new BluetoothPairingDialog(GetNativeWindow(), device);
7365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // The dialog deletes itself on close.
7375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    dialog->Show();
7385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
7395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::IsBluetoothDiscovering() {
7425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return bluetooth_adapter_->IsDiscovering();
7435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::GetCurrentIME(ash::IMEInfo* info) {
7465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodManager* manager =
7475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      input_method::InputMethodManager::Get();
7485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodUtil* util = manager->GetInputMethodUtil();
7495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodDescriptor ime = manager->GetCurrentInputMethod();
7505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ExtractIMEInfo(ime, *util, info);
7515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  info->selected = true;
7525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::GetAvailableIMEList(ash::IMEInfoList* list) {
7555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodManager* manager =
7565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      input_method::InputMethodManager::Get();
7575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodUtil* util = manager->GetInputMethodUtil();
7585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_ptr<input_method::InputMethodDescriptors> ime_descriptors(
7595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      manager->GetActiveInputMethods());
7605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  std::string current = manager->GetCurrentInputMethod().id();
7615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  for (size_t i = 0; i < ime_descriptors->size(); i++) {
7625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    input_method::InputMethodDescriptor& ime = ime_descriptors->at(i);
7635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::IMEInfo info;
7645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ExtractIMEInfo(ime, *util, &info);
7655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    info.selected = ime.id() == current;
7665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    list->push_back(info);
7675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
7685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::GetCurrentIMEProperties(
7715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::IMEPropertyInfoList* list) {
772a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  ash::ime::InputMethodMenuItemList menu_list =
773a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      ash::ime::InputMethodMenuManager::GetInstance()->
774a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      GetCurrentInputMethodMenuItemList();
775a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  for (size_t i = 0; i < menu_list.size(); ++i) {
7765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::IMEPropertyInfo property;
777a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    property.key = menu_list[i].key;
778a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    property.name = base::UTF8ToUTF16(menu_list[i].label);
779a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    property.selected = menu_list[i].is_selection_item_checked;
7805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    list->push_back(property);
7815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
7825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::SwitchIME(const std::string& ime_id) {
7855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodManager::Get()->ChangeInputMethod(ime_id);
7865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ActivateIMEProperty(const std::string& key) {
789a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  input_method::InputMethodManager::Get()->ActivateInputMethodMenuItem(key);
7905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::CancelDriveOperation(int32 operation_id) {
7935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DriveIntegrationService* integration_service = FindDriveIntegrationService();
7945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!integration_service)
7955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
7965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  integration_service->job_list()->CancelJob(operation_id);
7985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::GetDriveOperationStatusList(
8015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::DriveOperationStatusList* list) {
8025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DriveIntegrationService* integration_service = FindDriveIntegrationService();
8035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!integration_service)
8045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
8055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  *list = ConvertToDriveStatusList(
8075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      integration_service->job_list()->GetJobInfoList());
8085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowNetworkConfigure(
8115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::string& network_id,
8125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    gfx::NativeWindow parent_window) {
8135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  NetworkConfigView::Show(network_id, parent_window);
8145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::EnrollNetwork(
8175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::string& network_id,
8185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    gfx::NativeWindow parent_window) {
8195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return enrollment::CreateDialog(network_id, parent_window);
8205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ManageBluetoothDevices() {
8235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::RecordAction(base::UserMetricsAction("ShowBluetoothSettingsPage"));
8245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  std::string sub_page =
8255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      std::string(chrome::kSearchSubPage) + "#" +
8265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH);
827effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser(sub_page);
8285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ToggleBluetooth() {
8315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bluetooth_adapter_->SetPowered(!bluetooth_adapter_->IsPowered(),
8325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                 base::Bind(&base::DoNothing),
8335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                 base::Bind(&BluetoothPowerFailure));
8345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowMobileSimDialog() {
8375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  SimDialogDelegate::ShowDialog(GetNativeWindow(),
8385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                SimDialogDelegate::SIM_DIALOG_UNLOCK);
8395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
84090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
8415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowMobileSetupDialog(
8425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::string& service_path) {
8435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  MobileSetupDialog::Show(service_path);
8445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
845ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch
8465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowOtherNetworkDialog(
8475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::string& type) {
8485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (type == shill::kTypeCellular) {
8495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow());
8505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
8515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
8525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  NetworkConfigView::ShowForType(type, GetNativeWindow());
8535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetBluetoothAvailable() {
8565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return bluetooth_adapter_->IsPresent();
8575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetBluetoothEnabled() {
8605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return bluetooth_adapter_->IsPowered();
8615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
863e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochbool SystemTrayDelegateChromeOS::GetBluetoothDiscovering() {
864e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  return (bluetooth_discovery_session_.get() &&
865e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch      bluetooth_discovery_session_->IsActive());
866e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch}
867e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch
8685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ChangeProxySettings() {
8695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  CHECK(GetUserLoginStatus() == ash::user::LOGGED_IN_NONE);
8705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  LoginDisplayHostImpl::default_host()->OpenProxySettings();
8715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ash::VolumeControlDelegate*
8745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SystemTrayDelegateChromeOS::GetVolumeControlDelegate() const {
8755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return volume_control_delegate_.get();
8765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::SetVolumeControlDelegate(
8795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    scoped_ptr<ash::VolumeControlDelegate> delegate) {
8805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  volume_control_delegate_.swap(delegate);
8815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetSessionStartTime(
8845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    base::TimeTicks* session_start_time) {
8855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  *session_start_time = session_start_time_;
8865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return have_session_start_time_;
8875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
8895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetSessionLengthLimit(
8905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    base::TimeDelta* session_length_limit) {
8915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  *session_length_limit = session_length_limit_;
8925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return have_session_length_limit_;
8935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
8955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)int SystemTrayDelegateChromeOS::GetSystemTrayMenuWidth() {
8965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return l10n_util::GetLocalizedContentsWidthInPixels(
8975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      IDS_SYSTEM_TRAY_MENU_BUBBLE_WIDTH_PIXELS);
8985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
9005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ActiveUserWasChanged() {
9015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyUserUpdate();
9025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
9032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
904a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool SystemTrayDelegateChromeOS::IsSearchKeyMappedToCapsLock() {
905a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return search_key_mapped_to_ == input_method::kCapsLockKey;
906a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
907a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
908a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochash::tray::UserAccountsDelegate*
909a02191e04bc25c4935f804f2c080ae28663d096dBen MurdochSystemTrayDelegateChromeOS::GetUserAccountsDelegate(
910a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    const std::string& user_id) {
911a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  if (!accounts_delegates_.contains(user_id)) {
912cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    const User* user = UserManager::Get()->FindUser(user_id);
913116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user);
914cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    CHECK(user_profile);
915cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    accounts_delegates_.set(
916cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)        user_id,
917cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)        scoped_ptr<ash::tray::UserAccountsDelegate>(
918cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)            new UserAccountsDelegateChromeOS(user_profile)));
919a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  }
920a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  return accounts_delegates_.get(user_id);
921a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch}
922a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
9235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ash::SystemTray* SystemTrayDelegateChromeOS::GetPrimarySystemTray() {
9245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return ash::Shell::GetInstance()->GetPrimarySystemTray();
9255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
9265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() {
9285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return ash::Shell::GetInstance()->system_tray_notifier();
9295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
9305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) {
932a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Stop observing the Drive integration status and the AppWindowRegistry of
933a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // the current |user_profile_|.
9345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UnobserveDriveUpdates();
935a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  StopObservingAppWindowRegistry();
9365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
9375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_profile_ = profile;
9385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
939a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Start observing the Drive integration status and the AppWindowRegistry of
940a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // the newly set |user_profile_|.
9415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ObserveDriveUpdates();
942a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  apps::AppWindowRegistry::Get(user_profile_)->AddObserver(this);
9435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
9445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  PrefService* prefs = profile->GetPrefs();
9455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_.reset(new PrefChangeRegistrar);
9465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Init(prefs);
9475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
9485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kUse24HourClock,
9495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::UpdateClockType,
9505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this)));
9515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
9525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kLanguageRemapSearchKeyTo,
9535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::OnLanguageRemapSearchKeyToChanged,
9545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this)));
9555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
9565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kShowLogoutButtonInTray,
9575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray,
9585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this)));
9595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
9605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kLogoutDialogDurationMs,
9615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration,
9625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this)));
9635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
964f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      prefs::kAccessibilityLargeCursorEnabled,
9655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityModeChanged,
9665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this),
9675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 ash::A11Y_NOTIFICATION_NONE));
9685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
969f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      prefs::kAccessibilityAutoclickEnabled,
9705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityModeChanged,
9715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this),
9725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 ash::A11Y_NOTIFICATION_NONE));
9735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
9745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kShouldAlwaysShowAccessibilityMenu,
9755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityModeChanged,
9765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this),
9775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 ash::A11Y_NOTIFICATION_NONE));
9785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
9795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kPerformanceTracingEnabled,
9805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::UpdatePerformanceTracing,
9815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this)));
9825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
9835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateClockType();
9845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateShowLogoutButtonInTray();
9855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateLogoutDialogDuration();
9865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdatePerformanceTracing();
9875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  search_key_mapped_to_ =
9885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      profile->GetPrefs()->GetInteger(prefs::kLanguageRemapSearchKeyTo);
9895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
99090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
9915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::UnsetProfile(Profile* profile) {
9925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (profile != user_profile_)
9935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return false;
9945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_.reset();
995a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  user_profile_ = NULL;
9965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return true;
9975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
9985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ObserveDriveUpdates() {
10005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DriveIntegrationService* integration_service = FindDriveIntegrationService();
10015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (integration_service)
10025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    integration_service->job_list()->AddObserver(this);
10035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
10047dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
10055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UnobserveDriveUpdates() {
10065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DriveIntegrationService* integration_service = FindDriveIntegrationService();
10075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (integration_service)
10085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    integration_service->job_list()->RemoveObserver(this);
10095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
1010bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch
10115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetShouldUse24HourClockForTesting() const {
10125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return ShouldUse24HourClock();
10135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
10142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
10155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::ShouldUse24HourClock() const {
10165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // On login screen and in guest mode owner default is used for
10175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // kUse24HourClock preference.
10185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const ash::user::LoginStatus status = GetUserLoginStatus();
10195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const CrosSettings* const cros_settings = CrosSettings::Get();
10205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool system_use_24_hour_clock = true;
10215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const bool system_value_found = cros_settings->GetBoolean(
10225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      kSystemUse24HourClock, &system_use_24_hour_clock);
10235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
10245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if ((status == ash::user::LOGGED_IN_NONE) || !user_pref_registrar_)
10255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return (system_value_found
10265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                ? system_use_24_hour_clock
10275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                : (base::GetHourClockType() == base::k24HourClock));
10285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
10295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const PrefService::Preference* user_pref =
10305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      user_pref_registrar_->prefs()->FindPreference(prefs::kUse24HourClock);
10315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (status == ash::user::LOGGED_IN_GUEST && user_pref->IsDefaultValue())
10325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return (system_value_found
10335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                ? system_use_24_hour_clock
10345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                : (base::GetHourClockType() == base::k24HourClock));
10355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
10365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool use_24_hour_clock = true;
10375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref->GetValue()->GetAsBoolean(&use_24_hour_clock);
10385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return use_24_hour_clock;
10395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
10405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateClockType() {
10425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const bool use_24_hour_clock = ShouldUse24HourClock();
10435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock;
10445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyDateFormatChanged();
10455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // This also works for enterprise-managed devices because they never have
10465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // local owner.
10475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (chromeos::UserManager::Get()->IsCurrentUserOwner())
10485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, use_24_hour_clock);
10495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
10505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() {
10525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyShowLoginButtonChanged(
10535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      user_pref_registrar_->prefs()->GetBoolean(
10545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          prefs::kShowLogoutButtonInTray));
10555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
10565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() {
10585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const int duration_ms =
10595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      user_pref_registrar_->prefs()->GetInteger(prefs::kLogoutDialogDurationMs);
10605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyLogoutDialogDurationChanged(
10615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::TimeDelta::FromMilliseconds(duration_ms));
10625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
106358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
10645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateSessionStartTime() {
10655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const PrefService* local_state = local_state_registrar_->prefs();
10665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (local_state->HasPrefPath(prefs::kSessionStartTime)) {
10675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    have_session_start_time_ = true;
10685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    session_start_time_ = base::TimeTicks::FromInternalValue(
10695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        local_state->GetInt64(prefs::kSessionStartTime));
10705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  } else {
10715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    have_session_start_time_ = false;
10725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    session_start_time_ = base::TimeTicks();
10735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
10745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifySessionStartTimeChanged();
10755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
10765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateSessionLengthLimit() {
10785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const PrefService* local_state = local_state_registrar_->prefs();
10795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (local_state->HasPrefPath(prefs::kSessionLengthLimit)) {
10805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    have_session_length_limit_ = true;
10815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    session_length_limit_ = base::TimeDelta::FromMilliseconds(
10825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        std::min(std::max(local_state->GetInteger(prefs::kSessionLengthLimit),
10835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                          kSessionLengthLimitMinMs),
10845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 kSessionLengthLimitMaxMs));
10855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  } else {
10865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    have_session_length_limit_ = false;
10875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    session_length_limit_ = base::TimeDelta();
10885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
10895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifySessionLengthLimitChanged();
10905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
10915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1092a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::StopObservingAppWindowRegistry() {
1093a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (!user_profile_)
1094a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return;
1095a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1096a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  apps::AppWindowRegistry* registry =
1097a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      apps::AppWindowRegistry::Factory::GetForBrowserContext(user_profile_,
1098a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                             false);
1099a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (registry)
1100a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    registry->RemoveObserver(this);
1101a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1102a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1103a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::NotifyIfLastWindowClosed() {
1104a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (!user_profile_)
1105a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return;
1106a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1107a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  BrowserList* browser_list =
1108a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
1109a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  for (BrowserList::const_iterator it = browser_list->begin();
1110a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)       it != browser_list->end();
1111a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)       ++it) {
1112a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    if ((*it)->profile()->IsSameProfile(user_profile_)) {
1113a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      // The current user has at least one open browser window.
1114a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      return;
1115a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    }
1116a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
1117a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1118a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (!apps::AppWindowRegistry::Get(user_profile_)->app_windows().empty()) {
1119a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // The current user has at least one open app window.
1120a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return;
1121a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
1122a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1123a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyLastWindowClosed();
1124a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1125a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
11265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// LoginState::Observer overrides.
11275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::LoggedInStateChanged() {
11285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // It apparently sometimes takes a while after login before the current user
11295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // is recognized as the owner. Make sure that the system-wide clock setting
11305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // is updated when the recognition eventually happens
11315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // (http://crbug.com/278601).
11325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  //
11335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Note that it isn't safe to blindly call UpdateClockType() from this
11345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // method, as LoggedInStateChanged() is also called before the logged-in
11355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // user's profile has actually been loaded (http://crbug.com/317745). The
11365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // system tray's time format is updated at login via SetProfile().
11375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (chromeos::UserManager::Get()->IsCurrentUserOwner()) {
11385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    CrosSettings::Get()->SetBoolean(kSystemUse24HourClock,
11395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                    ShouldUse24HourClock());
11405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
11415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
11425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from SessionManagerClient::Observer.
11445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ScreenIsLocked() {
11455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  screen_locked_ = true;
11465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
11475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
11485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
11495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ScreenIsUnlocked() {
11505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  screen_locked_ = false;
11515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
11525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
11535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
11545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)gfx::NativeWindow SystemTrayDelegateChromeOS::GetNativeWindow() const {
11555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool session_started = ash::Shell::GetInstance()
11565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                             ->session_state_delegate()
11575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                             ->IsActiveUserSessionStarted();
11585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return GetNativeWindowByStatus(GetUserLoginStatus(), session_started);
11595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
11605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
11615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// content::NotificationObserver implementation.
11625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::Observe(
11635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    int type,
11645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const content::NotificationSource& source,
11655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const content::NotificationDetails& details) {
11665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  switch (type) {
11675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: {
11685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      UpgradeDetector* detector =
11695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          content::Source<UpgradeDetector>(source).ptr();
11705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ash::UpdateObserver::UpdateSeverity severity =
11715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          ash::UpdateObserver::UPDATE_NORMAL;
11725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      switch (detector->upgrade_notification_stage()) {
11735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        case UpgradeDetector::UPGRADE_ANNOYANCE_SEVERE:
11745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          severity = ash::UpdateObserver::UPDATE_SEVERE_RED;
11755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          break;
11765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
11775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        case UpgradeDetector::UPGRADE_ANNOYANCE_HIGH:
11785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          severity = ash::UpdateObserver::UPDATE_HIGH_ORANGE;
11795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          break;
11805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
11815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        case UpgradeDetector::UPGRADE_ANNOYANCE_ELEVATED:
11825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          severity = ash::UpdateObserver::UPDATE_LOW_GREEN;
11835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          break;
11845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
11855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        case UpgradeDetector::UPGRADE_ANNOYANCE_LOW:
11865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        default:
11875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          severity = ash::UpdateObserver::UPDATE_NORMAL;
11885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          break;
11895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      }
11905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      GetSystemTrayNotifier()->NotifyUpdateRecommended(severity);
11915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      break;
11925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    }
11935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED: {
11945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      // This notification is also sent on login screen when user avatar
11955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      // is loaded from file.
11965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      if (GetUserLoginStatus() != ash::user::LOGGED_IN_NONE) {
11975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        GetSystemTrayNotifier()->NotifyUserUpdate();
11985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      }
11995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      break;
12005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    }
12015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case chrome::NOTIFICATION_PROFILE_CREATED: {
12025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      SetProfile(content::Source<Profile>(source).ptr());
12035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      registrar_->Remove(this,
12045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                         chrome::NOTIFICATION_PROFILE_CREATED,
12055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                         content::NotificationService::AllSources());
12065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      break;
12075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    }
12085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case chrome::NOTIFICATION_PROFILE_DESTROYED: {
12095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      if (UnsetProfile(content::Source<Profile>(source).ptr())) {
121090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)        registrar_->Remove(this,
12115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                           chrome::NOTIFICATION_PROFILE_DESTROYED,
121290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                           content::NotificationService::AllSources());
12132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      }
12145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      break;
12155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
12165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case chrome::NOTIFICATION_SESSION_STARTED: {
12175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(
12185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          GetUserLoginStatus());
12195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      SetProfile(ProfileManager::GetActiveUserProfile());
12205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      break;
12215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    }
12225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    default:
12235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      NOTREACHED();
12245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
12255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
12265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnLanguageRemapSearchKeyToChanged() {
12285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  search_key_mapped_to_ = user_pref_registrar_->prefs()->GetInteger(
12295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kLanguageRemapSearchKeyTo);
12305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
12315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnAccessibilityModeChanged(
12335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::AccessibilityNotificationVisibility notify) {
12345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyAccessibilityModeChanged(notify);
12355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
12365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdatePerformanceTracing() {
12385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!user_pref_registrar_)
12395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
12405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool value = user_pref_registrar_->prefs()->GetBoolean(
12415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kPerformanceTracingEnabled);
12425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyTracingModeChanged(value);
12435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
12445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from InputMethodManager::Observer.
12465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::InputMethodChanged(
12475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    input_method::InputMethodManager* manager,
12485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    bool show_message) {
1249a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyRefreshIME();
1250a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1251a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1252a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Overridden from InputMethodMenuManager::Observer.
1253a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::InputMethodMenuItemChanged(
1254a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    ash::ime::InputMethodMenuManager* manager) {
1255a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyRefreshIME();
1256a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1257a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1258a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Overridden from CrasAudioHandler::AudioObserver.
1259a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnOutputVolumeChanged() {
1260a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyAudioOutputVolumeChanged();
1261a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1262a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1263a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnOutputMuteChanged() {
1264a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyAudioOutputMuteChanged();
1265a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1266a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1267a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnInputGainChanged() {
1268a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1269a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1270a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnInputMuteChanged() {
12715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
12725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1273a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnAudioNodesChanged() {
1274a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyAudioNodesChanged();
1275a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1276a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1277a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnActiveOutputNodeChanged() {
1278a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyAudioActiveOutputNodeChanged();
1279a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1280a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1281a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnActiveInputNodeChanged() {
1282a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyAudioActiveInputNodeChanged();
12835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
12845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// drive::JobListObserver overrides.
12865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnJobAdded(const drive::JobInfo& job_info) {
12875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  OnJobUpdated(job_info);
12885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
12895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnJobDone(const drive::JobInfo& job_info,
12915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                           drive::FileError error) {
12925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::DriveOperationStatus status;
12935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (ConvertToFinishedDriveOperationStatus(job_info, error, &status))
12945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    GetSystemTrayNotifier()->NotifyDriveJobUpdated(status);
12955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
12965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnJobUpdated(const drive::JobInfo& job_info) {
12985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::DriveOperationStatus status;
12995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (ConvertToDriveOperationStatus(job_info, &status))
13005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    GetSystemTrayNotifier()->NotifyDriveJobUpdated(status);
13015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)DriveIntegrationService*
13045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SystemTrayDelegateChromeOS::FindDriveIntegrationService() {
13055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return user_profile_
13065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)             ? DriveIntegrationServiceFactory::FindForProfile(user_profile_)
13075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)             : NULL;
13085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from BluetoothAdapter::Observer.
13115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::AdapterPresentChanged(
13125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothAdapter* adapter,
13135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    bool present) {
13145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyRefreshBluetooth();
13155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::AdapterPoweredChanged(
13185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothAdapter* adapter,
13195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    bool powered) {
13205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyRefreshBluetooth();
13215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::AdapterDiscoveringChanged(
13245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothAdapter* adapter,
13255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    bool discovering) {
13265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyBluetoothDiscoveringChanged();
13275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::DeviceAdded(device::BluetoothAdapter* adapter,
13305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                             device::BluetoothDevice* device) {
13315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyRefreshBluetooth();
13325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
13345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::DeviceChanged(
13355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothAdapter* adapter,
13365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothDevice* device) {
13375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyRefreshBluetooth();
13385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
13405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::DeviceRemoved(
13415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothAdapter* adapter,
13425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothDevice* device) {
13435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyRefreshBluetooth();
13445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1346a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnStartBluetoothDiscoverySession(
1347a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    scoped_ptr<device::BluetoothDiscoverySession> discovery_session) {
1348a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // If the discovery session was returned after a request to stop discovery
1349a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // (e.g. the user dismissed the Bluetooth detailed view before the call
1350a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // returned), don't claim the discovery session and let it clean up.
1351a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (!should_run_bluetooth_discovery_)
1352a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return;
1353a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  VLOG(1) << "Claiming new Bluetooth device discovery session.";
1354a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  bluetooth_discovery_session_ = discovery_session.Pass();
1355e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  GetSystemTrayNotifier()->NotifyBluetoothDiscoveringChanged();
13565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
1357868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
13585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateEnterpriseDomain() {
13595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  policy::BrowserPolicyConnectorChromeOS* connector =
13605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      g_browser_process->platform_part()->browser_policy_connector_chromeos();
13615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  std::string enterprise_domain = connector->GetEnterpriseDomain();
13625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (enterprise_domain_ != enterprise_domain) {
13635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    enterprise_domain_ = enterprise_domain;
13645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    GetSystemTrayNotifier()->NotifyEnterpriseDomainChanged();
13654e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  }
13665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
13685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from CloudPolicyStore::Observer
13695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnStoreLoaded(
13705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    policy::CloudPolicyStore* store) {
13715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateEnterpriseDomain();
13725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13734e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
13745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnStoreError(policy::CloudPolicyStore* store) {
13755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateEnterpriseDomain();
13765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from ash::SessionStateObserver
13795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UserAddedToSession(
13805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::string& user_id) {
13815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyUserAddedToSession();
13825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1384a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Overridden from chrome::BrowserListObserver.
1385a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnBrowserRemoved(Browser* browser) {
1386a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  NotifyIfLastWindowClosed();
1387a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1388a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1389a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Overridden from apps::AppWindowRegistry::Observer.
1390a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnAppWindowRemoved(
1391a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    apps::AppWindow* app_window) {
1392a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  NotifyIfLastWindowClosed();
1393a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1394a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1395a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged(
1396a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    const AccessibilityStatusEventDetails& details) {
1397a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN)
1398a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    accessibility_subscription_.reset();
1399a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  else
1400a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    OnAccessibilityModeChanged(details.notify);
1401a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1402a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
14035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
14045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return new SystemTrayDelegateChromeOS();
14055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
14065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace chromeos
1408