system_tray_delegate_chromeos.cc revision 5c02ac1a9c1b504631c0a3d2b6e737b5d738bae1
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" 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chromeos/login/login_display_host.h" 59c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/chromeos/login/login_display_host_impl.h" 60c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/browser/chromeos/login/login_wizard.h" 618bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/chromeos/login/supervised_user_manager.h" 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chromeos/login/user.h" 63868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "chrome/browser/chromeos/login/user_adding_screen.h" 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/chromeos/login/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" 75ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch#include "chrome/browser/feedback/tracing_manager.h" 762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/google/google_util.h" 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/lifetime/application_lifetime.h" 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/profiles/profile_manager.h" 795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 80a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#include "chrome/browser/ui/ash/stub_user_accounts_delegate.h" 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/ash/volume_controller_chromeos.h" 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser.h" 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser_finder.h" 84a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "chrome/browser/ui/browser_list.h" 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/chrome_pages.h" 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/host_desktop.h" 870f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/singleton_tabs.h" 89eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "chrome/browser/ui/tabs/tab_strip_model.h" 905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "chrome/browser/ui/webui/chromeos/charger_replacement_handler.h" 913551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h" 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/upgrade_detector.h" 93effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "chrome/common/chrome_switches.h" 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/pref_names.h" 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/url_constants.h" 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chromeos/dbus/dbus_thread_manager.h" 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chromeos/dbus/session_manager_client.h" 98c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chromeos/ime/extension_ime_util.h" 99a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#include "chromeos/ime/ime_keyboard.h" 100c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chromeos/ime/input_method_manager.h" 101c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chromeos/login/login_state.h" 102a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "components/policy/core/common/cloud/cloud_policy_store.h" 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_observer.h" 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_service.h" 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/user_metrics.h" 106eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "content/public/browser/web_contents.h" 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "device/bluetooth/bluetooth_adapter.h" 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "device/bluetooth/bluetooth_adapter_factory.h" 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "device/bluetooth/bluetooth_device.h" 1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "grit/ash_strings.h" 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "grit/generated_resources.h" 1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "grit/locale_settings.h" 11390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "net/base/escape.h" 11490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "third_party/cros_system_api/dbus/service_constants.h" 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/l10n/l10n_util.h" 116bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch#include "ui/base/l10n/time_format.h" 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 11890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)using drive::DriveIntegrationService; 11990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)using drive::DriveIntegrationServiceFactory; 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace chromeos { 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace { 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// The minimum session length limit that can be set. 1262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const int kSessionLengthLimitMinMs = 30 * 1000; // 30 seconds. 1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// The maximum session length limit that can be set. 1292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const int kSessionLengthLimitMaxMs = 24 * 60 * 60 * 1000; // 24 hours. 1302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 131eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochconst char kDisplaySettingsSubPageName[] = "display"; 132eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochconst char kDisplayOverscanSettingsSubPageName[] = "displayOverscan"; 133eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 134f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// The URL for the Google Drive settings page. 135f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)const char kDriveSettingsPageURL[] = "https://drive.google.com"; 136f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const input_method::InputMethodUtil& util, 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ash::IMEInfo* info) { 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) info->id = ime.id(); 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) info->name = util.GetInputMethodLongName(ime); 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) info->medium_name = util.GetInputMethodMediumName(ime); 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) info->short_name = util.GetInputMethodShortName(ime); 144c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) info->third_party = extension_ime_util::IsExtensionIME(ime.id()); 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)gfx::NativeWindow GetNativeWindowByStatus(ash::user::LoginStatus login_status, 1485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool session_started) { 1492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int container_id = 1505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) (!session_started || login_status == ash::user::LOGGED_IN_NONE || 151c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch login_status == ash::user::LOGGED_IN_LOCKED) 152c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ? ash::kShellWindowId_LockSystemModalContainer 153c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch : ash::kShellWindowId_SystemModalContainer; 1542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), 1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) container_id); 1562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 158c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Converts drive::JobInfo to ash::DriveOperationStatus. 159c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// If the job is not of type that ash tray is interested, returns false. 160c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)bool ConvertToDriveOperationStatus(const drive::JobInfo& info, 161c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ash::DriveOperationStatus* status) { 162c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (info.job_type == drive::TYPE_DOWNLOAD_FILE) { 163c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) status->type = ash::DriveOperationStatus::OPERATION_DOWNLOAD; 164c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } else if (info.job_type == drive::TYPE_UPLOAD_NEW_FILE || 1655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) info.job_type == drive::TYPE_UPLOAD_EXISTING_FILE) { 166c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) status->type = ash::DriveOperationStatus::OPERATION_UPLOAD; 167c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } else { 168c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return false; 169c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } 170c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 171c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (info.state == drive::STATE_NONE) 172c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) status->state = ash::DriveOperationStatus::OPERATION_NOT_STARTED; 173c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) else 174c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) status->state = ash::DriveOperationStatus::OPERATION_IN_PROGRESS; 175c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 176c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) status->id = info.job_id; 177c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) status->file_path = info.file_path; 178c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) status->progress = info.num_total_bytes == 0 ? 0.0 : 179c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) static_cast<double>(info.num_completed_bytes) / 180c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) static_cast<double>(info.num_total_bytes); 181c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return true; 182c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 183c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 184c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Converts drive::JobInfo that has finished in |error| state 185c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// to ash::DriveOperationStatus. 186c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// If the job is not of type that ash tray is interested, returns false. 187c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)bool ConvertToFinishedDriveOperationStatus(const drive::JobInfo& info, 188c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) drive::FileError error, 189c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) ash::DriveOperationStatus* status) { 190c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (!ConvertToDriveOperationStatus(info, status)) 191c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return false; 1925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) status->state = (error == drive::FILE_ERROR_OK) 1935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ? ash::DriveOperationStatus::OPERATION_COMPLETED 1945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : ash::DriveOperationStatus::OPERATION_FAILED; 195c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return true; 196c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 197c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 198c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Converts a list of drive::JobInfo to a list of ash::DriveOperationStatusList. 199c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)ash::DriveOperationStatusList ConvertToDriveStatusList( 200c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) const std::vector<drive::JobInfo>& list) { 2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ash::DriveOperationStatusList results; 202c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) for (size_t i = 0; i < list.size(); ++i) { 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ash::DriveOperationStatus status; 204c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (ConvertToDriveOperationStatus(list[i], &status)) 205c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) results.push_back(status); 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return results; 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void BluetoothPowerFailure() { 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(sad): Show an error bubble? 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void BluetoothSetDiscoveringError() { 2152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) LOG(ERROR) << "BluetoothSetDiscovering failed."; 2162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 2172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void BluetoothDeviceConnectError( 2192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) device::BluetoothDevice::ConnectErrorCode error_code) { 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(sad): Do something? 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 223effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochvoid ShowSettingsSubPageForActiveUser(const std::string& sub_page) { 224effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch chrome::ShowSettingsSubPageForProfile( 225effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch ProfileManager::GetActiveUserProfile(), sub_page); 2260f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)} 2270f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles) 2283551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)void ShowNetworkSettingsPage(const std::string& service_path) { 2293551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) std::string page = chrome::kInternetOptionsSubPage; 2304e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) page += "?servicePath=" + net::EscapeUrlEncodedData(service_path, true); 2315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::RecordAction(base::UserMetricsAction("OpenInternetOptionsDialog")); 232effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch ShowSettingsSubPageForActiveUser(page); 2335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void OnAcceptMultiprofilesIntro(bool no_show_again) { 2365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); 2375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again); 2385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UserAddingScreen::Get()->Start(); 2395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace 2425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 2435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() 2445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : weak_ptr_factory_(this), 2455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_profile_(NULL), 2465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) clock_type_(base::GetHourClockType()), 2475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) search_key_mapped_to_(input_method::kSearchKey), 2485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) screen_locked_(false), 2495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) have_session_start_time_(false), 2505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) have_session_length_limit_(false), 251a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) should_run_bluetooth_discovery_(false), 2525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) volume_control_delegate_(new VolumeController()), 2535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) device_settings_observer_(CrosSettings::Get()->AddSettingsObserver( 2545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) kSystemUse24HourClock, 2555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&SystemTrayDelegateChromeOS::UpdateClockType, 2565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Unretained(this)))) { 2575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Register notifications on construction so that events such as 2585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // PROFILE_CREATED do not get missed if they happen before Initialize(). 2595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) registrar_.reset(new content::NotificationRegistrar); 2605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) registrar_->Add(this, 2615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::NOTIFICATION_UPGRADE_RECOMMENDED, 2625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::NotificationService::AllSources()); 2635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) registrar_->Add(this, 2645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 2655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::NotificationService::AllSources()); 2665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (GetUserLoginStatus() == ash::user::LOGGED_IN_NONE) { 26790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) registrar_->Add(this, 2685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::NOTIFICATION_SESSION_STARTED, 2695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::NotificationService::AllSources()); 2705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 2715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) registrar_->Add(this, 2725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::NOTIFICATION_PROFILE_CREATED, 2735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::NotificationService::AllSources()); 2745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) registrar_->Add(this, 2755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::NOTIFICATION_PROFILE_DESTROYED, 2765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::NotificationService::AllSources()); 277a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 278a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); 279a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) CHECK(accessibility_manager); 280a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) accessibility_subscription_ = accessibility_manager->RegisterCallback( 281a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, 282a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::Unretained(this))); 2835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::Initialize() { 2865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); 2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) input_method::InputMethodManager::Get()->AddObserver(this); 289a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ash::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); 2905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateClockType(); 2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) device::BluetoothAdapterFactory::GetAdapter( 2935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&SystemTrayDelegateChromeOS::InitializeOnAdapterReady, 2945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) weak_ptr_factory_.GetWeakPtr())); 295868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 2965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::Shell::GetInstance()->session_state_delegate()->AddSessionStateObserver( 2975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) this); 29858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 2995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (LoginState::IsInitialized()) 3005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) LoginState::Get()->AddObserver(this); 301a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 302a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (CrasAudioHandler::IsInitialized()) 303a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) CrasAudioHandler::Get()->AddAudioObserver(this); 304a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 305a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) BrowserList::AddObserver(this); 3065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::Shutdown() { 3095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) device_settings_observer_.reset(); 3105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 311c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 3125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::InitializeOnAdapterReady( 3135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_refptr<device::BluetoothAdapter> adapter) { 3145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bluetooth_adapter_ = adapter; 3155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CHECK(bluetooth_adapter_.get()); 3165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bluetooth_adapter_->AddObserver(this); 3175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) local_state_registrar_.reset(new PrefChangeRegistrar); 3195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) local_state_registrar_->Init(g_browser_process->local_state()); 3205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateSessionStartTime(); 3225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateSessionLengthLimit(); 3235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) local_state_registrar_->Add( 3255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs::kSessionStartTime, 3265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&SystemTrayDelegateChromeOS::UpdateSessionStartTime, 3275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Unretained(this))); 3285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) local_state_registrar_->Add( 3295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs::kSessionLengthLimit, 3305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&SystemTrayDelegateChromeOS::UpdateSessionLengthLimit, 3315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Unretained(this))); 3325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) policy::BrowserPolicyConnectorChromeOS* policy_connector = 3345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) g_browser_process->platform_part()->browser_policy_connector_chromeos(); 3355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 3365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) policy_connector->GetDeviceCloudPolicyManager(); 3375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (policy_manager) 3385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) policy_manager->core()->store()->AddObserver(this); 3395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateEnterpriseDomain(); 3405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() { 3435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Unregister PrefChangeRegistrars. 3445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) local_state_registrar_.reset(); 3455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref_registrar_.reset(); 3465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 347a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Unregister content notifications before destroying any components. 3485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) registrar_.reset(); 3495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 350a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Unregister a11y status subscription. 351a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) accessibility_subscription_.reset(); 352a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 3535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); 3545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) input_method::InputMethodManager::Get()->RemoveObserver(this); 355a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ash::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); 3565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bluetooth_adapter_->RemoveObserver(this); 3575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::Shell::GetInstance() 3585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ->session_state_delegate() 3595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ->RemoveSessionStateObserver(this); 3605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) LoginState::Get()->RemoveObserver(this); 3615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 362a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (CrasAudioHandler::IsInitialized()) 363a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) CrasAudioHandler::Get()->RemoveAudioObserver(this); 364a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 365a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) BrowserList::RemoveObserver(this); 366a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) StopObservingAppWindowRegistry(); 367a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 3685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Stop observing Drive operations. 3695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UnobserveDriveUpdates(); 3705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) policy::BrowserPolicyConnectorChromeOS* connector = 3725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) g_browser_process->platform_part()->browser_policy_connector_chromeos(); 3735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 3745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) connector->GetDeviceCloudPolicyManager(); 3755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (policy_manager) 3765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) policy_manager->core()->store()->RemoveObserver(this); 3775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from ash::SystemTrayDelegate: 3805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetTrayVisibilityOnStartup() { 3815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // In case of OOBE / sign in screen tray will be shown later. 3825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return LoginState::Get()->IsUserLoggedIn(); 3835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 3845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ash::user::LoginStatus SystemTrayDelegateChromeOS::GetUserLoginStatus() const { 3865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // All non-logged in ChromeOS specific LOGGED_IN states map to the same 3875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Ash specific LOGGED_IN state. 3885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!LoginState::Get()->IsUserLoggedIn()) 3895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ash::user::LOGGED_IN_NONE; 3905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 3915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (screen_locked_) 3925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ash::user::LOGGED_IN_LOCKED; 3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) LoginState::LoggedInUserType user_type = 3955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) LoginState::Get()->GetLoggedInUserType(); 3965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) switch (user_type) { 3975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case LoginState::LOGGED_IN_USER_NONE: 3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return ash::user::LOGGED_IN_NONE; 3995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case LoginState::LOGGED_IN_USER_REGULAR: 4005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ash::user::LOGGED_IN_USER; 4015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case LoginState::LOGGED_IN_USER_OWNER: 4025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ash::user::LOGGED_IN_OWNER; 4035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case LoginState::LOGGED_IN_USER_GUEST: 4045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ash::user::LOGGED_IN_GUEST; 4055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case LoginState::LOGGED_IN_USER_RETAIL_MODE: 4065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ash::user::LOGGED_IN_RETAIL_MODE; 4075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT: 4085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ash::user::LOGGED_IN_PUBLIC; 4095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case LoginState::LOGGED_IN_USER_LOCALLY_MANAGED: 4105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ash::user::LOGGED_IN_LOCALLY_MANAGED; 4115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case LoginState::LOGGED_IN_USER_KIOSK_APP: 4125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ash::user::LOGGED_IN_KIOSK_APP; 4135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 4145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) NOTREACHED(); 4155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ash::user::LOGGED_IN_NONE; 4165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 417d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 4185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ChangeProfilePicture() { 4195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::RecordAction( 4205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::UserMetricsAction("OpenChangeProfilePictureDialog")); 421effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch ShowSettingsSubPageForActiveUser(chrome::kChangeProfilePictureSubPage); 4225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 423c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 4245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const std::string SystemTrayDelegateChromeOS::GetEnterpriseDomain() const { 4255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return enterprise_domain_; 4265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 4272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const base::string16 SystemTrayDelegateChromeOS::GetEnterpriseMessage() const { 4295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (GetEnterpriseDomain().empty()) 4305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return base::string16(); 4315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return l10n_util::GetStringFUTF16(IDS_DEVICE_OWNED_BY_NOTICE, 4325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::UTF8ToUTF16(GetEnterpriseDomain())); 4335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 4342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const std::string SystemTrayDelegateChromeOS::GetLocallyManagedUserManager() 4365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const { 4375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED) 4385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return std::string(); 4395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return UserManager::Get()->GetSupervisedUserManager()->GetManagerDisplayEmail( 4405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chromeos::UserManager::Get()->GetActiveUser()->email()); 4415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 4422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 4435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const base::string16 4445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SystemTrayDelegateChromeOS::GetLocallyManagedUserManagerName() const { 4455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED) 4465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return base::string16(); 4475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return UserManager::Get()->GetSupervisedUserManager()->GetManagerDisplayName( 4485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chromeos::UserManager::Get()->GetActiveUser()->email()); 4495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 450c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 4515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)const base::string16 SystemTrayDelegateChromeOS::GetLocallyManagedUserMessage() 4525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const { 4535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED) 4545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return base::string16(); 4555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return l10n_util::GetStringFUTF16( 4565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) IDS_USER_IS_LOCALLY_MANAGED_BY_NOTICE, 4575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::UTF8ToUTF16(GetLocallyManagedUserManager())); 4585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 459eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 4605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::SystemShouldUpgrade() const { 4615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return UpgradeDetector::GetInstance()->notify_upgrade(); 4625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 463c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 4645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)base::HourClockType SystemTrayDelegateChromeOS::GetHourClockType() const { 4655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return clock_type_; 4665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowSettings() { 469effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch ShowSettingsSubPageForActiveUser(""); 4705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::ShouldShowSettings() { 4735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return UserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings(); 4745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowDateSettings() { 4775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::RecordAction(base::UserMetricsAction("ShowDateOptions")); 4785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::string sub_page = 4795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::string(chrome::kSearchSubPage) + "#" + 4805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME); 4815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Everybody can change the time zone (even though it is a device setting). 482effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch ShowSettingsSubPageForActiveUser(sub_page); 4835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 4843551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 4855c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liuvoid SystemTrayDelegateChromeOS::ShowSetTimeDialog() { 4865c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu SetTimeDialog::ShowDialog(GetNativeWindow()); 4875c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu} 4885c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 4895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowNetworkSettings( 4905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& service_path) { 4915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!LoginState::Get()->IsUserLoggedIn()) 4925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return; 4935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ShowNetworkSettingsPage(service_path); 4945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowBluetoothSettings() { 4975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // TODO(sad): Make this work. 4985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowDisplaySettings() { 5015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::RecordAction(base::UserMetricsAction("ShowDisplayOptions")); 502effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch ShowSettingsSubPageForActiveUser(kDisplaySettingsSubPageName); 5035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 5045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowChromeSlow() { 5065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::ScopedTabbedBrowserDisplayer displayer( 5075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ProfileManager::GetPrimaryUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH); 5085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::ShowSlow(displayer.browser()); 5095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 510eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch 5115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::ShouldShowDisplayNotification() { 5125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Packaged app is not counted as 'last active', so if a browser opening the 5135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // display settings is in background of a packaged app, it will return true. 5145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // TODO(mukai): fix this. 5155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Browser* active_browser = 5165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::FindLastActiveWithHostDesktopType(chrome::HOST_DESKTOP_TYPE_ASH); 5175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!active_browser) 5185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return true; 519ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 5205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::WebContents* active_contents = 5215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) active_browser->tab_strip_model()->GetActiveWebContents(); 5225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!active_contents) 5235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return true; 5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GURL visible_url = active_contents->GetLastCommittedURL(); 526effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch GURL display_settings_url = 527effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch chrome::GetSettingsUrl(kDisplaySettingsSubPageName); 528effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch GURL display_overscan_url = 529effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch chrome::GetSettingsUrl(kDisplayOverscanSettingsSubPageName); 530effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch return (visible_url != display_settings_url && 531effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch visible_url != display_overscan_url); 5325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowDriveSettings() { 5355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // TODO(tengs): Open the drive-specific settings page once we put it in. 5365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // For now just show Google Drive main page. 5375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::ScopedTabbedBrowserDisplayer displayer( 5385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH); 5395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::ShowSingletonTabOverwritingNTP( 5405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) displayer.browser(), 5415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::GetSingletonTabNavigateParams(displayer.browser(), 5425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GURL(kDriveSettingsPageURL))); 5435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 5445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowIMESettings() { 5465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog")); 547effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch ShowSettingsSubPageForActiveUser(chrome::kLanguageOptionsSubPage); 5485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 5495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowHelp() { 5515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(), 5525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::HOST_DESKTOP_TYPE_ASH, 5535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::HELP_SOURCE_MENU); 5545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 5552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowAccessibilityHelp() { 5575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::ScopedTabbedBrowserDisplayer displayer( 5585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH); 5595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) accessibility::ShowAccessibilityHelp(displayer.browser()); 5605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 561b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles) 5625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowAccessibilitySettings() { 5635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::RecordAction(base::UserMetricsAction("ShowAccessibilitySettings")); 5645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::string sub_page = std::string(chrome::kSearchSubPage) + "#" + 5655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) l10n_util::GetStringUTF8( 5665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY); 567effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch ShowSettingsSubPageForActiveUser(sub_page); 5685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 5692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowPublicAccountInfo() { 5715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::ScopedTabbedBrowserDisplayer displayer( 5725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH); 5735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::ShowPolicy(displayer.browser()); 5745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 5755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowLocallyManagedUserInfo() { 5775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // TODO(antrim): find out what should we show in this case. 5785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // http://crbug.com/229762 5795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 5805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 5815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowEnterpriseInfo() { 5825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::user::LoginStatus status = GetUserLoginStatus(); 5835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (status == ash::user::LOGGED_IN_NONE || 5845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) status == ash::user::LOGGED_IN_LOCKED) { 5855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_refptr<chromeos::HelpAppLauncher> help_app( 5865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) new chromeos::HelpAppLauncher(GetNativeWindow())); 5875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) help_app->ShowHelpTopic(chromeos::HelpAppLauncher::HELP_ENTERPRISE); 5885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } else { 5895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GURL url(google_util::StringAppendGoogleLocaleParam( 5905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::kLearnMoreEnterpriseURL)); 5915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::ScopedTabbedBrowserDisplayer displayer( 5925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH); 5935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::ShowSingletonTab(displayer.browser(), url); 594c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) } 5955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 596c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 5975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowUserLogin() { 5985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::Shell* shell = ash::Shell::GetInstance(); 5995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!shell->delegate()->IsMultiProfilesEnabled()) 6005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return; 6015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 6025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Only regular users could add other users to current session. 6035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (UserManager::Get()->GetActiveUser()->GetType() != 6045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) User::USER_TYPE_REGULAR) { 6055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return; 6065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 6075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 6085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (static_cast<int>(UserManager::Get()->GetLoggedInUsers().size()) >= 6095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers()) 6105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return; 6115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 6125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Launch sign in screen to add another user to current session. 6135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (UserManager::Get()->GetUsersAdmittedForMultiProfile().size()) { 6145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Don't show dialog if any logged in user in multi-profiles session 6155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // dismissed it. 6165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool show_intro = true; 6175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const UserList logged_in_users = UserManager::Get()->GetLoggedInUsers(); 6185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) for (UserList::const_iterator it = logged_in_users.begin(); 6195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) it != logged_in_users.end(); 6205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ++it) { 6215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) show_intro &= !multi_user_util::GetProfileFromUserID( 6225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) multi_user_util::GetUserIDFromEmail((*it)->email())) 6235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ->GetPrefs() 6245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ->GetBoolean(prefs::kMultiProfileNeverShowIntro); 6255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!show_intro) 6265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) break; 6275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 6285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (show_intro) { 6295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Callback<void(bool)> on_accept = 6305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&OnAcceptMultiprofilesIntro); 6315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ShowMultiprofilesIntroDialog(on_accept); 6322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } else { 6335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UserAddingScreen::Get()->Start(); 6342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 6352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 6365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 6372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::ShowSpringChargerReplacementDialog() { 6395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!ChargerReplacementDialog::ShouldShowDialog()) 6405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return false; 641c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 6425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ChargerReplacementDialog* dialog = 6435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) new ChargerReplacementDialog(GetNativeWindow()); 6445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) dialog->Show(); 6455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return true; 6465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 647c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 6485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::IsSpringChargerReplacementDialogVisible() { 6495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ChargerReplacementDialog::IsDialogVisible(); 6505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 651c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 6525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::HasUserConfirmedSafeSpringCharger() { 6535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ChargerReplacementHandler::GetChargerStatusPref() == 6545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ChargerReplacementHandler::CONFIRM_SAFE_CHARGER; 6555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 656c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 6575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShutDown() { 6585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::Shell::GetInstance()->lock_state_controller()->RequestShutdown(); 6595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 6605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::SignOut() { 6625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::AttemptUserExit(); 6635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 6645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::RequestLockScreen() { 6665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // TODO(antrim) : additional logging for crbug/173178 6675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) LOG(WARNING) << "Requesting screen lock from AshSystemTrayDelegate"; 6685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen(); 6695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 6705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::RequestRestartForUpdate() { 6725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // We expect that UpdateEngine is in "Reboot for update" state now. 6735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::NotifyAndTerminate(true /* fast path */); 6745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 6755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::GetAvailableBluetoothDevices( 6775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::BluetoothDeviceList* list) { 6785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) device::BluetoothAdapter::DeviceList devices = 6795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bluetooth_adapter_->GetDevices(); 6805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) for (size_t i = 0; i < devices.size(); ++i) { 6815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) device::BluetoothDevice* device = devices[i]; 6825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::BluetoothDeviceInfo info; 6835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) info.address = device->GetAddress(); 6845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) info.display_name = device->GetName(); 6855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) info.connected = device->IsConnected(); 6865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) info.connecting = device->IsConnecting(); 6875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) info.paired = device->IsPaired(); 6885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) list->push_back(info); 6895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 6905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 6915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::BluetoothStartDiscovering() { 693e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch if (GetBluetoothDiscovering()) { 694a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) LOG(WARNING) << "Already have active Bluetooth device discovery session."; 695a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 696a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 697a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) VLOG(1) << "Requesting new Bluetooth device discovery session."; 698a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) should_run_bluetooth_discovery_ = true; 699a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bluetooth_adapter_->StartDiscoverySession( 700a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::Bind(&SystemTrayDelegateChromeOS::OnStartBluetoothDiscoverySession, 701a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) weak_ptr_factory_.GetWeakPtr()), 702a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::Bind(&BluetoothSetDiscoveringError)); 7035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 7042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::BluetoothStopDiscovering() { 706a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) should_run_bluetooth_discovery_ = false; 707e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch if (!GetBluetoothDiscovering()) { 708a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) LOG(WARNING) << "No active Bluetooth device discovery session."; 709a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 710a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 711a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) VLOG(1) << "Stopping Bluetooth device discovery session."; 712a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bluetooth_discovery_session_->Stop( 7135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&base::DoNothing), base::Bind(&BluetoothSetDiscoveringError)); 7145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 7152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ConnectToBluetoothDevice( 7175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& address) { 7185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) device::BluetoothDevice* device = bluetooth_adapter_->GetDevice(address); 7195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!device || device->IsConnecting() || 7205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) (device->IsConnected() && device->IsPaired())) { 7215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return; 7225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 7235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (device->IsPaired() && !device->IsConnectable()) 7245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return; 7255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (device->IsPaired() || !device->IsPairable()) { 7265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( 7275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::UMA_STATUS_AREA_BLUETOOTH_CONNECT_KNOWN_DEVICE); 7285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) device->Connect(NULL, 7295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&base::DoNothing), 7305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&BluetoothDeviceConnectError)); 7315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } else { // Show paring dialog for the unpaired device. 7325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction( 7335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::UMA_STATUS_AREA_BLUETOOTH_CONNECT_UNKNOWN_DEVICE); 7345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) BluetoothPairingDialog* dialog = 7355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) new BluetoothPairingDialog(GetNativeWindow(), device); 7365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The dialog deletes itself on close. 7375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) dialog->Show(); 7385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 7395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 7405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::IsBluetoothDiscovering() { 7425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return bluetooth_adapter_->IsDiscovering(); 7435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 7445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::GetCurrentIME(ash::IMEInfo* info) { 7465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) input_method::InputMethodManager* manager = 7475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) input_method::InputMethodManager::Get(); 7485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); 7495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) input_method::InputMethodDescriptor ime = manager->GetCurrentInputMethod(); 7505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ExtractIMEInfo(ime, *util, info); 7515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) info->selected = true; 7525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 7535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::GetAvailableIMEList(ash::IMEInfoList* list) { 7555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) input_method::InputMethodManager* manager = 7565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) input_method::InputMethodManager::Get(); 7575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); 7585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<input_method::InputMethodDescriptors> ime_descriptors( 7595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) manager->GetActiveInputMethods()); 7605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::string current = manager->GetCurrentInputMethod().id(); 7615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) for (size_t i = 0; i < ime_descriptors->size(); i++) { 7625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) input_method::InputMethodDescriptor& ime = ime_descriptors->at(i); 7635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::IMEInfo info; 7645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ExtractIMEInfo(ime, *util, &info); 7655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) info.selected = ime.id() == current; 7665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) list->push_back(info); 7675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 7685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 7695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::GetCurrentIMEProperties( 7715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::IMEPropertyInfoList* list) { 772a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ash::ime::InputMethodMenuItemList menu_list = 773a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ash::ime::InputMethodMenuManager::GetInstance()-> 774a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetCurrentInputMethodMenuItemList(); 775a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) for (size_t i = 0; i < menu_list.size(); ++i) { 7765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::IMEPropertyInfo property; 777a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) property.key = menu_list[i].key; 778a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) property.name = base::UTF8ToUTF16(menu_list[i].label); 779a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) property.selected = menu_list[i].is_selection_item_checked; 7805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) list->push_back(property); 7815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 7825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 7835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::SwitchIME(const std::string& ime_id) { 7855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) input_method::InputMethodManager::Get()->ChangeInputMethod(ime_id); 7865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 7875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ActivateIMEProperty(const std::string& key) { 789a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) input_method::InputMethodManager::Get()->ActivateInputMethodMenuItem(key); 7905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 7915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::CancelDriveOperation(int32 operation_id) { 7935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DriveIntegrationService* integration_service = FindDriveIntegrationService(); 7945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!integration_service) 7955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return; 7965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) integration_service->job_list()->CancelJob(operation_id); 7985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 7995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::GetDriveOperationStatusList( 8015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::DriveOperationStatusList* list) { 8025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DriveIntegrationService* integration_service = FindDriveIntegrationService(); 8035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!integration_service) 8045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return; 8055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) *list = ConvertToDriveStatusList( 8075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) integration_service->job_list()->GetJobInfoList()); 8085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 8095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowNetworkConfigure( 8115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& network_id, 8125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::NativeWindow parent_window) { 8135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) NetworkConfigView::Show(network_id, parent_window); 8145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 8155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::EnrollNetwork( 8175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& network_id, 8185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::NativeWindow parent_window) { 8195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return enrollment::CreateDialog(network_id, parent_window); 8205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 8215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ManageBluetoothDevices() { 8235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::RecordAction(base::UserMetricsAction("ShowBluetoothSettingsPage")); 8245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::string sub_page = 8255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::string(chrome::kSearchSubPage) + "#" + 8265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH); 827effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch ShowSettingsSubPageForActiveUser(sub_page); 8285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 8295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ToggleBluetooth() { 8315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bluetooth_adapter_->SetPowered(!bluetooth_adapter_->IsPowered(), 8325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&base::DoNothing), 8335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&BluetoothPowerFailure)); 8345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 8355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowMobileSimDialog() { 8375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SimDialogDelegate::ShowDialog(GetNativeWindow(), 8385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SimDialogDelegate::SIM_DIALOG_UNLOCK); 8395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 84090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 8415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowMobileSetupDialog( 8425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& service_path) { 8435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) MobileSetupDialog::Show(service_path); 8445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 845ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16Ben Murdoch 8465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ShowOtherNetworkDialog( 8475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& type) { 8485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (type == shill::kTypeCellular) { 8495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); 8505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return; 8515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 8525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) NetworkConfigView::ShowForType(type, GetNativeWindow()); 8535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 8545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetBluetoothAvailable() { 8565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return bluetooth_adapter_->IsPresent(); 8575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 8585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetBluetoothEnabled() { 8605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return bluetooth_adapter_->IsPowered(); 8615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 8625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 863e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochbool SystemTrayDelegateChromeOS::GetBluetoothDiscovering() { 864e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch return (bluetooth_discovery_session_.get() && 865e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch bluetooth_discovery_session_->IsActive()); 866e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch} 867e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 8685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ChangeProxySettings() { 8695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CHECK(GetUserLoginStatus() == ash::user::LOGGED_IN_NONE); 8705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) LoginDisplayHostImpl::default_host()->OpenProxySettings(); 8715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 8725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ash::VolumeControlDelegate* 8745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SystemTrayDelegateChromeOS::GetVolumeControlDelegate() const { 8755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return volume_control_delegate_.get(); 8765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 8775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::SetVolumeControlDelegate( 8795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<ash::VolumeControlDelegate> delegate) { 8805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) volume_control_delegate_.swap(delegate); 8815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 8825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetSessionStartTime( 8845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::TimeTicks* session_start_time) { 8855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) *session_start_time = session_start_time_; 8865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return have_session_start_time_; 8875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 8882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 8895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetSessionLengthLimit( 8905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::TimeDelta* session_length_limit) { 8915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) *session_length_limit = session_length_limit_; 8925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return have_session_length_limit_; 8935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 8942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 8955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)int SystemTrayDelegateChromeOS::GetSystemTrayMenuWidth() { 8965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return l10n_util::GetLocalizedContentsWidthInPixels( 8975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) IDS_SYSTEM_TRAY_MENU_BUBBLE_WIDTH_PIXELS); 8985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 8992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 9005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ActiveUserWasChanged() { 9015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyUserUpdate(); 9025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 9032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 904a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool SystemTrayDelegateChromeOS::IsNetworkBehindCaptivePortal( 905a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const std::string& service_path) const { 906a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) NetworkPortalDetector::CaptivePortalState state = 907a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) NetworkPortalDetector::Get()->GetCaptivePortalState(service_path); 908a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; 909a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 910a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 911a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool SystemTrayDelegateChromeOS::IsSearchKeyMappedToCapsLock() { 912a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return search_key_mapped_to_ == input_method::kCapsLockKey; 913a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 914a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 915a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochash::tray::UserAccountsDelegate* 916a02191e04bc25c4935f804f2c080ae28663d096dBen MurdochSystemTrayDelegateChromeOS::GetUserAccountsDelegate( 917a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch const std::string& user_id) { 918a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch if (!accounts_delegates_.contains(user_id)) { 919a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // TODO(dzhioev): replace stub with real implementation. 920a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch accounts_delegates_.set(user_id, 921a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch scoped_ptr<ash::tray::UserAccountsDelegate>( 922a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch new StubUserAccountsDelegate(user_id))); 923a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch static_cast<StubUserAccountsDelegate*>(accounts_delegates_.get(user_id)) 924a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ->AddAccount("secondary_account1@gmail.com"); 925a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch static_cast<StubUserAccountsDelegate*>(accounts_delegates_.get(user_id)) 926a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ->AddAccount("very_long_account_name_for_user@gmail.com"); 927a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch static_cast<StubUserAccountsDelegate*>(accounts_delegates_.get(user_id)) 928a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ->AddAccount("secondary_account2@gmail.com"); 929a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch static_cast<StubUserAccountsDelegate*>(accounts_delegates_.get(user_id)) 930a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ->AddAccount("very_very_very_long_account_name_for_user@gmail.com"); 931a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch } 932a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch return accounts_delegates_.get(user_id); 933a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch} 934a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 9355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ash::SystemTray* SystemTrayDelegateChromeOS::GetPrimarySystemTray() { 9365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ash::Shell::GetInstance()->GetPrimarySystemTray(); 9375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 9385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() { 9405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ash::Shell::GetInstance()->system_tray_notifier(); 9415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 9425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { 944a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Stop observing the Drive integration status and the AppWindowRegistry of 945a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // the current |user_profile_|. 9465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UnobserveDriveUpdates(); 947a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) StopObservingAppWindowRegistry(); 9485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 9495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_profile_ = profile; 9505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 951a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Start observing the Drive integration status and the AppWindowRegistry of 952a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // the newly set |user_profile_|. 9535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ObserveDriveUpdates(); 954a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) apps::AppWindowRegistry::Get(user_profile_)->AddObserver(this); 9555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 9565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) PrefService* prefs = profile->GetPrefs(); 9575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref_registrar_.reset(new PrefChangeRegistrar); 9585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref_registrar_->Init(prefs); 9595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref_registrar_->Add( 9605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs::kUse24HourClock, 9615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&SystemTrayDelegateChromeOS::UpdateClockType, 9625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Unretained(this))); 9635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref_registrar_->Add( 9645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs::kLanguageRemapSearchKeyTo, 9655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&SystemTrayDelegateChromeOS::OnLanguageRemapSearchKeyToChanged, 9665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Unretained(this))); 9675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref_registrar_->Add( 9685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs::kShowLogoutButtonInTray, 9695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray, 9705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Unretained(this))); 9715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref_registrar_->Add( 9725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs::kLogoutDialogDurationMs, 9735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration, 9745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Unretained(this))); 9755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref_registrar_->Add( 9765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs::kLargeCursorEnabled, 9775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityModeChanged, 9785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Unretained(this), 9795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::A11Y_NOTIFICATION_NONE)); 9805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref_registrar_->Add( 9815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs::kAutoclickEnabled, 9825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityModeChanged, 9835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Unretained(this), 9845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::A11Y_NOTIFICATION_NONE)); 9855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref_registrar_->Add( 9865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs::kShouldAlwaysShowAccessibilityMenu, 9875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityModeChanged, 9885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Unretained(this), 9895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::A11Y_NOTIFICATION_NONE)); 9905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref_registrar_->Add( 9915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs::kPerformanceTracingEnabled, 9925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Bind(&SystemTrayDelegateChromeOS::UpdatePerformanceTracing, 9935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Unretained(this))); 9945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 9955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateClockType(); 9965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateShowLogoutButtonInTray(); 9975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateLogoutDialogDuration(); 9985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdatePerformanceTracing(); 9995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) search_key_mapped_to_ = 10005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) profile->GetPrefs()->GetInteger(prefs::kLanguageRemapSearchKeyTo); 10015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 100290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 10035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::UnsetProfile(Profile* profile) { 10045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (profile != user_profile_) 10055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return false; 10065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref_registrar_.reset(); 1007a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) user_profile_ = NULL; 10085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return true; 10095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 10105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ObserveDriveUpdates() { 10125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DriveIntegrationService* integration_service = FindDriveIntegrationService(); 10135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (integration_service) 10145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) integration_service->job_list()->AddObserver(this); 10155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 10167dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 10175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UnobserveDriveUpdates() { 10185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DriveIntegrationService* integration_service = FindDriveIntegrationService(); 10195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (integration_service) 10205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) integration_service->job_list()->RemoveObserver(this); 10215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1022bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 10235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::GetShouldUse24HourClockForTesting() const { 10245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return ShouldUse24HourClock(); 10255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 10262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 10275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool SystemTrayDelegateChromeOS::ShouldUse24HourClock() const { 10285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // On login screen and in guest mode owner default is used for 10295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // kUse24HourClock preference. 10305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const ash::user::LoginStatus status = GetUserLoginStatus(); 10315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const CrosSettings* const cros_settings = CrosSettings::Get(); 10325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool system_use_24_hour_clock = true; 10335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const bool system_value_found = cros_settings->GetBoolean( 10345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) kSystemUse24HourClock, &system_use_24_hour_clock); 10355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 10365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if ((status == ash::user::LOGGED_IN_NONE) || !user_pref_registrar_) 10375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return (system_value_found 10385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ? system_use_24_hour_clock 10395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : (base::GetHourClockType() == base::k24HourClock)); 10405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 10415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const PrefService::Preference* user_pref = 10425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref_registrar_->prefs()->FindPreference(prefs::kUse24HourClock); 10435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (status == ash::user::LOGGED_IN_GUEST && user_pref->IsDefaultValue()) 10445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return (system_value_found 10455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ? system_use_24_hour_clock 10465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : (base::GetHourClockType() == base::k24HourClock)); 10475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 10485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool use_24_hour_clock = true; 10495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref->GetValue()->GetAsBoolean(&use_24_hour_clock); 10505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return use_24_hour_clock; 10515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 10525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateClockType() { 10545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const bool use_24_hour_clock = ShouldUse24HourClock(); 10555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock; 10565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyDateFormatChanged(); 10575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // This also works for enterprise-managed devices because they never have 10585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // local owner. 10595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (chromeos::UserManager::Get()->IsCurrentUserOwner()) 10605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, use_24_hour_clock); 10615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 10625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() { 10645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyShowLoginButtonChanged( 10655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref_registrar_->prefs()->GetBoolean( 10665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs::kShowLogoutButtonInTray)); 10675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 10685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() { 10705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const int duration_ms = 10715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) user_pref_registrar_->prefs()->GetInteger(prefs::kLogoutDialogDurationMs); 10725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyLogoutDialogDurationChanged( 10735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::TimeDelta::FromMilliseconds(duration_ms)); 10745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 107558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 10765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateSessionStartTime() { 10775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const PrefService* local_state = local_state_registrar_->prefs(); 10785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (local_state->HasPrefPath(prefs::kSessionStartTime)) { 10795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) have_session_start_time_ = true; 10805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) session_start_time_ = base::TimeTicks::FromInternalValue( 10815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) local_state->GetInt64(prefs::kSessionStartTime)); 10825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } else { 10835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) have_session_start_time_ = false; 10845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) session_start_time_ = base::TimeTicks(); 10855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 10865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifySessionStartTimeChanged(); 10875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 10885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateSessionLengthLimit() { 10905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const PrefService* local_state = local_state_registrar_->prefs(); 10915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (local_state->HasPrefPath(prefs::kSessionLengthLimit)) { 10925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) have_session_length_limit_ = true; 10935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) session_length_limit_ = base::TimeDelta::FromMilliseconds( 10945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::min(std::max(local_state->GetInteger(prefs::kSessionLengthLimit), 10955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) kSessionLengthLimitMinMs), 10965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) kSessionLengthLimitMaxMs)); 10975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } else { 10985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) have_session_length_limit_ = false; 10995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) session_length_limit_ = base::TimeDelta(); 11005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 11015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifySessionLengthLimitChanged(); 11025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 11035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1104a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::StopObservingAppWindowRegistry() { 1105a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!user_profile_) 1106a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 1107a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1108a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) apps::AppWindowRegistry* registry = 1109a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) apps::AppWindowRegistry::Factory::GetForBrowserContext(user_profile_, 1110a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) false); 1111a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (registry) 1112a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) registry->RemoveObserver(this); 1113a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 1114a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1115a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::NotifyIfLastWindowClosed() { 1116a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!user_profile_) 1117a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 1118a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1119a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) BrowserList* browser_list = 1120a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); 1121a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) for (BrowserList::const_iterator it = browser_list->begin(); 1122a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) it != browser_list->end(); 1123a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ++it) { 1124a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if ((*it)->profile()->IsSameProfile(user_profile_)) { 1125a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // The current user has at least one open browser window. 1126a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 1127a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 1128a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 1129a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1130a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!apps::AppWindowRegistry::Get(user_profile_)->app_windows().empty()) { 1131a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // The current user has at least one open app window. 1132a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 1133a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 1134a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1135a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetSystemTrayNotifier()->NotifyLastWindowClosed(); 1136a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 1137a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 11385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// LoginState::Observer overrides. 11395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::LoggedInStateChanged() { 11405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // It apparently sometimes takes a while after login before the current user 11415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // is recognized as the owner. Make sure that the system-wide clock setting 11425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // is updated when the recognition eventually happens 11435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // (http://crbug.com/278601). 11445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // 11455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Note that it isn't safe to blindly call UpdateClockType() from this 11465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // method, as LoggedInStateChanged() is also called before the logged-in 11475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // user's profile has actually been loaded (http://crbug.com/317745). The 11485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // system tray's time format is updated at login via SetProfile(). 11495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { 11505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, 11515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ShouldUse24HourClock()); 11525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 11535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 11545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 11555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from SessionManagerClient::Observer. 11565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ScreenIsLocked() { 11575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) screen_locked_ = true; 11585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(GetUserLoginStatus()); 11595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 11605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 11615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::ScreenIsUnlocked() { 11625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) screen_locked_ = false; 11635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(GetUserLoginStatus()); 11645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 11655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 11665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)gfx::NativeWindow SystemTrayDelegateChromeOS::GetNativeWindow() const { 11675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool session_started = ash::Shell::GetInstance() 11685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ->session_state_delegate() 11695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ->IsActiveUserSessionStarted(); 11705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return GetNativeWindowByStatus(GetUserLoginStatus(), session_started); 11715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 11725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 11735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// content::NotificationObserver implementation. 11745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::Observe( 11755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int type, 11765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const content::NotificationSource& source, 11775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const content::NotificationDetails& details) { 11785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) switch (type) { 11795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: { 11805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpgradeDetector* detector = 11815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::Source<UpgradeDetector>(source).ptr(); 11825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::UpdateObserver::UpdateSeverity severity = 11835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::UpdateObserver::UPDATE_NORMAL; 11845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) switch (detector->upgrade_notification_stage()) { 11855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case UpgradeDetector::UPGRADE_ANNOYANCE_SEVERE: 11865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) severity = ash::UpdateObserver::UPDATE_SEVERE_RED; 11875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) break; 11885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 11895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case UpgradeDetector::UPGRADE_ANNOYANCE_HIGH: 11905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) severity = ash::UpdateObserver::UPDATE_HIGH_ORANGE; 11915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) break; 11925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 11935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case UpgradeDetector::UPGRADE_ANNOYANCE_ELEVATED: 11945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) severity = ash::UpdateObserver::UPDATE_LOW_GREEN; 11955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) break; 11965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 11975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case UpgradeDetector::UPGRADE_ANNOYANCE_LOW: 11985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) default: 11995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) severity = ash::UpdateObserver::UPDATE_NORMAL; 12005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) break; 12015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 12025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyUpdateRecommended(severity); 12035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) break; 12045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 12055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED: { 12065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // This notification is also sent on login screen when user avatar 12075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // is loaded from file. 12085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (GetUserLoginStatus() != ash::user::LOGGED_IN_NONE) { 12095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyUserUpdate(); 12105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 12115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) break; 12125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 12135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case chrome::NOTIFICATION_PROFILE_CREATED: { 12145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetProfile(content::Source<Profile>(source).ptr()); 12155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) registrar_->Remove(this, 12165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::NOTIFICATION_PROFILE_CREATED, 12175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) content::NotificationService::AllSources()); 12185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) break; 12195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 12205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case chrome::NOTIFICATION_PROFILE_DESTROYED: { 12215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (UnsetProfile(content::Source<Profile>(source).ptr())) { 122290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) registrar_->Remove(this, 12235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) chrome::NOTIFICATION_PROFILE_DESTROYED, 122490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) content::NotificationService::AllSources()); 12252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 12265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) break; 12275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 12285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case chrome::NOTIFICATION_SESSION_STARTED: { 12295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( 12305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetUserLoginStatus()); 12315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SetProfile(ProfileManager::GetActiveUserProfile()); 12325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) break; 12335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 12345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) default: 12355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) NOTREACHED(); 12365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 12375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 12385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 12395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnLanguageRemapSearchKeyToChanged() { 12405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) search_key_mapped_to_ = user_pref_registrar_->prefs()->GetInteger( 12415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs::kLanguageRemapSearchKeyTo); 12425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 12435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 12445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnAccessibilityModeChanged( 12455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::AccessibilityNotificationVisibility notify) { 12465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyAccessibilityModeChanged(notify); 12475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 12485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 12495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdatePerformanceTracing() { 12505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!user_pref_registrar_) 12515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return; 12525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool value = user_pref_registrar_->prefs()->GetBoolean( 12535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) prefs::kPerformanceTracingEnabled); 12545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyTracingModeChanged(value); 12555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 12565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 12575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from InputMethodManager::Observer. 12585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::InputMethodChanged( 12595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) input_method::InputMethodManager* manager, 12605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool show_message) { 1261a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetSystemTrayNotifier()->NotifyRefreshIME(); 1262a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 1263a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1264a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Overridden from InputMethodMenuManager::Observer. 1265a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::InputMethodMenuItemChanged( 1266a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ash::ime::InputMethodMenuManager* manager) { 1267a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetSystemTrayNotifier()->NotifyRefreshIME(); 1268a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 1269a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1270a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Overridden from CrasAudioHandler::AudioObserver. 1271a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnOutputVolumeChanged() { 1272a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetSystemTrayNotifier()->NotifyAudioOutputVolumeChanged(); 1273a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 1274a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1275a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnOutputMuteChanged() { 1276a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetSystemTrayNotifier()->NotifyAudioOutputMuteChanged(); 1277a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 1278a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1279a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnInputGainChanged() { 1280a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 1281a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1282a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnInputMuteChanged() { 12835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 12845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1285a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnAudioNodesChanged() { 1286a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetSystemTrayNotifier()->NotifyAudioNodesChanged(); 1287a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 1288a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1289a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnActiveOutputNodeChanged() { 1290a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetSystemTrayNotifier()->NotifyAudioActiveOutputNodeChanged(); 1291a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 1292a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1293a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnActiveInputNodeChanged() { 1294a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GetSystemTrayNotifier()->NotifyAudioActiveInputNodeChanged(); 12955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 12965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 12975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// drive::JobListObserver overrides. 12985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnJobAdded(const drive::JobInfo& job_info) { 12995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) OnJobUpdated(job_info); 13005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 13015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 13025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnJobDone(const drive::JobInfo& job_info, 13035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) drive::FileError error) { 13045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::DriveOperationStatus status; 13055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (ConvertToFinishedDriveOperationStatus(job_info, error, &status)) 13065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyDriveJobUpdated(status); 13075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 13085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 13095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnJobUpdated(const drive::JobInfo& job_info) { 13105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ash::DriveOperationStatus status; 13115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (ConvertToDriveOperationStatus(job_info, &status)) 13125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyDriveJobUpdated(status); 13135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 13145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 13155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)DriveIntegrationService* 13165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SystemTrayDelegateChromeOS::FindDriveIntegrationService() { 13175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return user_profile_ 13185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ? DriveIntegrationServiceFactory::FindForProfile(user_profile_) 13195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : NULL; 13205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 13215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 13225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from BluetoothAdapter::Observer. 13235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::AdapterPresentChanged( 13245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) device::BluetoothAdapter* adapter, 13255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool present) { 13265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyRefreshBluetooth(); 13275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 13285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 13295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::AdapterPoweredChanged( 13305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) device::BluetoothAdapter* adapter, 13315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool powered) { 13325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyRefreshBluetooth(); 13335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 13345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 13355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::AdapterDiscoveringChanged( 13365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) device::BluetoothAdapter* adapter, 13375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool discovering) { 13385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyBluetoothDiscoveringChanged(); 13395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 13405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 13415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::DeviceAdded(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::DeviceChanged( 13475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) device::BluetoothAdapter* adapter, 13485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) device::BluetoothDevice* device) { 13495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyRefreshBluetooth(); 13505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 13512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 13525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::DeviceRemoved( 13535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) device::BluetoothAdapter* adapter, 13545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) device::BluetoothDevice* device) { 13555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyRefreshBluetooth(); 13565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 13572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1358a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnStartBluetoothDiscoverySession( 1359a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_ptr<device::BluetoothDiscoverySession> discovery_session) { 1360a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // If the discovery session was returned after a request to stop discovery 1361a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // (e.g. the user dismissed the Bluetooth detailed view before the call 1362a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // returned), don't claim the discovery session and let it clean up. 1363a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!should_run_bluetooth_discovery_) 1364a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 1365a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) VLOG(1) << "Claiming new Bluetooth device discovery session."; 1366a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bluetooth_discovery_session_ = discovery_session.Pass(); 1367e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch GetSystemTrayNotifier()->NotifyBluetoothDiscoveringChanged(); 13685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 1369868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 13705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UpdateEnterpriseDomain() { 13715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) policy::BrowserPolicyConnectorChromeOS* connector = 13725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) g_browser_process->platform_part()->browser_policy_connector_chromeos(); 13735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::string enterprise_domain = connector->GetEnterpriseDomain(); 13745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (enterprise_domain_ != enterprise_domain) { 13755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) enterprise_domain_ = enterprise_domain; 13765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyEnterpriseDomainChanged(); 13774e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) } 13785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 13795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 13805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from CloudPolicyStore::Observer 13815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnStoreLoaded( 13825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) policy::CloudPolicyStore* store) { 13835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateEnterpriseDomain(); 13845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 13854e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 13865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnStoreError(policy::CloudPolicyStore* store) { 13875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) UpdateEnterpriseDomain(); 13885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 13895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 13905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Overridden from ash::SessionStateObserver 13915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void SystemTrayDelegateChromeOS::UserAddedToSession( 13925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& user_id) { 13935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) GetSystemTrayNotifier()->NotifyUserAddedToSession(); 13945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 13955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1396a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Overridden from chrome::BrowserListObserver. 1397a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnBrowserRemoved(Browser* browser) { 1398a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) NotifyIfLastWindowClosed(); 1399a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 1400a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1401a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Overridden from apps::AppWindowRegistry::Observer. 1402a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnAppWindowAdded(apps::AppWindow* app_window) { 1403a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 1404a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1405a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnAppWindowIconChanged( 1406a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) apps::AppWindow* app_window) {} 1407a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1408a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnAppWindowRemoved( 1409a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) apps::AppWindow* app_window) { 1410a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) NotifyIfLastWindowClosed(); 1411a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 1412a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1413a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged( 1414a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const AccessibilityStatusEventDetails& details) { 1415a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN) 1416a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) accessibility_subscription_.reset(); 1417a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) else 1418a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) OnAccessibilityModeChanged(details.notify); 1419a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 1420a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 14215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 14225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return new SystemTrayDelegateChromeOS(); 14235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 14245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 14255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace chromeos 1426