OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" | 5 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ash/system/audio/audio_observer.h" | 9 #include "ash/system/audio/audio_observer.h" |
10 #include "ash/system/bluetooth/bluetooth_observer.h" | 10 #include "ash/system/bluetooth/bluetooth_observer.h" |
11 #include "ash/system/brightness/brightness_observer.h" | 11 #include "ash/system/brightness/brightness_observer.h" |
12 #include "ash/system/date/clock_observer.h" | 12 #include "ash/system/date/clock_observer.h" |
13 #include "ash/system/drive/drive_observer.h" | |
13 #include "ash/system/ime/ime_observer.h" | 14 #include "ash/system/ime/ime_observer.h" |
14 #include "ash/system/network/network_observer.h" | 15 #include "ash/system/network/network_observer.h" |
15 #include "ash/system/power/power_status_observer.h" | 16 #include "ash/system/power/power_status_observer.h" |
16 #include "ash/system/tray/system_tray.h" | 17 #include "ash/system/tray/system_tray.h" |
17 #include "ash/system/tray/system_tray_delegate.h" | 18 #include "ash/system/tray/system_tray_delegate.h" |
18 #include "ash/system/tray_accessibility.h" | 19 #include "ash/system/tray_accessibility.h" |
19 #include "ash/system/tray_caps_lock.h" | 20 #include "ash/system/tray_caps_lock.h" |
20 #include "ash/system/user/update_observer.h" | 21 #include "ash/system/user/update_observer.h" |
21 #include "ash/system/user/user_observer.h" | 22 #include "ash/system/user/user_observer.h" |
22 #include "base/chromeos/chromeos_version.h" | 23 #include "base/chromeos/chromeos_version.h" |
23 #include "base/logging.h" | 24 #include "base/logging.h" |
25 #include "base/memory/weak_ptr.h" | |
24 #include "base/utf_string_conversions.h" | 26 #include "base/utf_string_conversions.h" |
25 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
26 #include "chrome/browser/chromeos/audio/audio_handler.h" | 28 #include "chrome/browser/chromeos/audio/audio_handler.h" |
27 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" | 29 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" |
28 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" | 30 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" |
29 #include "chrome/browser/chromeos/cros/cros_library.h" | 31 #include "chrome/browser/chromeos/cros/cros_library.h" |
30 #include "chrome/browser/chromeos/cros/network_library.h" | 32 #include "chrome/browser/chromeos/cros/network_library.h" |
33 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | |
34 #include "chrome/browser/chromeos/gdata/gdata_util.h" | |
31 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 35 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
32 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 36 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
33 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" | 37 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" |
34 #include "chrome/browser/chromeos/input_method/xkeyboard.h" | 38 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
35 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 39 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" |
36 #include "chrome/browser/chromeos/login/base_login_display_host.h" | 40 #include "chrome/browser/chromeos/login/base_login_display_host.h" |
37 #include "chrome/browser/chromeos/login/login_display_host.h" | 41 #include "chrome/browser/chromeos/login/login_display_host.h" |
38 #include "chrome/browser/chromeos/login/message_bubble.h" | 42 #include "chrome/browser/chromeos/login/message_bubble.h" |
39 #include "chrome/browser/chromeos/login/user.h" | 43 #include "chrome/browser/chromeos/login/user.h" |
40 #include "chrome/browser/chromeos/login/user_manager.h" | 44 #include "chrome/browser/chromeos/login/user_manager.h" |
41 #include "chrome/browser/chromeos/mobile_config.h" | 45 #include "chrome/browser/chromeos/mobile_config.h" |
42 #include "chrome/browser/chromeos/status/data_promo_notification.h" | 46 #include "chrome/browser/chromeos/status/data_promo_notification.h" |
43 #include "chrome/browser/chromeos/status/network_menu.h" | 47 #include "chrome/browser/chromeos/status/network_menu.h" |
44 #include "chrome/browser/chromeos/status/network_menu_icon.h" | 48 #include "chrome/browser/chromeos/status/network_menu_icon.h" |
45 #include "chrome/browser/chromeos/system/timezone_settings.h" | 49 #include "chrome/browser/chromeos/system/timezone_settings.h" |
46 #include "chrome/browser/chromeos/system_key_event_listener.h" | 50 #include "chrome/browser/chromeos/system_key_event_listener.h" |
47 #include "chrome/browser/prefs/pref_service.h" | 51 #include "chrome/browser/prefs/pref_service.h" |
48 #include "chrome/browser/profiles/profile_manager.h" | 52 #include "chrome/browser/profiles/profile_manager.h" |
49 #include "chrome/browser/ui/browser.h" | 53 #include "chrome/browser/ui/browser.h" |
50 #include "chrome/browser/ui/browser_list.h" | 54 #include "chrome/browser/ui/browser_list.h" |
51 #include "chrome/browser/upgrade_detector.h" | 55 #include "chrome/browser/upgrade_detector.h" |
52 #include "chrome/common/chrome_notification_types.h" | 56 #include "chrome/common/chrome_notification_types.h" |
53 #include "chrome/common/pref_names.h" | 57 #include "chrome/common/pref_names.h" |
54 #include "chrome/common/url_constants.h" | 58 #include "chrome/common/url_constants.h" |
55 #include "chromeos/dbus/dbus_thread_manager.h" | 59 #include "chromeos/dbus/dbus_thread_manager.h" |
56 #include "chromeos/dbus/power_manager_client.h" | 60 #include "chromeos/dbus/power_manager_client.h" |
61 #include "content/public/browser/browser_thread.h" | |
57 #include "content/public/browser/notification_observer.h" | 62 #include "content/public/browser/notification_observer.h" |
58 #include "content/public/browser/notification_service.h" | 63 #include "content/public/browser/notification_service.h" |
59 #include "content/public/browser/user_metrics.h" | 64 #include "content/public/browser/user_metrics.h" |
60 #include "grit/generated_resources.h" | 65 #include "grit/generated_resources.h" |
61 #include "ui/base/l10n/l10n_util.h" | 66 #include "ui/base/l10n/l10n_util.h" |
62 | 67 |
68 using gdata::GDataFileSystem; | |
69 using gdata::GDataOperationRegistry; | |
70 using gdata::GDataSystemService; | |
71 using gdata::GDataSystemServiceFactory; | |
72 | |
63 namespace chromeos { | 73 namespace chromeos { |
64 | 74 |
65 namespace { | 75 namespace { |
66 | 76 |
77 // Time delay for rechecking gdata operation when we suspect that there will | |
78 // be no upcoming activity notifications that need to be pushed to UI. | |
79 const int kGDataOperationRecheckDelayMs = 5000; | |
80 | |
67 bool ShouldShowNetworkIconInTray(const Network* network) { | 81 bool ShouldShowNetworkIconInTray(const Network* network) { |
68 if (!network) | 82 if (!network) |
69 return true; | 83 return true; |
70 return !network->connected() || network->type() != TYPE_ETHERNET; | 84 return !network->connected() || network->type() != TYPE_ETHERNET; |
71 } | 85 } |
72 | 86 |
73 ash::NetworkIconInfo CreateNetworkIconInfo(const Network* network, | 87 ash::NetworkIconInfo CreateNetworkIconInfo(const Network* network, |
74 NetworkMenuIcon* network_icon, | 88 NetworkMenuIcon* network_icon, |
75 NetworkMenu* network_menu) { | 89 NetworkMenu* network_menu) { |
76 ash::NetworkIconInfo info; | 90 ash::NetworkIconInfo info; |
77 info.name = UTF8ToUTF16(network->name()); | 91 info.name = UTF8ToUTF16(network->name()); |
78 info.image = network_icon->GetBitmap(network, NetworkMenuIcon::COLOR_DARK); | 92 info.image = network_icon->GetBitmap(network, NetworkMenuIcon::COLOR_DARK); |
79 info.service_path = network->service_path(); | 93 info.service_path = network->service_path(); |
80 info.highlight = network_menu->ShouldHighlightNetwork(network); | 94 info.highlight = network_menu->ShouldHighlightNetwork(network); |
81 info.tray_icon_visible = ShouldShowNetworkIconInTray(network); | 95 info.tray_icon_visible = ShouldShowNetworkIconInTray(network); |
82 return info; | 96 return info; |
83 } | 97 } |
84 | 98 |
85 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, | 99 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, |
86 const input_method::InputMethodUtil& util, | 100 const input_method::InputMethodUtil& util, |
87 ash::IMEInfo* info) { | 101 ash::IMEInfo* info) { |
88 info->id = ime.id(); | 102 info->id = ime.id(); |
89 info->name = util.GetInputMethodLongName(ime); | 103 info->name = util.GetInputMethodLongName(ime); |
90 info->short_name = util.GetInputMethodShortName(ime); | 104 info->short_name = util.GetInputMethodShortName(ime); |
91 } | 105 } |
92 | 106 |
107 ash::DriveOperationStatusList GetDriveStatusList( | |
108 const std::vector<GDataOperationRegistry::ProgressStatus>& list) { | |
109 ash::DriveOperationStatusList results; | |
110 for (GDataOperationRegistry::ProgressStatusList::const_iterator it = | |
111 list.begin(); | |
112 it != list.end(); ++it) { | |
113 ash::DriveOperationStatus status; | |
114 status.file_path = it->file_path; | |
115 status.progress = it->progress_total == 0 ? 0.0 : | |
116 static_cast<double>(it->progress_current) / | |
117 static_cast<double>(it->progress_total); | |
118 status.type = static_cast<ash::DriveOperationStatus::OperationType>( | |
119 it->operation_type); | |
120 status.state = static_cast<ash::DriveOperationStatus::OperationState>( | |
121 it->transfer_state); | |
122 results.push_back(status); | |
123 } | |
124 return results; | |
125 } | |
93 | 126 |
94 void BluetoothPowerFailure() { | 127 void BluetoothPowerFailure() { |
95 // TODO(sad): Show an error bubble? | 128 // TODO(sad): Show an error bubble? |
96 } | 129 } |
97 | 130 |
98 void BluetoothDiscoveryFailure() { | 131 void BluetoothDiscoveryFailure() { |
99 // TODO(sad): Show an error bubble? | 132 // TODO(sad): Show an error bubble? |
100 } | 133 } |
101 | 134 |
102 void BluetoothDeviceDisconnectError() { | 135 void BluetoothDeviceDisconnectError() { |
103 // TODO(sad): Do something? | 136 // TODO(sad): Do something? |
104 } | 137 } |
105 | 138 |
106 void BluetoothDeviceConnectError() { | 139 void BluetoothDeviceConnectError() { |
107 // TODO(sad): Do something? | 140 // TODO(sad): Do something? |
108 } | 141 } |
109 | 142 |
110 class SystemTrayDelegate : public ash::SystemTrayDelegate, | 143 class SystemTrayDelegate : public ash::SystemTrayDelegate, |
111 public AudioHandler::VolumeObserver, | 144 public AudioHandler::VolumeObserver, |
112 public PowerManagerClient::Observer, | 145 public PowerManagerClient::Observer, |
113 public NetworkMenuIcon::Delegate, | 146 public NetworkMenuIcon::Delegate, |
114 public NetworkMenu::Delegate, | 147 public NetworkMenu::Delegate, |
115 public NetworkLibrary::NetworkManagerObserver, | 148 public NetworkLibrary::NetworkManagerObserver, |
116 public NetworkLibrary::NetworkObserver, | 149 public NetworkLibrary::NetworkObserver, |
117 public NetworkLibrary::CellularDataPlanObserver, | 150 public NetworkLibrary::CellularDataPlanObserver, |
151 public gdata::GDataOperationRegistry::Observer, | |
118 public content::NotificationObserver, | 152 public content::NotificationObserver, |
119 public input_method::InputMethodManager::Observer, | 153 public input_method::InputMethodManager::Observer, |
120 public system::TimezoneSettings::Observer, | 154 public system::TimezoneSettings::Observer, |
121 public BluetoothAdapter::Observer, | 155 public BluetoothAdapter::Observer, |
122 public SystemKeyEventListener::CapsLockObserver, | 156 public SystemKeyEventListener::CapsLockObserver, |
123 public MessageBubbleLinkListener { | 157 public MessageBubbleLinkListener { |
124 public: | 158 public: |
125 explicit SystemTrayDelegate(ash::SystemTray* tray) | 159 explicit SystemTrayDelegate(ash::SystemTray* tray) |
126 : tray_(tray), | 160 : tray_(tray), |
161 ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST( | |
162 new base::WeakPtrFactory<SystemTrayDelegate>(this))), | |
127 network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST( | 163 network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST( |
128 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), | 164 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), |
129 network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST( | 165 network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST( |
130 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), | 166 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), |
131 network_menu_(ALLOW_THIS_IN_INITIALIZER_LIST(new NetworkMenu(this))), | 167 network_menu_(ALLOW_THIS_IN_INITIALIZER_LIST(new NetworkMenu(this))), |
132 clock_type_(base::k24HourClock), | 168 clock_type_(base::k24HourClock), |
133 search_key_mapped_to_(input_method::kSearchKey), | 169 search_key_mapped_to_(input_method::kSearchKey), |
134 screen_locked_(false), | 170 screen_locked_(false), |
135 data_promo_notification_(new DataPromoNotification()) { | 171 data_promo_notification_(new DataPromoNotification()) { |
136 AudioHandler::GetInstance()->AddVolumeObserver(this); | 172 AudioHandler::GetInstance()->AddVolumeObserver(this); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 virtual void ShowNetworkSettings() OVERRIDE { | 299 virtual void ShowNetworkSettings() OVERRIDE { |
264 content::RecordAction( | 300 content::RecordAction( |
265 content::UserMetricsAction("OpenInternetOptionsDialog")); | 301 content::UserMetricsAction("OpenInternetOptionsDialog")); |
266 GetAppropriateBrowser()->ShowOptionsTab(chrome::kInternetOptionsSubPage); | 302 GetAppropriateBrowser()->ShowOptionsTab(chrome::kInternetOptionsSubPage); |
267 } | 303 } |
268 | 304 |
269 virtual void ShowBluetoothSettings() OVERRIDE { | 305 virtual void ShowBluetoothSettings() OVERRIDE { |
270 // TODO(sad): Make this work. | 306 // TODO(sad): Make this work. |
271 } | 307 } |
272 | 308 |
309 virtual void ShowDriveSettings() OVERRIDE { | |
310 // TODO(zelidrag): Show settings once we put them in. | |
311 } | |
312 | |
273 virtual void ShowIMESettings() OVERRIDE { | 313 virtual void ShowIMESettings() OVERRIDE { |
274 content::RecordAction( | 314 content::RecordAction( |
275 content::UserMetricsAction("OpenLanguageOptionsDialog")); | 315 content::UserMetricsAction("OpenLanguageOptionsDialog")); |
276 GetAppropriateBrowser()->ShowOptionsTab(chrome::kLanguageOptionsSubPage); | 316 GetAppropriateBrowser()->ShowOptionsTab(chrome::kLanguageOptionsSubPage); |
277 } | 317 } |
278 | 318 |
279 virtual void ShowHelp() OVERRIDE { | 319 virtual void ShowHelp() OVERRIDE { |
280 GetAppropriateBrowser()->ShowHelpTab(); | 320 GetAppropriateBrowser()->ShowHelpTab(); |
281 } | 321 } |
282 | 322 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 | 437 |
398 virtual void SwitchIME(const std::string& ime_id) OVERRIDE { | 438 virtual void SwitchIME(const std::string& ime_id) OVERRIDE { |
399 input_method::InputMethodManager::GetInstance()->ChangeInputMethod(ime_id); | 439 input_method::InputMethodManager::GetInstance()->ChangeInputMethod(ime_id); |
400 } | 440 } |
401 | 441 |
402 virtual void ActivateIMEProperty(const std::string& key) OVERRIDE { | 442 virtual void ActivateIMEProperty(const std::string& key) OVERRIDE { |
403 input_method::InputMethodManager::GetInstance()-> | 443 input_method::InputMethodManager::GetInstance()-> |
404 ActivateInputMethodProperty(key); | 444 ActivateInputMethodProperty(key); |
405 } | 445 } |
406 | 446 |
447 virtual void CancelDriveOperation(const FilePath& file_path) OVERRIDE { | |
448 Profile* profile = ProfileManager::GetDefaultProfile(); | |
449 if (!gdata::util::IsGDataAvailable(profile)) | |
450 return; | |
451 | |
452 GDataSystemService* system_service = | |
453 GDataSystemServiceFactory::FindForProfile(profile); | |
454 if (!system_service) | |
455 return; | |
456 | |
457 system_service->file_system()->GetOperationRegistry()->CancelForFilePath( | |
458 file_path); | |
459 } | |
460 | |
461 virtual void GetDriveOperationStatusList( | |
462 ash::DriveOperationStatusList* list) OVERRIDE { | |
463 Profile* profile = ProfileManager::GetDefaultProfile(); | |
464 if (!gdata::util::IsGDataAvailable(profile)) | |
465 return; | |
466 | |
467 GDataSystemService* system_service = | |
468 GDataSystemServiceFactory::FindForProfile(profile); | |
469 if (!system_service) | |
470 return; | |
471 | |
472 *list = GetDriveStatusList( | |
473 system_service->file_system()->GetOperationRegistry()-> | |
474 GetProgressStatusList()); | |
475 } | |
476 | |
477 | |
407 virtual void GetMostRelevantNetworkIcon(ash::NetworkIconInfo* info, | 478 virtual void GetMostRelevantNetworkIcon(ash::NetworkIconInfo* info, |
408 bool dark) OVERRIDE { | 479 bool dark) OVERRIDE { |
409 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); | 480 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); |
410 info->image = !dark ? network_icon_->GetIconAndText(&info->description) : | 481 info->image = !dark ? network_icon_->GetIconAndText(&info->description) : |
411 network_icon_dark_->GetIconAndText(&info->description); | 482 network_icon_dark_->GetIconAndText(&info->description); |
412 info->tray_icon_visible = | 483 info->tray_icon_visible = |
413 ShouldShowNetworkIconInTray(crosnet->connected_network()); | 484 ShouldShowNetworkIconInTray(crosnet->connected_network()); |
414 } | 485 } |
415 | 486 |
416 virtual void GetAvailableNetworks( | 487 virtual void GetAvailableNetworks( |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
648 } | 719 } |
649 | 720 |
650 void SetProfile(Profile* profile) { | 721 void SetProfile(Profile* profile) { |
651 pref_registrar_.reset(new PrefChangeRegistrar); | 722 pref_registrar_.reset(new PrefChangeRegistrar); |
652 pref_registrar_->Init(profile->GetPrefs()); | 723 pref_registrar_->Init(profile->GetPrefs()); |
653 pref_registrar_->Add(prefs::kUse24HourClock, this); | 724 pref_registrar_->Add(prefs::kUse24HourClock, this); |
654 pref_registrar_->Add(prefs::kLanguageXkbRemapSearchKeyTo, this); | 725 pref_registrar_->Add(prefs::kLanguageXkbRemapSearchKeyTo, this); |
655 UpdateClockType(profile->GetPrefs()); | 726 UpdateClockType(profile->GetPrefs()); |
656 search_key_mapped_to_ = | 727 search_key_mapped_to_ = |
657 profile->GetPrefs()->GetInteger(prefs::kLanguageXkbRemapSearchKeyTo); | 728 profile->GetPrefs()->GetInteger(prefs::kLanguageXkbRemapSearchKeyTo); |
729 | |
730 if (gdata::util::IsGDataAvailable(profile)) { | |
731 GDataSystemService* system_service = | |
732 GDataSystemServiceFactory::FindForProfile(profile); | |
733 system_service->file_system()->GetOperationRegistry()-> | |
734 AddObserver(this); | |
735 } | |
658 } | 736 } |
659 | 737 |
660 void UpdateClockType(PrefService* service) { | 738 void UpdateClockType(PrefService* service) { |
661 clock_type_ = service->GetBoolean(prefs::kUse24HourClock) ? | 739 clock_type_ = service->GetBoolean(prefs::kUse24HourClock) ? |
662 base::k24HourClock : base::k12HourClock; | 740 base::k24HourClock : base::k12HourClock; |
663 ash::ClockObserver* observer = tray_->clock_observer(); | 741 ash::ClockObserver* observer = tray_->clock_observer(); |
664 if (observer) | 742 if (observer) |
665 observer->OnDateFormatChanged(); | 743 observer->OnDateFormatChanged(); |
666 } | 744 } |
667 | 745 |
(...skipping 20 matching lines...) Expand all Loading... | |
688 if (observer) | 766 if (observer) |
689 observer->OnBluetoothRefresh(); | 767 observer->OnBluetoothRefresh(); |
690 } | 768 } |
691 | 769 |
692 void NotifyRefreshIME() { | 770 void NotifyRefreshIME() { |
693 ash::IMEObserver* observer = tray_->ime_observer(); | 771 ash::IMEObserver* observer = tray_->ime_observer(); |
694 if (observer) | 772 if (observer) |
695 observer->OnIMERefresh(); | 773 observer->OnIMERefresh(); |
696 } | 774 } |
697 | 775 |
776 void NotifyRefreshDrive(ash::DriveOperationStatusList& list) { | |
777 ash::DriveObserver* observer = tray_->drive_observer(); | |
778 if (observer) | |
779 observer->OnDriveRefresh(list); | |
780 } | |
781 | |
698 void RefreshNetworkObserver(NetworkLibrary* crosnet) { | 782 void RefreshNetworkObserver(NetworkLibrary* crosnet) { |
699 const Network* network = crosnet->active_network(); | 783 const Network* network = crosnet->active_network(); |
700 std::string new_path = network ? network->service_path() : std::string(); | 784 std::string new_path = network ? network->service_path() : std::string(); |
701 if (active_network_path_ != new_path) { | 785 if (active_network_path_ != new_path) { |
702 if (!active_network_path_.empty()) | 786 if (!active_network_path_.empty()) |
703 crosnet->RemoveNetworkObserver(active_network_path_, this); | 787 crosnet->RemoveNetworkObserver(active_network_path_, this); |
704 if (!new_path.empty()) | 788 if (!new_path.empty()) |
705 crosnet->AddNetworkObserver(new_path, this); | 789 crosnet->AddNetworkObserver(new_path, this); |
706 active_network_path_ = new_path; | 790 active_network_path_ = new_path; |
707 } | 791 } |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
865 virtual void InputMethodChanged( | 949 virtual void InputMethodChanged( |
866 input_method::InputMethodManager* manager) OVERRIDE { | 950 input_method::InputMethodManager* manager) OVERRIDE { |
867 NotifyRefreshIME(); | 951 NotifyRefreshIME(); |
868 } | 952 } |
869 | 953 |
870 virtual void InputMethodPropertyChanged( | 954 virtual void InputMethodPropertyChanged( |
871 input_method::InputMethodManager* manager) OVERRIDE { | 955 input_method::InputMethodManager* manager) OVERRIDE { |
872 NotifyRefreshIME(); | 956 NotifyRefreshIME(); |
873 } | 957 } |
874 | 958 |
959 // gdata::GDataOperationRegistry::Observer overrides. | |
960 virtual void OnProgressUpdate( | |
961 const GDataOperationRegistry::ProgressStatusList& list) { | |
962 std::vector<ash::DriveOperationStatus> ui_list = GetDriveStatusList(list); | |
963 NotifyRefreshDrive(ui_list); | |
964 | |
965 // If we have something to report right now (i.e. completion status only), | |
966 // we need to delayed re-check the status in few seconds to ensure we | |
967 // raise events that will let us properly clear the uber tray state. | |
968 if (list.size() > 0) { | |
969 bool has_in_progress_items = false; | |
970 for (GDataOperationRegistry::ProgressStatusList::const_iterator it = | |
971 list.begin(); | |
972 it != list.end(); ++it) { | |
973 if (it->transfer_state == | |
974 GDataOperationRegistry::OPERATION_IN_PROGRESS) { | |
975 has_in_progress_items = true; | |
976 break; | |
977 } | |
978 } | |
979 if (!has_in_progress_items) { | |
980 content::BrowserThread::PostDelayedTask( | |
981 content::BrowserThread::UI, | |
982 FROM_HERE, | |
983 base::Bind(&SystemTrayDelegate::RecheckGDataOperations, | |
984 ui_weak_ptr_factory_->GetWeakPtr()), | |
985 base::TimeDelta::FromMilliseconds(kGDataOperationRecheckDelayMs)); | |
986 } | |
987 } | |
988 | |
xiyuan
2012/05/01 16:47:53
nit: nuke empty line.
| |
989 } | |
990 | |
991 // Pulls the list of ongoing drive operations and initiates status update. | |
992 // This method is needed to ensure delayed cleanup of the latest reported | |
993 // status in UI in cases when there are no new changes coming (i.e. when the | |
994 // last set of transfer operations completed). | |
995 void RecheckGDataOperations() { | |
996 Profile* profile = ProfileManager::GetDefaultProfile(); | |
997 if (!gdata::util::IsGDataAvailable(profile)) | |
998 return; | |
999 | |
1000 GDataSystemService* system_service = | |
1001 GDataSystemServiceFactory::FindForProfile(profile); | |
1002 if (!system_service) | |
1003 return; | |
1004 | |
1005 OnProgressUpdate(system_service->file_system()->GetOperationRegistry()-> | |
1006 GetProgressStatusList()); | |
sadrul
2012/05/01 14:28:58
4-space indent
zel
2012/05/01 16:56:52
Done.
| |
1007 } | |
1008 | |
875 // Overridden from system::TimezoneSettings::Observer. | 1009 // Overridden from system::TimezoneSettings::Observer. |
876 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE { | 1010 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE { |
877 NotifyRefreshClock(); | 1011 NotifyRefreshClock(); |
878 } | 1012 } |
879 | 1013 |
880 // Overridden from BluetoothAdapter::Observer. | 1014 // Overridden from BluetoothAdapter::Observer. |
881 virtual void AdapterPresentChanged(BluetoothAdapter* adapter, | 1015 virtual void AdapterPresentChanged(BluetoothAdapter* adapter, |
882 bool present) OVERRIDE { | 1016 bool present) OVERRIDE { |
883 NotifyRefreshBluetooth(); | 1017 NotifyRefreshBluetooth(); |
884 } | 1018 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
950 | 1084 |
951 if (!deal_url_to_open.empty()) { | 1085 if (!deal_url_to_open.empty()) { |
952 Browser* browser = GetAppropriateBrowser(); | 1086 Browser* browser = GetAppropriateBrowser(); |
953 if (!browser) | 1087 if (!browser) |
954 return; | 1088 return; |
955 browser->ShowSingletonTab(GURL(deal_url_to_open)); | 1089 browser->ShowSingletonTab(GURL(deal_url_to_open)); |
956 } | 1090 } |
957 } | 1091 } |
958 | 1092 |
959 ash::SystemTray* tray_; | 1093 ash::SystemTray* tray_; |
1094 scoped_ptr<base::WeakPtrFactory<SystemTrayDelegate> > ui_weak_ptr_factory_; | |
xiyuan
2012/05/01 16:47:53
nit: Any reason to put base::WeakPtrFactory in a s
| |
960 scoped_ptr<NetworkMenuIcon> network_icon_; | 1095 scoped_ptr<NetworkMenuIcon> network_icon_; |
961 scoped_ptr<NetworkMenuIcon> network_icon_dark_; | 1096 scoped_ptr<NetworkMenuIcon> network_icon_dark_; |
962 scoped_ptr<NetworkMenu> network_menu_; | 1097 scoped_ptr<NetworkMenu> network_menu_; |
963 content::NotificationRegistrar registrar_; | 1098 content::NotificationRegistrar registrar_; |
964 scoped_ptr<PrefChangeRegistrar> pref_registrar_; | 1099 scoped_ptr<PrefChangeRegistrar> pref_registrar_; |
965 std::string cellular_device_path_; | 1100 std::string cellular_device_path_; |
966 std::string active_network_path_; | 1101 std::string active_network_path_; |
967 PowerSupplyStatus power_supply_status_; | 1102 PowerSupplyStatus power_supply_status_; |
968 base::HourClockType clock_type_; | 1103 base::HourClockType clock_type_; |
969 int search_key_mapped_to_; | 1104 int search_key_mapped_to_; |
970 bool screen_locked_; | 1105 bool screen_locked_; |
971 | 1106 |
972 scoped_ptr<BluetoothAdapter> bluetooth_adapter_; | 1107 scoped_ptr<BluetoothAdapter> bluetooth_adapter_; |
973 | 1108 |
974 BooleanPrefMember accessibility_enabled_; | 1109 BooleanPrefMember accessibility_enabled_; |
975 | 1110 |
976 scoped_ptr<DataPromoNotification> data_promo_notification_; | 1111 scoped_ptr<DataPromoNotification> data_promo_notification_; |
977 | 1112 |
978 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); | 1113 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); |
979 }; | 1114 }; |
980 | 1115 |
981 } // namespace | 1116 } // namespace |
982 | 1117 |
983 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { | 1118 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { |
984 return new chromeos::SystemTrayDelegate(tray); | 1119 return new chromeos::SystemTrayDelegate(tray); |
985 } | 1120 } |
986 | 1121 |
987 } // namespace chromeos | 1122 } // namespace chromeos |
OLD | NEW |