Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: chrome/browser/chromeos/system/ash_system_tray_delegate.cc

Issue 10285002: Revert 134774 because of win aura compile and chromium os browser_test crashes - Created uber tray … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_util.cc ('k') | ui/resources/ui_resources.grd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
14 #include "ash/system/ime/ime_observer.h" 13 #include "ash/system/ime/ime_observer.h"
15 #include "ash/system/network/network_observer.h" 14 #include "ash/system/network/network_observer.h"
16 #include "ash/system/power/power_status_observer.h" 15 #include "ash/system/power/power_status_observer.h"
17 #include "ash/system/tray/system_tray.h" 16 #include "ash/system/tray/system_tray.h"
18 #include "ash/system/tray/system_tray_delegate.h" 17 #include "ash/system/tray/system_tray_delegate.h"
19 #include "ash/system/tray_accessibility.h" 18 #include "ash/system/tray_accessibility.h"
20 #include "ash/system/tray_caps_lock.h" 19 #include "ash/system/tray_caps_lock.h"
21 #include "ash/system/user/update_observer.h" 20 #include "ash/system/user/update_observer.h"
22 #include "ash/system/user/user_observer.h" 21 #include "ash/system/user/user_observer.h"
23 #include "base/chromeos/chromeos_version.h" 22 #include "base/chromeos/chromeos_version.h"
24 #include "base/logging.h" 23 #include "base/logging.h"
25 #include "base/memory/weak_ptr.h"
26 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
27 #include "chrome/browser/browser_process.h" 25 #include "chrome/browser/browser_process.h"
28 #include "chrome/browser/chromeos/audio/audio_handler.h" 26 #include "chrome/browser/chromeos/audio/audio_handler.h"
29 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" 27 #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h"
30 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" 28 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h"
31 #include "chrome/browser/chromeos/cros/cros_library.h" 29 #include "chrome/browser/chromeos/cros/cros_library.h"
32 #include "chrome/browser/chromeos/cros/network_library.h" 30 #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"
35 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 31 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
36 #include "chrome/browser/chromeos/input_method/input_method_util.h" 32 #include "chrome/browser/chromeos/input_method/input_method_util.h"
37 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" 33 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h"
38 #include "chrome/browser/chromeos/input_method/xkeyboard.h" 34 #include "chrome/browser/chromeos/input_method/xkeyboard.h"
39 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" 35 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
40 #include "chrome/browser/chromeos/login/base_login_display_host.h" 36 #include "chrome/browser/chromeos/login/base_login_display_host.h"
41 #include "chrome/browser/chromeos/login/login_display_host.h" 37 #include "chrome/browser/chromeos/login/login_display_host.h"
42 #include "chrome/browser/chromeos/login/message_bubble.h" 38 #include "chrome/browser/chromeos/login/message_bubble.h"
43 #include "chrome/browser/chromeos/login/user.h" 39 #include "chrome/browser/chromeos/login/user.h"
44 #include "chrome/browser/chromeos/login/user_manager.h" 40 #include "chrome/browser/chromeos/login/user_manager.h"
45 #include "chrome/browser/chromeos/mobile_config.h" 41 #include "chrome/browser/chromeos/mobile_config.h"
46 #include "chrome/browser/chromeos/status/data_promo_notification.h" 42 #include "chrome/browser/chromeos/status/data_promo_notification.h"
47 #include "chrome/browser/chromeos/status/network_menu.h" 43 #include "chrome/browser/chromeos/status/network_menu.h"
48 #include "chrome/browser/chromeos/status/network_menu_icon.h" 44 #include "chrome/browser/chromeos/status/network_menu_icon.h"
49 #include "chrome/browser/chromeos/system/timezone_settings.h" 45 #include "chrome/browser/chromeos/system/timezone_settings.h"
50 #include "chrome/browser/chromeos/system_key_event_listener.h" 46 #include "chrome/browser/chromeos/system_key_event_listener.h"
51 #include "chrome/browser/prefs/pref_service.h" 47 #include "chrome/browser/prefs/pref_service.h"
52 #include "chrome/browser/profiles/profile_manager.h" 48 #include "chrome/browser/profiles/profile_manager.h"
53 #include "chrome/browser/ui/browser.h" 49 #include "chrome/browser/ui/browser.h"
54 #include "chrome/browser/ui/browser_list.h" 50 #include "chrome/browser/ui/browser_list.h"
55 #include "chrome/browser/upgrade_detector.h" 51 #include "chrome/browser/upgrade_detector.h"
56 #include "chrome/common/chrome_notification_types.h" 52 #include "chrome/common/chrome_notification_types.h"
57 #include "chrome/common/pref_names.h" 53 #include "chrome/common/pref_names.h"
58 #include "chrome/common/url_constants.h" 54 #include "chrome/common/url_constants.h"
59 #include "chromeos/dbus/dbus_thread_manager.h" 55 #include "chromeos/dbus/dbus_thread_manager.h"
60 #include "chromeos/dbus/power_manager_client.h" 56 #include "chromeos/dbus/power_manager_client.h"
61 #include "content/public/browser/browser_thread.h"
62 #include "content/public/browser/notification_observer.h" 57 #include "content/public/browser/notification_observer.h"
63 #include "content/public/browser/notification_service.h" 58 #include "content/public/browser/notification_service.h"
64 #include "content/public/browser/user_metrics.h" 59 #include "content/public/browser/user_metrics.h"
65 #include "grit/generated_resources.h" 60 #include "grit/generated_resources.h"
66 #include "ui/base/l10n/l10n_util.h" 61 #include "ui/base/l10n/l10n_util.h"
67 62
68 using gdata::GDataFileSystem;
69 using gdata::GDataOperationRegistry;
70 using gdata::GDataSystemService;
71 using gdata::GDataSystemServiceFactory;
72
73 namespace chromeos { 63 namespace chromeos {
74 64
75 namespace { 65 namespace {
76 66
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
81 bool ShouldShowNetworkIconInTray(const Network* network) { 67 bool ShouldShowNetworkIconInTray(const Network* network) {
82 if (!network) 68 if (!network)
83 return true; 69 return true;
84 return !network->connected() || network->type() != TYPE_ETHERNET; 70 return !network->connected() || network->type() != TYPE_ETHERNET;
85 } 71 }
86 72
87 ash::NetworkIconInfo CreateNetworkIconInfo(const Network* network, 73 ash::NetworkIconInfo CreateNetworkIconInfo(const Network* network,
88 NetworkMenuIcon* network_icon, 74 NetworkMenuIcon* network_icon,
89 NetworkMenu* network_menu) { 75 NetworkMenu* network_menu) {
90 ash::NetworkIconInfo info; 76 ash::NetworkIconInfo info;
91 info.name = UTF8ToUTF16(network->name()); 77 info.name = UTF8ToUTF16(network->name());
92 info.image = network_icon->GetBitmap(network, NetworkMenuIcon::COLOR_DARK); 78 info.image = network_icon->GetBitmap(network, NetworkMenuIcon::COLOR_DARK);
93 info.service_path = network->service_path(); 79 info.service_path = network->service_path();
94 info.highlight = network_menu->ShouldHighlightNetwork(network); 80 info.highlight = network_menu->ShouldHighlightNetwork(network);
95 info.tray_icon_visible = ShouldShowNetworkIconInTray(network); 81 info.tray_icon_visible = ShouldShowNetworkIconInTray(network);
96 return info; 82 return info;
97 } 83 }
98 84
99 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, 85 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime,
100 const input_method::InputMethodUtil& util, 86 const input_method::InputMethodUtil& util,
101 ash::IMEInfo* info) { 87 ash::IMEInfo* info) {
102 info->id = ime.id(); 88 info->id = ime.id();
103 info->name = util.GetInputMethodLongName(ime); 89 info->name = util.GetInputMethodLongName(ime);
104 info->short_name = util.GetInputMethodShortName(ime); 90 info->short_name = util.GetInputMethodShortName(ime);
105 } 91 }
106 92
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 }
126 93
127 void BluetoothPowerFailure() { 94 void BluetoothPowerFailure() {
128 // TODO(sad): Show an error bubble? 95 // TODO(sad): Show an error bubble?
129 } 96 }
130 97
131 void BluetoothDiscoveryFailure() { 98 void BluetoothDiscoveryFailure() {
132 // TODO(sad): Show an error bubble? 99 // TODO(sad): Show an error bubble?
133 } 100 }
134 101
135 void BluetoothDeviceDisconnectError() { 102 void BluetoothDeviceDisconnectError() {
136 // TODO(sad): Do something? 103 // TODO(sad): Do something?
137 } 104 }
138 105
139 void BluetoothDeviceConnectError() { 106 void BluetoothDeviceConnectError() {
140 // TODO(sad): Do something? 107 // TODO(sad): Do something?
141 } 108 }
142 109
143 class SystemTrayDelegate : public ash::SystemTrayDelegate, 110 class SystemTrayDelegate : public ash::SystemTrayDelegate,
144 public AudioHandler::VolumeObserver, 111 public AudioHandler::VolumeObserver,
145 public PowerManagerClient::Observer, 112 public PowerManagerClient::Observer,
146 public NetworkMenuIcon::Delegate, 113 public NetworkMenuIcon::Delegate,
147 public NetworkMenu::Delegate, 114 public NetworkMenu::Delegate,
148 public NetworkLibrary::NetworkManagerObserver, 115 public NetworkLibrary::NetworkManagerObserver,
149 public NetworkLibrary::NetworkObserver, 116 public NetworkLibrary::NetworkObserver,
150 public NetworkLibrary::CellularDataPlanObserver, 117 public NetworkLibrary::CellularDataPlanObserver,
151 public gdata::GDataOperationRegistry::Observer,
152 public content::NotificationObserver, 118 public content::NotificationObserver,
153 public input_method::InputMethodManager::Observer, 119 public input_method::InputMethodManager::Observer,
154 public system::TimezoneSettings::Observer, 120 public system::TimezoneSettings::Observer,
155 public BluetoothAdapter::Observer, 121 public BluetoothAdapter::Observer,
156 public SystemKeyEventListener::CapsLockObserver, 122 public SystemKeyEventListener::CapsLockObserver,
157 public MessageBubbleLinkListener { 123 public MessageBubbleLinkListener {
158 public: 124 public:
159 explicit SystemTrayDelegate(ash::SystemTray* tray) 125 explicit SystemTrayDelegate(ash::SystemTray* tray)
160 : tray_(tray), 126 : tray_(tray),
161 ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(
162 new base::WeakPtrFactory<SystemTrayDelegate>(this))),
163 network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST( 127 network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST(
164 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), 128 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))),
165 network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST( 129 network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST(
166 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), 130 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))),
167 network_menu_(ALLOW_THIS_IN_INITIALIZER_LIST(new NetworkMenu(this))), 131 network_menu_(ALLOW_THIS_IN_INITIALIZER_LIST(new NetworkMenu(this))),
168 clock_type_(base::k24HourClock), 132 clock_type_(base::k24HourClock),
169 search_key_mapped_to_(input_method::kSearchKey), 133 search_key_mapped_to_(input_method::kSearchKey),
170 screen_locked_(false), 134 screen_locked_(false),
171 data_promo_notification_(new DataPromoNotification()) { 135 data_promo_notification_(new DataPromoNotification()) {
172 AudioHandler::GetInstance()->AddVolumeObserver(this); 136 AudioHandler::GetInstance()->AddVolumeObserver(this);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 virtual void ShowNetworkSettings() OVERRIDE { 263 virtual void ShowNetworkSettings() OVERRIDE {
300 content::RecordAction( 264 content::RecordAction(
301 content::UserMetricsAction("OpenInternetOptionsDialog")); 265 content::UserMetricsAction("OpenInternetOptionsDialog"));
302 GetAppropriateBrowser()->ShowOptionsTab(chrome::kInternetOptionsSubPage); 266 GetAppropriateBrowser()->ShowOptionsTab(chrome::kInternetOptionsSubPage);
303 } 267 }
304 268
305 virtual void ShowBluetoothSettings() OVERRIDE { 269 virtual void ShowBluetoothSettings() OVERRIDE {
306 // TODO(sad): Make this work. 270 // TODO(sad): Make this work.
307 } 271 }
308 272
309 virtual void ShowDriveSettings() OVERRIDE {
310 // TODO(zelidrag): Show settings once we put them in.
311 }
312
313 virtual void ShowIMESettings() OVERRIDE { 273 virtual void ShowIMESettings() OVERRIDE {
314 content::RecordAction( 274 content::RecordAction(
315 content::UserMetricsAction("OpenLanguageOptionsDialog")); 275 content::UserMetricsAction("OpenLanguageOptionsDialog"));
316 GetAppropriateBrowser()->ShowOptionsTab(chrome::kLanguageOptionsSubPage); 276 GetAppropriateBrowser()->ShowOptionsTab(chrome::kLanguageOptionsSubPage);
317 } 277 }
318 278
319 virtual void ShowHelp() OVERRIDE { 279 virtual void ShowHelp() OVERRIDE {
320 GetAppropriateBrowser()->ShowHelpTab(); 280 GetAppropriateBrowser()->ShowHelpTab();
321 } 281 }
322 282
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 397
438 virtual void SwitchIME(const std::string& ime_id) OVERRIDE { 398 virtual void SwitchIME(const std::string& ime_id) OVERRIDE {
439 input_method::InputMethodManager::GetInstance()->ChangeInputMethod(ime_id); 399 input_method::InputMethodManager::GetInstance()->ChangeInputMethod(ime_id);
440 } 400 }
441 401
442 virtual void ActivateIMEProperty(const std::string& key) OVERRIDE { 402 virtual void ActivateIMEProperty(const std::string& key) OVERRIDE {
443 input_method::InputMethodManager::GetInstance()-> 403 input_method::InputMethodManager::GetInstance()->
444 ActivateInputMethodProperty(key); 404 ActivateInputMethodProperty(key);
445 } 405 }
446 406
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
478 virtual void GetMostRelevantNetworkIcon(ash::NetworkIconInfo* info, 407 virtual void GetMostRelevantNetworkIcon(ash::NetworkIconInfo* info,
479 bool dark) OVERRIDE { 408 bool dark) OVERRIDE {
480 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); 409 NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
481 info->image = !dark ? network_icon_->GetIconAndText(&info->description) : 410 info->image = !dark ? network_icon_->GetIconAndText(&info->description) :
482 network_icon_dark_->GetIconAndText(&info->description); 411 network_icon_dark_->GetIconAndText(&info->description);
483 info->tray_icon_visible = 412 info->tray_icon_visible =
484 ShouldShowNetworkIconInTray(crosnet->connected_network()); 413 ShouldShowNetworkIconInTray(crosnet->connected_network());
485 } 414 }
486 415
487 virtual void GetAvailableNetworks( 416 virtual void GetAvailableNetworks(
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 } 648 }
720 649
721 void SetProfile(Profile* profile) { 650 void SetProfile(Profile* profile) {
722 pref_registrar_.reset(new PrefChangeRegistrar); 651 pref_registrar_.reset(new PrefChangeRegistrar);
723 pref_registrar_->Init(profile->GetPrefs()); 652 pref_registrar_->Init(profile->GetPrefs());
724 pref_registrar_->Add(prefs::kUse24HourClock, this); 653 pref_registrar_->Add(prefs::kUse24HourClock, this);
725 pref_registrar_->Add(prefs::kLanguageXkbRemapSearchKeyTo, this); 654 pref_registrar_->Add(prefs::kLanguageXkbRemapSearchKeyTo, this);
726 UpdateClockType(profile->GetPrefs()); 655 UpdateClockType(profile->GetPrefs());
727 search_key_mapped_to_ = 656 search_key_mapped_to_ =
728 profile->GetPrefs()->GetInteger(prefs::kLanguageXkbRemapSearchKeyTo); 657 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 }
736 } 658 }
737 659
738 void UpdateClockType(PrefService* service) { 660 void UpdateClockType(PrefService* service) {
739 clock_type_ = service->GetBoolean(prefs::kUse24HourClock) ? 661 clock_type_ = service->GetBoolean(prefs::kUse24HourClock) ?
740 base::k24HourClock : base::k12HourClock; 662 base::k24HourClock : base::k12HourClock;
741 ash::ClockObserver* observer = tray_->clock_observer(); 663 ash::ClockObserver* observer = tray_->clock_observer();
742 if (observer) 664 if (observer)
743 observer->OnDateFormatChanged(); 665 observer->OnDateFormatChanged();
744 } 666 }
745 667
(...skipping 20 matching lines...) Expand all
766 if (observer) 688 if (observer)
767 observer->OnBluetoothRefresh(); 689 observer->OnBluetoothRefresh();
768 } 690 }
769 691
770 void NotifyRefreshIME() { 692 void NotifyRefreshIME() {
771 ash::IMEObserver* observer = tray_->ime_observer(); 693 ash::IMEObserver* observer = tray_->ime_observer();
772 if (observer) 694 if (observer)
773 observer->OnIMERefresh(); 695 observer->OnIMERefresh();
774 } 696 }
775 697
776 void NotifyRefreshDrive(ash::DriveOperationStatusList& list) {
777 ash::DriveObserver* observer = tray_->drive_observer();
778 if (observer)
779 observer->OnDriveRefresh(list);
780 }
781
782 void RefreshNetworkObserver(NetworkLibrary* crosnet) { 698 void RefreshNetworkObserver(NetworkLibrary* crosnet) {
783 const Network* network = crosnet->active_network(); 699 const Network* network = crosnet->active_network();
784 std::string new_path = network ? network->service_path() : std::string(); 700 std::string new_path = network ? network->service_path() : std::string();
785 if (active_network_path_ != new_path) { 701 if (active_network_path_ != new_path) {
786 if (!active_network_path_.empty()) 702 if (!active_network_path_.empty())
787 crosnet->RemoveNetworkObserver(active_network_path_, this); 703 crosnet->RemoveNetworkObserver(active_network_path_, this);
788 if (!new_path.empty()) 704 if (!new_path.empty())
789 crosnet->AddNetworkObserver(new_path, this); 705 crosnet->AddNetworkObserver(new_path, this);
790 active_network_path_ = new_path; 706 active_network_path_ = new_path;
791 } 707 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 virtual void InputMethodChanged( 865 virtual void InputMethodChanged(
950 input_method::InputMethodManager* manager) OVERRIDE { 866 input_method::InputMethodManager* manager) OVERRIDE {
951 NotifyRefreshIME(); 867 NotifyRefreshIME();
952 } 868 }
953 869
954 virtual void InputMethodPropertyChanged( 870 virtual void InputMethodPropertyChanged(
955 input_method::InputMethodManager* manager) OVERRIDE { 871 input_method::InputMethodManager* manager) OVERRIDE {
956 NotifyRefreshIME(); 872 NotifyRefreshIME();
957 } 873 }
958 874
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_STARTED ||
975 it->transfer_state ==
976 GDataOperationRegistry::OPERATION_IN_PROGRESS ||
977 it->transfer_state ==
978 GDataOperationRegistry::OPERATION_SUSPENDED) {
979 has_in_progress_items = true;
980 break;
981 }
982 }
983
984 if (!has_in_progress_items) {
985 content::BrowserThread::PostDelayedTask(
986 content::BrowserThread::UI,
987 FROM_HERE,
988 base::Bind(&SystemTrayDelegate::RecheckGDataOperations,
989 ui_weak_ptr_factory_->GetWeakPtr()),
990 base::TimeDelta::FromMilliseconds(kGDataOperationRecheckDelayMs));
991 }
992 }
993
994 }
995
996 // Pulls the list of ongoing drive operations and initiates status update.
997 // This method is needed to ensure delayed cleanup of the latest reported
998 // status in UI in cases when there are no new changes coming (i.e. when the
999 // last set of transfer operations completed).
1000 void RecheckGDataOperations() {
1001 Profile* profile = ProfileManager::GetDefaultProfile();
1002 if (!gdata::util::IsGDataAvailable(profile))
1003 return;
1004
1005 GDataSystemService* system_service =
1006 GDataSystemServiceFactory::FindForProfile(profile);
1007 if (!system_service)
1008 return;
1009
1010 OnProgressUpdate(system_service->file_system()->GetOperationRegistry()->
1011 GetProgressStatusList());
1012 }
1013
1014 // Overridden from system::TimezoneSettings::Observer. 875 // Overridden from system::TimezoneSettings::Observer.
1015 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE { 876 virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE {
1016 NotifyRefreshClock(); 877 NotifyRefreshClock();
1017 } 878 }
1018 879
1019 // Overridden from BluetoothAdapter::Observer. 880 // Overridden from BluetoothAdapter::Observer.
1020 virtual void AdapterPresentChanged(BluetoothAdapter* adapter, 881 virtual void AdapterPresentChanged(BluetoothAdapter* adapter,
1021 bool present) OVERRIDE { 882 bool present) OVERRIDE {
1022 NotifyRefreshBluetooth(); 883 NotifyRefreshBluetooth();
1023 } 884 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 950
1090 if (!deal_url_to_open.empty()) { 951 if (!deal_url_to_open.empty()) {
1091 Browser* browser = GetAppropriateBrowser(); 952 Browser* browser = GetAppropriateBrowser();
1092 if (!browser) 953 if (!browser)
1093 return; 954 return;
1094 browser->ShowSingletonTab(GURL(deal_url_to_open)); 955 browser->ShowSingletonTab(GURL(deal_url_to_open));
1095 } 956 }
1096 } 957 }
1097 958
1098 ash::SystemTray* tray_; 959 ash::SystemTray* tray_;
1099 scoped_ptr<base::WeakPtrFactory<SystemTrayDelegate> > ui_weak_ptr_factory_;
1100 scoped_ptr<NetworkMenuIcon> network_icon_; 960 scoped_ptr<NetworkMenuIcon> network_icon_;
1101 scoped_ptr<NetworkMenuIcon> network_icon_dark_; 961 scoped_ptr<NetworkMenuIcon> network_icon_dark_;
1102 scoped_ptr<NetworkMenu> network_menu_; 962 scoped_ptr<NetworkMenu> network_menu_;
1103 content::NotificationRegistrar registrar_; 963 content::NotificationRegistrar registrar_;
1104 scoped_ptr<PrefChangeRegistrar> pref_registrar_; 964 scoped_ptr<PrefChangeRegistrar> pref_registrar_;
1105 std::string cellular_device_path_; 965 std::string cellular_device_path_;
1106 std::string active_network_path_; 966 std::string active_network_path_;
1107 PowerSupplyStatus power_supply_status_; 967 PowerSupplyStatus power_supply_status_;
1108 base::HourClockType clock_type_; 968 base::HourClockType clock_type_;
1109 int search_key_mapped_to_; 969 int search_key_mapped_to_;
1110 bool screen_locked_; 970 bool screen_locked_;
1111 971
1112 scoped_ptr<BluetoothAdapter> bluetooth_adapter_; 972 scoped_ptr<BluetoothAdapter> bluetooth_adapter_;
1113 973
1114 BooleanPrefMember accessibility_enabled_; 974 BooleanPrefMember accessibility_enabled_;
1115 975
1116 scoped_ptr<DataPromoNotification> data_promo_notification_; 976 scoped_ptr<DataPromoNotification> data_promo_notification_;
1117 977
1118 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); 978 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate);
1119 }; 979 };
1120 980
1121 } // namespace 981 } // namespace
1122 982
1123 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) { 983 ash::SystemTrayDelegate* CreateSystemTrayDelegate(ash::SystemTray* tray) {
1124 return new chromeos::SystemTrayDelegate(tray); 984 return new chromeos::SystemTrayDelegate(tray);
1125 } 985 }
1126 986
1127 } // namespace chromeos 987 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_util.cc ('k') | ui/resources/ui_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698