system_tray_delegate_chromeos.cc revision cedac228d2dd51db4b79ea1e72c7f249408ee061
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"
65a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "chrome/browser/chromeos/net/network_portal_detector.h"
6690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/chromeos/options/network_config_view.h"
675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.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"
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/google/google_util.h"
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/lifetime/application_lifetime.h"
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/profiles/profile_manager.h"
785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
79cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/ui/ash/user_accounts_delegate_chromeos.h"
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/ash/volume_controller_chromeos.h"
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser.h"
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser_finder.h"
83a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "chrome/browser/ui/browser_list.h"
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/chrome_pages.h"
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/host_desktop.h"
860f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/singleton_tabs.h"
88eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "chrome/browser/ui/tabs/tab_strip_model.h"
895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/ui/webui/chromeos/charger_replacement_handler.h"
903551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/upgrade_detector.h"
92effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "chrome/common/chrome_switches.h"
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/pref_names.h"
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/url_constants.h"
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chromeos/dbus/dbus_thread_manager.h"
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chromeos/dbus/session_manager_client.h"
97c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chromeos/ime/extension_ime_util.h"
98a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#include "chromeos/ime/ime_keyboard.h"
99c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chromeos/ime/input_method_manager.h"
100c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chromeos/login/login_state.h"
101a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "components/policy/core/common/cloud/cloud_policy_store.h"
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_observer.h"
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_service.h"
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/user_metrics.h"
105eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "content/public/browser/web_contents.h"
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "device/bluetooth/bluetooth_adapter.h"
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "device/bluetooth/bluetooth_adapter_factory.h"
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "device/bluetooth/bluetooth_device.h"
1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "grit/ash_strings.h"
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "grit/generated_resources.h"
1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "grit/locale_settings.h"
11290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "net/base/escape.h"
11390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "third_party/cros_system_api/dbus/service_constants.h"
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/l10n/l10n_util.h"
115bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch#include "ui/base/l10n/time_format.h"
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)using drive::DriveIntegrationService;
11890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)using drive::DriveIntegrationServiceFactory;
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace chromeos {
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace {
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// The minimum session length limit that can be set.
1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const int kSessionLengthLimitMinMs = 30 * 1000;  // 30 seconds.
1262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// The maximum session length limit that can be set.
1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000;  // 24 hours.
1292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
130eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochconst char kDisplaySettingsSubPageName[] = "display";
131eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochconst char kDisplayOverscanSettingsSubPageName[] = "displayOverscan";
132eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
133f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// The URL for the Google Drive settings page.
134f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)const char kDriveSettingsPageURL[] = "https://drive.google.com";
135f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime,
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    const input_method::InputMethodUtil& util,
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                    ash::IMEInfo* info) {
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  info->id = ime.id();
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  info->name = util.GetInputMethodLongName(ime);
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  info->medium_name = util.GetInputMethodMediumName(ime);
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  info->short_name = util.GetInputMethodShortName(ime);
143c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  info->third_party = extension_ime_util::IsExtensionIME(ime.id());
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)gfx::NativeWindow GetNativeWindowByStatus(ash::user::LoginStatus login_status,
1475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                          bool session_started) {
1482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  int container_id =
1495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      (!session_started || login_status == ash::user::LOGGED_IN_NONE ||
150c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch       login_status == ash::user::LOGGED_IN_LOCKED)
151c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch          ? ash::kShellWindowId_LockSystemModalContainer
152c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch          : ash::kShellWindowId_SystemModalContainer;
1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(),
1542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                                  container_id);
1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
157c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Converts drive::JobInfo to ash::DriveOperationStatus.
158c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// If the job is not of type that ash tray is interested, returns false.
159c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)bool ConvertToDriveOperationStatus(const drive::JobInfo& info,
160c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                                   ash::DriveOperationStatus* status) {
161c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  if (info.job_type == drive::TYPE_DOWNLOAD_FILE) {
162c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    status->type = ash::DriveOperationStatus::OPERATION_DOWNLOAD;
163c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  } else if (info.job_type == drive::TYPE_UPLOAD_NEW_FILE ||
1645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)             info.job_type == drive::TYPE_UPLOAD_EXISTING_FILE) {
165c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    status->type = ash::DriveOperationStatus::OPERATION_UPLOAD;
166c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  } else {
167c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return false;
168c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
169c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
170c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  if (info.state == drive::STATE_NONE)
171c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    status->state = ash::DriveOperationStatus::OPERATION_NOT_STARTED;
172c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  else
173c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    status->state = ash::DriveOperationStatus::OPERATION_IN_PROGRESS;
174c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
175c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  status->id = info.job_id;
176c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  status->file_path = info.file_path;
177c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  status->progress = info.num_total_bytes == 0 ? 0.0 :
178c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      static_cast<double>(info.num_completed_bytes) /
179c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)          static_cast<double>(info.num_total_bytes);
180c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  return true;
181c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
182c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
183c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Converts drive::JobInfo that has finished in |error| state
184c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// to ash::DriveOperationStatus.
185c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// If the job is not of type that ash tray is interested, returns false.
186c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)bool ConvertToFinishedDriveOperationStatus(const drive::JobInfo& info,
187c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                                           drive::FileError error,
188c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                                           ash::DriveOperationStatus* status) {
189c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  if (!ConvertToDriveOperationStatus(info, status))
190c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return false;
1915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  status->state = (error == drive::FILE_ERROR_OK)
1925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                      ? ash::DriveOperationStatus::OPERATION_COMPLETED
1935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                      : ash::DriveOperationStatus::OPERATION_FAILED;
194c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  return true;
195c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
196c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
197c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Converts a list of drive::JobInfo to a list of ash::DriveOperationStatusList.
198c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)ash::DriveOperationStatusList ConvertToDriveStatusList(
199c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    const std::vector<drive::JobInfo>& list) {
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ash::DriveOperationStatusList results;
201c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  for (size_t i = 0; i < list.size(); ++i) {
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    ash::DriveOperationStatus status;
203c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    if (ConvertToDriveOperationStatus(list[i], &status))
204c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      results.push_back(status);
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return results;
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void BluetoothPowerFailure() {
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(sad): Show an error bubble?
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void BluetoothSetDiscoveringError() {
2142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  LOG(ERROR) << "BluetoothSetDiscovering failed.";
2152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
2162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void BluetoothDeviceConnectError(
2182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    device::BluetoothDevice::ConnectErrorCode error_code) {
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // TODO(sad): Do something?
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
222effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochvoid ShowSettingsSubPageForActiveUser(const std::string& sub_page) {
223effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  chrome::ShowSettingsSubPageForProfile(
224effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch      ProfileManager::GetActiveUserProfile(), sub_page);
2250f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)}
2260f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
2273551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)void ShowNetworkSettingsPage(const std::string& service_path) {
2283551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  std::string page = chrome::kInternetOptionsSubPage;
2294e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  page += "?servicePath=" + net::EscapeUrlEncodedData(service_path, true);
2305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::RecordAction(base::UserMetricsAction("OpenInternetOptionsDialog"));
231effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser(page);
2325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
2335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void OnAcceptMultiprofilesIntro(bool no_show_again) {
2355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
2365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again);
2375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UserAddingScreen::Get()->Start();
2385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
2395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}  // namespace
2415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
2425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS()
2435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    : weak_ptr_factory_(this),
2445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      user_profile_(NULL),
2455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      clock_type_(base::GetHourClockType()),
2465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      search_key_mapped_to_(input_method::kSearchKey),
2475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      screen_locked_(false),
2485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      have_session_start_time_(false),
2495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      have_session_length_limit_(false),
250a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      should_run_bluetooth_discovery_(false),
2515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      volume_control_delegate_(new VolumeController()),
2525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      device_settings_observer_(CrosSettings::Get()->AddSettingsObserver(
2535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          kSystemUse24HourClock,
2545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          base::Bind(&SystemTrayDelegateChromeOS::UpdateClockType,
2555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                     base::Unretained(this)))) {
2565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Register notifications on construction so that events such as
2575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // PROFILE_CREATED do not get missed if they happen before Initialize().
2585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  registrar_.reset(new content::NotificationRegistrar);
2595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  registrar_->Add(this,
2605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
2615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  content::NotificationService::AllSources());
2625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  registrar_->Add(this,
2635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
2645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  content::NotificationService::AllSources());
2655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (GetUserLoginStatus() == ash::user::LOGGED_IN_NONE) {
26690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)    registrar_->Add(this,
2675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                    chrome::NOTIFICATION_SESSION_STARTED,
2685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                    content::NotificationService::AllSources());
2695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
2705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  registrar_->Add(this,
2715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  chrome::NOTIFICATION_PROFILE_CREATED,
2725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  content::NotificationService::AllSources());
2735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  registrar_->Add(this,
2745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  chrome::NOTIFICATION_PROFILE_DESTROYED,
2755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                  content::NotificationService::AllSources());
276a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
277a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
278a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  CHECK(accessibility_manager);
279a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  accessibility_subscription_ = accessibility_manager->RegisterCallback(
280a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged,
281a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                 base::Unretained(this)));
2825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::Initialize() {
2855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodManager::Get()->AddObserver(this);
288a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  ash::ime::InputMethodMenuManager::GetInstance()->AddObserver(this);
2895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateClockType();
2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  device::BluetoothAdapterFactory::GetAdapter(
2925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::InitializeOnAdapterReady,
2935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 weak_ptr_factory_.GetWeakPtr()));
294868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
2955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::Shell::GetInstance()->session_state_delegate()->AddSessionStateObserver(
2965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      this);
29758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
2985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (LoginState::IsInitialized())
2995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    LoginState::Get()->AddObserver(this);
300a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
301a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (CrasAudioHandler::IsInitialized())
302a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    CrasAudioHandler::Get()->AddAudioObserver(this);
303a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
304a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  BrowserList::AddObserver(this);
3055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::Shutdown() {
3085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  device_settings_observer_.reset();
3095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
310c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
3115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::InitializeOnAdapterReady(
3125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    scoped_refptr<device::BluetoothAdapter> adapter) {
3135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bluetooth_adapter_ = adapter;
3145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  CHECK(bluetooth_adapter_.get());
3155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bluetooth_adapter_->AddObserver(this);
3165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  local_state_registrar_.reset(new PrefChangeRegistrar);
3185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  local_state_registrar_->Init(g_browser_process->local_state());
3195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateSessionStartTime();
3215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateSessionLengthLimit();
3225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  local_state_registrar_->Add(
3245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kSessionStartTime,
3255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::UpdateSessionStartTime,
3265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this)));
3275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  local_state_registrar_->Add(
3285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kSessionLengthLimit,
3295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::UpdateSessionLengthLimit,
3305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this)));
3315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  policy::BrowserPolicyConnectorChromeOS* policy_connector =
3335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      g_browser_process->platform_part()->browser_policy_connector_chromeos();
3345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
3355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      policy_connector->GetDeviceCloudPolicyManager();
3365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (policy_manager)
3375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    policy_manager->core()->store()->AddObserver(this);
3385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateEnterpriseDomain();
3395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() {
3425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Unregister PrefChangeRegistrars.
3435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  local_state_registrar_.reset();
3445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_.reset();
3455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
346a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Unregister content notifications before destroying any components.
3475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  registrar_.reset();
3485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
349a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Unregister a11y status subscription.
350a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  accessibility_subscription_.reset();
351a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
3525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this);
3535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodManager::Get()->RemoveObserver(this);
354a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  ash::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this);
3555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bluetooth_adapter_->RemoveObserver(this);
3565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::Shell::GetInstance()
3575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ->session_state_delegate()
3585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ->RemoveSessionStateObserver(this);
3595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  LoginState::Get()->RemoveObserver(this);
3605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
361a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (CrasAudioHandler::IsInitialized())
362a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    CrasAudioHandler::Get()->RemoveAudioObserver(this);
363a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
364a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  BrowserList::RemoveObserver(this);
365a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  StopObservingAppWindowRegistry();
366a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
3675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Stop observing Drive operations.
3685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UnobserveDriveUpdates();
3695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  policy::BrowserPolicyConnectorChromeOS* connector =
3715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      g_browser_process->platform_part()->browser_policy_connector_chromeos();
3725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
3735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      connector->GetDeviceCloudPolicyManager();
3745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (policy_manager)
3755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    policy_manager->core()->store()->RemoveObserver(this);
3765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from ash::SystemTrayDelegate:
3795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetTrayVisibilityOnStartup() {
3805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // In case of OOBE / sign in screen tray will be shown later.
3815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return LoginState::Get()->IsUserLoggedIn();
3825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
3835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ash::user::LoginStatus SystemTrayDelegateChromeOS::GetUserLoginStatus() const {
3855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // All non-logged in ChromeOS specific LOGGED_IN states map to the same
3865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Ash specific LOGGED_IN state.
3875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!LoginState::Get()->IsUserLoggedIn())
3885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return ash::user::LOGGED_IN_NONE;
3895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
3905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (screen_locked_)
3915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return ash::user::LOGGED_IN_LOCKED;
3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  LoginState::LoggedInUserType user_type =
3945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      LoginState::Get()->GetLoggedInUserType();
3955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  switch (user_type) {
3965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_NONE:
3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      return ash::user::LOGGED_IN_NONE;
3985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_REGULAR:
3995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      return ash::user::LOGGED_IN_USER;
4005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_OWNER:
4015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      return ash::user::LOGGED_IN_OWNER;
4025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_GUEST:
4035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      return ash::user::LOGGED_IN_GUEST;
4045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_RETAIL_MODE:
4055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      return ash::user::LOGGED_IN_RETAIL_MODE;
4065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT:
4075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      return ash::user::LOGGED_IN_PUBLIC;
4085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_LOCALLY_MANAGED:
4095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      return ash::user::LOGGED_IN_LOCALLY_MANAGED;
4105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case LoginState::LOGGED_IN_USER_KIOSK_APP:
4115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      return ash::user::LOGGED_IN_KIOSK_APP;
4125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
4135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  NOTREACHED();
4145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return ash::user::LOGGED_IN_NONE;
4155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
416d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
4175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ChangeProfilePicture() {
4185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::RecordAction(
4195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::UserMetricsAction("OpenChangeProfilePictureDialog"));
420effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser(chrome::kChangeProfilePictureSubPage);
4215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
422c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
4235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const std::string SystemTrayDelegateChromeOS::GetEnterpriseDomain() const {
4245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return enterprise_domain_;
4255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const base::string16 SystemTrayDelegateChromeOS::GetEnterpriseMessage() const {
4285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (GetEnterpriseDomain().empty())
4295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return base::string16();
4305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return l10n_util::GetStringFUTF16(IDS_DEVICE_OWNED_BY_NOTICE,
4315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                    base::UTF8ToUTF16(GetEnterpriseDomain()));
4325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const std::string SystemTrayDelegateChromeOS::GetLocallyManagedUserManager()
4355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const {
4365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED)
4375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return std::string();
4385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return UserManager::Get()->GetSupervisedUserManager()->GetManagerDisplayEmail(
4395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      chromeos::UserManager::Get()->GetActiveUser()->email());
4405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const base::string16
4435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SystemTrayDelegateChromeOS::GetLocallyManagedUserManagerName() const {
4445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED)
4455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return base::string16();
4465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return UserManager::Get()->GetSupervisedUserManager()->GetManagerDisplayName(
4475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      chromeos::UserManager::Get()->GetActiveUser()->email());
4485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
449c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
4505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const base::string16 SystemTrayDelegateChromeOS::GetLocallyManagedUserMessage()
4515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const {
4525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED)
4535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return base::string16();
4545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return l10n_util::GetStringFUTF16(
4555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      IDS_USER_IS_LOCALLY_MANAGED_BY_NOTICE,
4565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::UTF8ToUTF16(GetLocallyManagedUserManager()));
4575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
458eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
4595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::SystemShouldUpgrade() const {
4605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return UpgradeDetector::GetInstance()->notify_upgrade();
4615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
462c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
4635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)base::HourClockType SystemTrayDelegateChromeOS::GetHourClockType() const {
4645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return clock_type_;
4655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowSettings() {
468effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser("");
4695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::ShouldShowSettings() {
4725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return UserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings();
4735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowDateSettings() {
4765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::RecordAction(base::UserMetricsAction("ShowDateOptions"));
4775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  std::string sub_page =
4785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      std::string(chrome::kSearchSubPage) + "#" +
4795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME);
4805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Everybody can change the time zone (even though it is a device setting).
481effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser(sub_page);
4825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4833551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
4845c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liuvoid SystemTrayDelegateChromeOS::ShowSetTimeDialog() {
4855c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  SetTimeDialog::ShowDialog(GetNativeWindow());
4865c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu}
4875c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
4885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowNetworkSettings(
4895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::string& service_path) {
4905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!LoginState::Get()->IsUserLoggedIn())
4915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
4925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ShowNetworkSettingsPage(service_path);
4935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowBluetoothSettings() {
4965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(sad): Make this work.
4975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowDisplaySettings() {
5005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::RecordAction(base::UserMetricsAction("ShowDisplayOptions"));
501effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser(kDisplaySettingsSubPageName);
5025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowChromeSlow() {
5055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ScopedTabbedBrowserDisplayer displayer(
5065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ProfileManager::GetPrimaryUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
5075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ShowSlow(displayer.browser());
5085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
509eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
5105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::ShouldShowDisplayNotification() {
5115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Packaged app is not counted as 'last active', so if a browser opening the
5125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // display settings is in background of a packaged app, it will return true.
5135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(mukai): fix this.
5145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  Browser* active_browser =
5155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      chrome::FindLastActiveWithHostDesktopType(chrome::HOST_DESKTOP_TYPE_ASH);
5165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!active_browser)
5175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return true;
518ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch
5195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::WebContents* active_contents =
5205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      active_browser->tab_strip_model()->GetActiveWebContents();
5215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!active_contents)
5225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return true;
5235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GURL visible_url = active_contents->GetLastCommittedURL();
525effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  GURL display_settings_url =
526effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch      chrome::GetSettingsUrl(kDisplaySettingsSubPageName);
527effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  GURL display_overscan_url =
528effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch      chrome::GetSettingsUrl(kDisplayOverscanSettingsSubPageName);
529effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  return (visible_url != display_settings_url &&
530effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch          visible_url != display_overscan_url);
5315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowDriveSettings() {
5345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(tengs): Open the drive-specific settings page once we put it in.
5355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // For now just show Google Drive main page.
5365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ScopedTabbedBrowserDisplayer displayer(
5375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
5385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ShowSingletonTabOverwritingNTP(
5395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      displayer.browser(),
5405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      chrome::GetSingletonTabNavigateParams(displayer.browser(),
5415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                            GURL(kDriveSettingsPageURL)));
5425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowIMESettings() {
5455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog"));
546effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser(chrome::kLanguageOptionsSubPage);
5475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowHelp() {
5505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(),
5515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                             chrome::HOST_DESKTOP_TYPE_ASH,
5525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                             chrome::HELP_SOURCE_MENU);
5535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowAccessibilityHelp() {
5565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ScopedTabbedBrowserDisplayer displayer(
5575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
5585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  accessibility::ShowAccessibilityHelp(displayer.browser());
5595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
560b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
5615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowAccessibilitySettings() {
5625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::RecordAction(base::UserMetricsAction("ShowAccessibilitySettings"));
5635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  std::string sub_page = std::string(chrome::kSearchSubPage) + "#" +
5645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                         l10n_util::GetStringUTF8(
5655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                             IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY);
566effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser(sub_page);
5675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowPublicAccountInfo() {
5705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ScopedTabbedBrowserDisplayer displayer(
5715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
5725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::ShowPolicy(displayer.browser());
5735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
5755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowLocallyManagedUserInfo() {
5765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(antrim): find out what should we show in this case.
5775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // http://crbug.com/229762
5785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
5795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
5805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowEnterpriseInfo() {
5815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::user::LoginStatus status = GetUserLoginStatus();
5825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (status == ash::user::LOGGED_IN_NONE ||
5835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      status == ash::user::LOGGED_IN_LOCKED) {
5845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    scoped_refptr<chromeos::HelpAppLauncher> help_app(
5855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        new chromeos::HelpAppLauncher(GetNativeWindow()));
5865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    help_app->ShowHelpTopic(chromeos::HelpAppLauncher::HELP_ENTERPRISE);
5875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  } else {
5885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    GURL url(google_util::StringAppendGoogleLocaleParam(
5895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        chrome::kLearnMoreEnterpriseURL));
5905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    chrome::ScopedTabbedBrowserDisplayer displayer(
5915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
5925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    chrome::ShowSingletonTab(displayer.browser(), url);
593c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  }
5945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
595c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
5965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowUserLogin() {
5975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::Shell* shell = ash::Shell::GetInstance();
5985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!shell->delegate()->IsMultiProfilesEnabled())
5995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
6005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
6015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Only regular users could add other users to current session.
6025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (UserManager::Get()->GetActiveUser()->GetType() !=
6035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      User::USER_TYPE_REGULAR) {
6045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
6055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
6065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
6075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (static_cast<int>(UserManager::Get()->GetLoggedInUsers().size()) >=
6085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers())
6095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
6105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
6115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Launch sign in screen to add another user to current session.
6125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (UserManager::Get()->GetUsersAdmittedForMultiProfile().size()) {
6135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // Don't show dialog if any logged in user in multi-profiles session
6145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // dismissed it.
6155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    bool show_intro = true;
6165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const UserList logged_in_users = UserManager::Get()->GetLoggedInUsers();
6175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    for (UserList::const_iterator it = logged_in_users.begin();
6185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)         it != logged_in_users.end();
6195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)         ++it) {
6205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      show_intro &= !multi_user_util::GetProfileFromUserID(
6215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                         multi_user_util::GetUserIDFromEmail((*it)->email()))
6225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                         ->GetPrefs()
6235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                         ->GetBoolean(prefs::kMultiProfileNeverShowIntro);
6245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      if (!show_intro)
6255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        break;
6265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    }
6275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    if (show_intro) {
6285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Callback<void(bool)> on_accept =
6295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          base::Bind(&OnAcceptMultiprofilesIntro);
6305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ShowMultiprofilesIntroDialog(on_accept);
6312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    } else {
6325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      UserAddingScreen::Get()->Start();
6332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    }
6342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
6355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
6362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
6375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::ShowSpringChargerReplacementDialog() {
6385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!ChargerReplacementDialog::ShouldShowDialog())
6395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return false;
640c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
6415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ChargerReplacementDialog* dialog =
6425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      new ChargerReplacementDialog(GetNativeWindow());
6435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  dialog->Show();
6445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return true;
6455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
646c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
6475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::IsSpringChargerReplacementDialogVisible() {
6485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return ChargerReplacementDialog::IsDialogVisible();
6495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
650c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
6515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::HasUserConfirmedSafeSpringCharger() {
6525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return ChargerReplacementHandler::GetChargerStatusPref() ==
6535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)         ChargerReplacementHandler::CONFIRM_SAFE_CHARGER;
6545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
655c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
6565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShutDown() {
6575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::Shell::GetInstance()->lock_state_controller()->RequestShutdown();
6585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
6595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::SignOut() {
6615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::AttemptUserExit();
6625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
6635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::RequestLockScreen() {
6655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(antrim) : additional logging for crbug/173178
6665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  LOG(WARNING) << "Requesting screen lock from AshSystemTrayDelegate";
6675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen();
6685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
6695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::RequestRestartForUpdate() {
6715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // We expect that UpdateEngine is in "Reboot for update" state now.
6725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  chrome::NotifyAndTerminate(true /* fast path */);
6735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
6745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::GetAvailableBluetoothDevices(
6765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::BluetoothDeviceList* list) {
6775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  device::BluetoothAdapter::DeviceList devices =
6785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      bluetooth_adapter_->GetDevices();
6795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  for (size_t i = 0; i < devices.size(); ++i) {
6805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothDevice* device = devices[i];
6815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::BluetoothDeviceInfo info;
6825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    info.address = device->GetAddress();
6835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    info.display_name = device->GetName();
6845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    info.connected = device->IsConnected();
6855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    info.connecting = device->IsConnecting();
6865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    info.paired = device->IsPaired();
6875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    list->push_back(info);
6885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
6895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
6905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::BluetoothStartDiscovering() {
692e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  if (GetBluetoothDiscovering()) {
693a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    LOG(WARNING) << "Already have active Bluetooth device discovery session.";
694a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return;
695a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
696a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  VLOG(1) << "Requesting new Bluetooth device discovery session.";
697a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  should_run_bluetooth_discovery_ = true;
698a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  bluetooth_adapter_->StartDiscoverySession(
699a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::OnStartBluetoothDiscoverySession,
700a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                 weak_ptr_factory_.GetWeakPtr()),
701a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      base::Bind(&BluetoothSetDiscoveringError));
7025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
7045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::BluetoothStopDiscovering() {
705a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  should_run_bluetooth_discovery_ = false;
706e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  if (!GetBluetoothDiscovering()) {
707a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    LOG(WARNING) << "No active Bluetooth device discovery session.";
708a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return;
709a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
710a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  VLOG(1) << "Stopping Bluetooth device discovery session.";
711a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  bluetooth_discovery_session_->Stop(
7125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&base::DoNothing), base::Bind(&BluetoothSetDiscoveringError));
7135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
7155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ConnectToBluetoothDevice(
7165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::string& address) {
7175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  device::BluetoothDevice* device = bluetooth_adapter_->GetDevice(address);
7185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!device || device->IsConnecting() ||
7195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      (device->IsConnected() && device->IsPaired())) {
7205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
7215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  }
7225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (device->IsPaired() && !device->IsConnectable())
7235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
7245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (device->IsPaired() || !device->IsPairable()) {
7255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction(
7265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        ash::UMA_STATUS_AREA_BLUETOOTH_CONNECT_KNOWN_DEVICE);
7275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device->Connect(NULL,
7285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                    base::Bind(&base::DoNothing),
7295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                    base::Bind(&BluetoothDeviceConnectError));
7305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  } else {  // Show paring dialog for the unpaired device.
7315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction(
7325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        ash::UMA_STATUS_AREA_BLUETOOTH_CONNECT_UNKNOWN_DEVICE);
7335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    BluetoothPairingDialog* dialog =
7345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        new BluetoothPairingDialog(GetNativeWindow(), device);
7355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    // The dialog deletes itself on close.
7365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    dialog->Show();
7375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
7385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::IsBluetoothDiscovering() {
7415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return bluetooth_adapter_->IsDiscovering();
7425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::GetCurrentIME(ash::IMEInfo* info) {
7455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodManager* manager =
7465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      input_method::InputMethodManager::Get();
7475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodUtil* util = manager->GetInputMethodUtil();
7485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodDescriptor ime = manager->GetCurrentInputMethod();
7495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ExtractIMEInfo(ime, *util, info);
7505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  info->selected = true;
7515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::GetAvailableIMEList(ash::IMEInfoList* list) {
7545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodManager* manager =
7555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      input_method::InputMethodManager::Get();
7565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodUtil* util = manager->GetInputMethodUtil();
7575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_ptr<input_method::InputMethodDescriptors> ime_descriptors(
7585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      manager->GetActiveInputMethods());
7595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  std::string current = manager->GetCurrentInputMethod().id();
7605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  for (size_t i = 0; i < ime_descriptors->size(); i++) {
7615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    input_method::InputMethodDescriptor& ime = ime_descriptors->at(i);
7625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::IMEInfo info;
7635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ExtractIMEInfo(ime, *util, &info);
7645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    info.selected = ime.id() == current;
7655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    list->push_back(info);
7665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
7675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::GetCurrentIMEProperties(
7705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::IMEPropertyInfoList* list) {
771a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  ash::ime::InputMethodMenuItemList menu_list =
772a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      ash::ime::InputMethodMenuManager::GetInstance()->
773a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      GetCurrentInputMethodMenuItemList();
774a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  for (size_t i = 0; i < menu_list.size(); ++i) {
7755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::IMEPropertyInfo property;
776a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    property.key = menu_list[i].key;
777a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    property.name = base::UTF8ToUTF16(menu_list[i].label);
778a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    property.selected = menu_list[i].is_selection_item_checked;
7795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    list->push_back(property);
7805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
7815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::SwitchIME(const std::string& ime_id) {
7845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  input_method::InputMethodManager::Get()->ChangeInputMethod(ime_id);
7855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ActivateIMEProperty(const std::string& key) {
788a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  input_method::InputMethodManager::Get()->ActivateInputMethodMenuItem(key);
7895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::CancelDriveOperation(int32 operation_id) {
7925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DriveIntegrationService* integration_service = FindDriveIntegrationService();
7935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!integration_service)
7945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
7955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  integration_service->job_list()->CancelJob(operation_id);
7975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
7985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::GetDriveOperationStatusList(
8005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::DriveOperationStatusList* list) {
8015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DriveIntegrationService* integration_service = FindDriveIntegrationService();
8025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!integration_service)
8035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
8045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  *list = ConvertToDriveStatusList(
8065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      integration_service->job_list()->GetJobInfoList());
8075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowNetworkConfigure(
8105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::string& network_id,
8115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    gfx::NativeWindow parent_window) {
8125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  NetworkConfigView::Show(network_id, parent_window);
8135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::EnrollNetwork(
8165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::string& network_id,
8175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    gfx::NativeWindow parent_window) {
8185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return enrollment::CreateDialog(network_id, parent_window);
8195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ManageBluetoothDevices() {
8225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  content::RecordAction(base::UserMetricsAction("ShowBluetoothSettingsPage"));
8235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  std::string sub_page =
8245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      std::string(chrome::kSearchSubPage) + "#" +
8255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH);
826effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  ShowSettingsSubPageForActiveUser(sub_page);
8275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ToggleBluetooth() {
8305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bluetooth_adapter_->SetPowered(!bluetooth_adapter_->IsPowered(),
8315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                 base::Bind(&base::DoNothing),
8325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                 base::Bind(&BluetoothPowerFailure));
8335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowMobileSimDialog() {
8365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  SimDialogDelegate::ShowDialog(GetNativeWindow(),
8375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                SimDialogDelegate::SIM_DIALOG_UNLOCK);
8385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
83990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
8405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowMobileSetupDialog(
8415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::string& service_path) {
8425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  MobileSetupDialog::Show(service_path);
8435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
844ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch
8455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowOtherNetworkDialog(
8465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::string& type) {
8475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (type == shill::kTypeCellular) {
8485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow());
8495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
8505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
8515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  NetworkConfigView::ShowForType(type, GetNativeWindow());
8525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetBluetoothAvailable() {
8555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return bluetooth_adapter_->IsPresent();
8565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetBluetoothEnabled() {
8595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return bluetooth_adapter_->IsPowered();
8605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
862e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochbool SystemTrayDelegateChromeOS::GetBluetoothDiscovering() {
863e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  return (bluetooth_discovery_session_.get() &&
864e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch      bluetooth_discovery_session_->IsActive());
865e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch}
866e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch
8675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ChangeProxySettings() {
8685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  CHECK(GetUserLoginStatus() == ash::user::LOGGED_IN_NONE);
8695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  LoginDisplayHostImpl::default_host()->OpenProxySettings();
8705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ash::VolumeControlDelegate*
8735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SystemTrayDelegateChromeOS::GetVolumeControlDelegate() const {
8745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return volume_control_delegate_.get();
8755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::SetVolumeControlDelegate(
8785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    scoped_ptr<ash::VolumeControlDelegate> delegate) {
8795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  volume_control_delegate_.swap(delegate);
8805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetSessionStartTime(
8835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    base::TimeTicks* session_start_time) {
8845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  *session_start_time = session_start_time_;
8855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return have_session_start_time_;
8865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
8885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetSessionLengthLimit(
8895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    base::TimeDelta* session_length_limit) {
8905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  *session_length_limit = session_length_limit_;
8915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return have_session_length_limit_;
8925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
8945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)int SystemTrayDelegateChromeOS::GetSystemTrayMenuWidth() {
8955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return l10n_util::GetLocalizedContentsWidthInPixels(
8965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      IDS_SYSTEM_TRAY_MENU_BUBBLE_WIDTH_PIXELS);
8975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
8982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
8995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ActiveUserWasChanged() {
9005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyUserUpdate();
9015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
9022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
903a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool SystemTrayDelegateChromeOS::IsNetworkBehindCaptivePortal(
904a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    const std::string& service_path) const {
905a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  NetworkPortalDetector::CaptivePortalState state =
906a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      NetworkPortalDetector::Get()->GetCaptivePortalState(service_path);
907a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL;
908a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
909a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
910a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool SystemTrayDelegateChromeOS::IsSearchKeyMappedToCapsLock() {
911a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  return search_key_mapped_to_ == input_method::kCapsLockKey;
912a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
913a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
914a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochash::tray::UserAccountsDelegate*
915a02191e04bc25c4935f804f2c080ae28663d096dBen MurdochSystemTrayDelegateChromeOS::GetUserAccountsDelegate(
916a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    const std::string& user_id) {
917a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  if (!accounts_delegates_.contains(user_id)) {
918cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    const User* user = UserManager::Get()->FindUser(user_id);
919cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    Profile* user_profile = UserManager::Get()->GetProfileByUser(user);
920cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    CHECK(user_profile);
921cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)    accounts_delegates_.set(
922cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)        user_id,
923cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)        scoped_ptr<ash::tray::UserAccountsDelegate>(
924cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)            new UserAccountsDelegateChromeOS(user_profile)));
925a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  }
926a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  return accounts_delegates_.get(user_id);
927a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch}
928a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
9295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ash::SystemTray* SystemTrayDelegateChromeOS::GetPrimarySystemTray() {
9305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return ash::Shell::GetInstance()->GetPrimarySystemTray();
9315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
9325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() {
9345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return ash::Shell::GetInstance()->system_tray_notifier();
9355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
9365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) {
938a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Stop observing the Drive integration status and the AppWindowRegistry of
939a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // the current |user_profile_|.
9405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UnobserveDriveUpdates();
941a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  StopObservingAppWindowRegistry();
9425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
9435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_profile_ = profile;
9445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
945a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Start observing the Drive integration status and the AppWindowRegistry of
946a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // the newly set |user_profile_|.
9475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ObserveDriveUpdates();
948a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  apps::AppWindowRegistry::Get(user_profile_)->AddObserver(this);
9495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
9505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  PrefService* prefs = profile->GetPrefs();
9515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_.reset(new PrefChangeRegistrar);
9525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Init(prefs);
9535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
9545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kUse24HourClock,
9555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::UpdateClockType,
9565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this)));
9575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
9585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kLanguageRemapSearchKeyTo,
9595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::OnLanguageRemapSearchKeyToChanged,
9605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this)));
9615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
9625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kShowLogoutButtonInTray,
9635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray,
9645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this)));
9655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
9665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kLogoutDialogDurationMs,
9675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration,
9685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this)));
9695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
9705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kLargeCursorEnabled,
9715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityModeChanged,
9725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this),
9735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 ash::A11Y_NOTIFICATION_NONE));
9745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
9755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kAutoclickEnabled,
9765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityModeChanged,
9775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this),
9785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 ash::A11Y_NOTIFICATION_NONE));
9795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
9805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kShouldAlwaysShowAccessibilityMenu,
9815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityModeChanged,
9825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this),
9835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 ash::A11Y_NOTIFICATION_NONE));
9845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_->Add(
9855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kPerformanceTracingEnabled,
9865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::Bind(&SystemTrayDelegateChromeOS::UpdatePerformanceTracing,
9875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 base::Unretained(this)));
9885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
9895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateClockType();
9905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateShowLogoutButtonInTray();
9915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateLogoutDialogDuration();
9925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdatePerformanceTracing();
9935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  search_key_mapped_to_ =
9945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      profile->GetPrefs()->GetInteger(prefs::kLanguageRemapSearchKeyTo);
9955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
99690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
9975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::UnsetProfile(Profile* profile) {
9985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (profile != user_profile_)
9995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return false;
10005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref_registrar_.reset();
1001a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  user_profile_ = NULL;
10025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return true;
10035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
10045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ObserveDriveUpdates() {
10065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DriveIntegrationService* integration_service = FindDriveIntegrationService();
10075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (integration_service)
10085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    integration_service->job_list()->AddObserver(this);
10095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
10107dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
10115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UnobserveDriveUpdates() {
10125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DriveIntegrationService* integration_service = FindDriveIntegrationService();
10135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (integration_service)
10145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    integration_service->job_list()->RemoveObserver(this);
10155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
1016bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch
10175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetShouldUse24HourClockForTesting() const {
10185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return ShouldUse24HourClock();
10195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
10202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
10215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::ShouldUse24HourClock() const {
10225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // On login screen and in guest mode owner default is used for
10235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // kUse24HourClock preference.
10245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const ash::user::LoginStatus status = GetUserLoginStatus();
10255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const CrosSettings* const cros_settings = CrosSettings::Get();
10265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool system_use_24_hour_clock = true;
10275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const bool system_value_found = cros_settings->GetBoolean(
10285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      kSystemUse24HourClock, &system_use_24_hour_clock);
10295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
10305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if ((status == ash::user::LOGGED_IN_NONE) || !user_pref_registrar_)
10315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return (system_value_found
10325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                ? system_use_24_hour_clock
10335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                : (base::GetHourClockType() == base::k24HourClock));
10345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
10355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const PrefService::Preference* user_pref =
10365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      user_pref_registrar_->prefs()->FindPreference(prefs::kUse24HourClock);
10375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (status == ash::user::LOGGED_IN_GUEST && user_pref->IsDefaultValue())
10385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return (system_value_found
10395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                ? system_use_24_hour_clock
10405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                : (base::GetHourClockType() == base::k24HourClock));
10415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
10425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool use_24_hour_clock = true;
10435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_pref->GetValue()->GetAsBoolean(&use_24_hour_clock);
10445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return use_24_hour_clock;
10455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
10465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateClockType() {
10485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const bool use_24_hour_clock = ShouldUse24HourClock();
10495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock;
10505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyDateFormatChanged();
10515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // This also works for enterprise-managed devices because they never have
10525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // local owner.
10535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (chromeos::UserManager::Get()->IsCurrentUserOwner())
10545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, use_24_hour_clock);
10555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
10565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() {
10585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyShowLoginButtonChanged(
10595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      user_pref_registrar_->prefs()->GetBoolean(
10605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          prefs::kShowLogoutButtonInTray));
10615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
10625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() {
10645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const int duration_ms =
10655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      user_pref_registrar_->prefs()->GetInteger(prefs::kLogoutDialogDurationMs);
10665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyLogoutDialogDurationChanged(
10675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      base::TimeDelta::FromMilliseconds(duration_ms));
10685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
106958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
10705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateSessionStartTime() {
10715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const PrefService* local_state = local_state_registrar_->prefs();
10725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (local_state->HasPrefPath(prefs::kSessionStartTime)) {
10735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    have_session_start_time_ = true;
10745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    session_start_time_ = base::TimeTicks::FromInternalValue(
10755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        local_state->GetInt64(prefs::kSessionStartTime));
10765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  } else {
10775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    have_session_start_time_ = false;
10785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    session_start_time_ = base::TimeTicks();
10795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
10805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifySessionStartTimeChanged();
10815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
10825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateSessionLengthLimit() {
10845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  const PrefService* local_state = local_state_registrar_->prefs();
10855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (local_state->HasPrefPath(prefs::kSessionLengthLimit)) {
10865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    have_session_length_limit_ = true;
10875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    session_length_limit_ = base::TimeDelta::FromMilliseconds(
10885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        std::min(std::max(local_state->GetInteger(prefs::kSessionLengthLimit),
10895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                          kSessionLengthLimitMinMs),
10905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                 kSessionLengthLimitMaxMs));
10915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  } else {
10925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    have_session_length_limit_ = false;
10935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    session_length_limit_ = base::TimeDelta();
10945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
10955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifySessionLengthLimitChanged();
10965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
10975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1098a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::StopObservingAppWindowRegistry() {
1099a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (!user_profile_)
1100a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return;
1101a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1102a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  apps::AppWindowRegistry* registry =
1103a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      apps::AppWindowRegistry::Factory::GetForBrowserContext(user_profile_,
1104a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                                                             false);
1105a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (registry)
1106a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    registry->RemoveObserver(this);
1107a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1108a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1109a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::NotifyIfLastWindowClosed() {
1110a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (!user_profile_)
1111a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return;
1112a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1113a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  BrowserList* browser_list =
1114a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
1115a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  for (BrowserList::const_iterator it = browser_list->begin();
1116a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)       it != browser_list->end();
1117a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)       ++it) {
1118a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    if ((*it)->profile()->IsSameProfile(user_profile_)) {
1119a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      // The current user has at least one open browser window.
1120a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)      return;
1121a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    }
1122a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
1123a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1124a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (!apps::AppWindowRegistry::Get(user_profile_)->app_windows().empty()) {
1125a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    // The current user has at least one open app window.
1126a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return;
1127a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  }
1128a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1129a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyLastWindowClosed();
1130a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1131a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
11325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// LoginState::Observer overrides.
11335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::LoggedInStateChanged() {
11345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // It apparently sometimes takes a while after login before the current user
11355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // is recognized as the owner. Make sure that the system-wide clock setting
11365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // is updated when the recognition eventually happens
11375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // (http://crbug.com/278601).
11385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  //
11395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Note that it isn't safe to blindly call UpdateClockType() from this
11405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // method, as LoggedInStateChanged() is also called before the logged-in
11415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // user's profile has actually been loaded (http://crbug.com/317745). The
11425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // system tray's time format is updated at login via SetProfile().
11435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (chromeos::UserManager::Get()->IsCurrentUserOwner()) {
11445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    CrosSettings::Get()->SetBoolean(kSystemUse24HourClock,
11455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                    ShouldUse24HourClock());
11465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
11475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
11485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from SessionManagerClient::Observer.
11505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ScreenIsLocked() {
11515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  screen_locked_ = true;
11525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
11535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
11545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
11555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ScreenIsUnlocked() {
11565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  screen_locked_ = false;
11575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
11585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
11595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
11605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)gfx::NativeWindow SystemTrayDelegateChromeOS::GetNativeWindow() const {
11615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool session_started = ash::Shell::GetInstance()
11625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                             ->session_state_delegate()
11635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                             ->IsActiveUserSessionStarted();
11645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return GetNativeWindowByStatus(GetUserLoginStatus(), session_started);
11655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
11665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
11675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// content::NotificationObserver implementation.
11685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::Observe(
11695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    int type,
11705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const content::NotificationSource& source,
11715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const content::NotificationDetails& details) {
11725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  switch (type) {
11735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: {
11745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      UpgradeDetector* detector =
11755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          content::Source<UpgradeDetector>(source).ptr();
11765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ash::UpdateObserver::UpdateSeverity severity =
11775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          ash::UpdateObserver::UPDATE_NORMAL;
11785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      switch (detector->upgrade_notification_stage()) {
11795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        case UpgradeDetector::UPGRADE_ANNOYANCE_SEVERE:
11805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          severity = ash::UpdateObserver::UPDATE_SEVERE_RED;
11815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          break;
11825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
11835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        case UpgradeDetector::UPGRADE_ANNOYANCE_HIGH:
11845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          severity = ash::UpdateObserver::UPDATE_HIGH_ORANGE;
11855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          break;
11865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
11875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        case UpgradeDetector::UPGRADE_ANNOYANCE_ELEVATED:
11885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          severity = ash::UpdateObserver::UPDATE_LOW_GREEN;
11895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          break;
11905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
11915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        case UpgradeDetector::UPGRADE_ANNOYANCE_LOW:
11925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        default:
11935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          severity = ash::UpdateObserver::UPDATE_NORMAL;
11945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          break;
11955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      }
11965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      GetSystemTrayNotifier()->NotifyUpdateRecommended(severity);
11975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      break;
11985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    }
11995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED: {
12005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      // This notification is also sent on login screen when user avatar
12015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      // is loaded from file.
12025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      if (GetUserLoginStatus() != ash::user::LOGGED_IN_NONE) {
12035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)        GetSystemTrayNotifier()->NotifyUserUpdate();
12045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      }
12055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      break;
12065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    }
12075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case chrome::NOTIFICATION_PROFILE_CREATED: {
12085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      SetProfile(content::Source<Profile>(source).ptr());
12095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      registrar_->Remove(this,
12105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                         chrome::NOTIFICATION_PROFILE_CREATED,
12115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                         content::NotificationService::AllSources());
12125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      break;
12135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    }
12145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case chrome::NOTIFICATION_PROFILE_DESTROYED: {
12155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      if (UnsetProfile(content::Source<Profile>(source).ptr())) {
121690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)        registrar_->Remove(this,
12175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                           chrome::NOTIFICATION_PROFILE_DESTROYED,
121890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                           content::NotificationService::AllSources());
12192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      }
12205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      break;
12215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
12225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    case chrome::NOTIFICATION_SESSION_STARTED: {
12235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(
12245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)          GetUserLoginStatus());
12255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      SetProfile(ProfileManager::GetActiveUserProfile());
12265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      break;
12275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    }
12285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    default:
12295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      NOTREACHED();
12305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
12315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
12325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnLanguageRemapSearchKeyToChanged() {
12345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  search_key_mapped_to_ = user_pref_registrar_->prefs()->GetInteger(
12355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kLanguageRemapSearchKeyTo);
12365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
12375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnAccessibilityModeChanged(
12395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ash::AccessibilityNotificationVisibility notify) {
12405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyAccessibilityModeChanged(notify);
12415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
12425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdatePerformanceTracing() {
12445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (!user_pref_registrar_)
12455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    return;
12465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  bool value = user_pref_registrar_->prefs()->GetBoolean(
12475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      prefs::kPerformanceTracingEnabled);
12485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyTracingModeChanged(value);
12495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
12505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from InputMethodManager::Observer.
12525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::InputMethodChanged(
12535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    input_method::InputMethodManager* manager,
12545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    bool show_message) {
1255a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyRefreshIME();
1256a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1257a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1258a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Overridden from InputMethodMenuManager::Observer.
1259a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::InputMethodMenuItemChanged(
1260a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    ash::ime::InputMethodMenuManager* manager) {
1261a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyRefreshIME();
1262a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1263a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1264a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Overridden from CrasAudioHandler::AudioObserver.
1265a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnOutputVolumeChanged() {
1266a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyAudioOutputVolumeChanged();
1267a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1268a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1269a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnOutputMuteChanged() {
1270a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyAudioOutputMuteChanged();
1271a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1272a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1273a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnInputGainChanged() {
1274a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1275a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1276a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnInputMuteChanged() {
12775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
12785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1279a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnAudioNodesChanged() {
1280a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyAudioNodesChanged();
1281a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1282a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1283a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnActiveOutputNodeChanged() {
1284a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyAudioActiveOutputNodeChanged();
1285a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1286a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1287a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnActiveInputNodeChanged() {
1288a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyAudioActiveInputNodeChanged();
12895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
12905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// drive::JobListObserver overrides.
12925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnJobAdded(const drive::JobInfo& job_info) {
12935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  OnJobUpdated(job_info);
12945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
12955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnJobDone(const drive::JobInfo& job_info,
12975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                           drive::FileError error) {
12985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::DriveOperationStatus status;
12995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (ConvertToFinishedDriveOperationStatus(job_info, error, &status))
13005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    GetSystemTrayNotifier()->NotifyDriveJobUpdated(status);
13015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnJobUpdated(const drive::JobInfo& job_info) {
13045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ash::DriveOperationStatus status;
13055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (ConvertToDriveOperationStatus(job_info, &status))
13065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    GetSystemTrayNotifier()->NotifyDriveJobUpdated(status);
13075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)DriveIntegrationService*
13105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SystemTrayDelegateChromeOS::FindDriveIntegrationService() {
13115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return user_profile_
13125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)             ? DriveIntegrationServiceFactory::FindForProfile(user_profile_)
13135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)             : NULL;
13145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from BluetoothAdapter::Observer.
13175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::AdapterPresentChanged(
13185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothAdapter* adapter,
13195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    bool present) {
13205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyRefreshBluetooth();
13215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::AdapterPoweredChanged(
13245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothAdapter* adapter,
13255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    bool powered) {
13265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyRefreshBluetooth();
13275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::AdapterDiscoveringChanged(
13305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothAdapter* adapter,
13315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    bool discovering) {
13325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyBluetoothDiscoveringChanged();
13335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::DeviceAdded(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::DeviceChanged(
13415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothAdapter* adapter,
13425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothDevice* device) {
13435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyRefreshBluetooth();
13445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
13465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::DeviceRemoved(
13475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothAdapter* adapter,
13485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    device::BluetoothDevice* device) {
13495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyRefreshBluetooth();
13505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1352a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnStartBluetoothDiscoverySession(
1353a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    scoped_ptr<device::BluetoothDiscoverySession> discovery_session) {
1354a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // If the discovery session was returned after a request to stop discovery
1355a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // (e.g. the user dismissed the Bluetooth detailed view before the call
1356a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // returned), don't claim the discovery session and let it clean up.
1357a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (!should_run_bluetooth_discovery_)
1358a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    return;
1359a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  VLOG(1) << "Claiming new Bluetooth device discovery session.";
1360a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  bluetooth_discovery_session_ = discovery_session.Pass();
1361e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch  GetSystemTrayNotifier()->NotifyBluetoothDiscoveringChanged();
13625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
1363868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
13645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateEnterpriseDomain() {
13655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  policy::BrowserPolicyConnectorChromeOS* connector =
13665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      g_browser_process->platform_part()->browser_policy_connector_chromeos();
13675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  std::string enterprise_domain = connector->GetEnterpriseDomain();
13685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  if (enterprise_domain_ != enterprise_domain) {
13695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    enterprise_domain_ = enterprise_domain;
13705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    GetSystemTrayNotifier()->NotifyEnterpriseDomainChanged();
13714e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  }
13725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
13745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from CloudPolicyStore::Observer
13755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnStoreLoaded(
13765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    policy::CloudPolicyStore* store) {
13775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateEnterpriseDomain();
13785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13794e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
13805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnStoreError(policy::CloudPolicyStore* store) {
13815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  UpdateEnterpriseDomain();
13825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
13845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from ash::SessionStateObserver
13855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UserAddedToSession(
13865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::string& user_id) {
13875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  GetSystemTrayNotifier()->NotifyUserAddedToSession();
13885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
13895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1390a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Overridden from chrome::BrowserListObserver.
1391a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnBrowserRemoved(Browser* browser) {
1392a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  NotifyIfLastWindowClosed();
1393a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1394a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1395a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Overridden from apps::AppWindowRegistry::Observer.
1396a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnAppWindowRemoved(
1397a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    apps::AppWindow* app_window) {
1398a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  NotifyIfLastWindowClosed();
1399a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1400a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
1401a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged(
1402a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    const AccessibilityStatusEventDetails& details) {
1403a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN)
1404a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    accessibility_subscription_.reset();
1405a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  else
1406a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    OnAccessibilityModeChanged(details.notify);
1407a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
1408a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
14095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
14105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return new SystemTrayDelegateChromeOS();
14115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
14125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
14135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace chromeos
1414