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

Side by Side Diff: chrome/browser/ui/ash/system_tray_client.cc

Issue 2882933002: Add update available icon in system tray (Closed)
Patch Set: Add file to BUILD.gn Created 3 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
« no previous file with comments | « chrome/browser/ui/ash/system_tray_client.h ('k') | chrome/browser/upgrade_detector.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ui/ash/system_tray_client.h" 5 #include "chrome/browser/ui/ash/system_tray_client.h"
6 6
7 #include "ash/login_status.h" 7 #include "ash/login_status.h"
8 #include "ash/public/cpp/shell_window_ids.h" 8 #include "ash/public/cpp/shell_window_ids.h"
9 #include "ash/public/interfaces/constants.mojom.h" 9 #include "ash/public/interfaces/constants.mojom.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "base/feature_list.h" 11 #include "base/feature_list.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/weak_ptr.h"
13 #include "base/metrics/user_metrics.h" 14 #include "base/metrics/user_metrics.h"
14 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/browser_process_platform_part.h" 16 #include "chrome/browser/browser_process_platform_part.h"
16 #include "chrome/browser/chrome_notification_types.h" 17 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 18 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
18 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h" 19 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h"
19 #include "chrome/browser/chromeos/login/help_app_launcher.h" 20 #include "chrome/browser/chromeos/login/help_app_launcher.h"
20 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 21 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
21 #include "chrome/browser/chromeos/options/network_config_view.h" 22 #include "chrome/browser/chromeos/options/network_config_view.h"
22 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 23 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "services/service_manager/public/cpp/connector.h" 55 #include "services/service_manager/public/cpp/connector.h"
55 #include "services/ui/public/cpp/property_type_converters.h" 56 #include "services/ui/public/cpp/property_type_converters.h"
56 #include "services/ui/public/interfaces/window_manager.mojom.h" 57 #include "services/ui/public/interfaces/window_manager.mojom.h"
57 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h" 58 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h"
58 #include "ui/views/widget/widget.h" 59 #include "ui/views/widget/widget.h"
59 #include "ui/views/window/dialog_delegate.h" 60 #include "ui/views/window/dialog_delegate.h"
60 61
61 using chromeos::BluetoothPairingDialog; 62 using chromeos::BluetoothPairingDialog;
62 using chromeos::DBusThreadManager; 63 using chromeos::DBusThreadManager;
63 using chromeos::LoginState; 64 using chromeos::LoginState;
65 using chromeos::UpdateEngineClient;
64 using device::BluetoothDevice; 66 using device::BluetoothDevice;
65 using views::Widget; 67 using views::Widget;
66 68
67 namespace { 69 namespace {
68 70
69 SystemTrayClient* g_instance = nullptr; 71 SystemTrayClient* g_instance = nullptr;
70 72
71 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { 73 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) {
72 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), 74 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(),
73 sub_page); 75 sub_page);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 policy::BrowserPolicyConnectorChromeOS* policy_connector = 119 policy::BrowserPolicyConnectorChromeOS* policy_connector =
118 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 120 g_browser_process->platform_part()->browser_policy_connector_chromeos();
119 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 121 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
120 policy_connector->GetDeviceCloudPolicyManager(); 122 policy_connector->GetDeviceCloudPolicyManager();
121 if (policy_manager) 123 if (policy_manager)
122 policy_manager->core()->store()->AddObserver(this); 124 policy_manager->core()->store()->AddObserver(this);
123 UpdateEnterpriseDomain(); 125 UpdateEnterpriseDomain();
124 126
125 DCHECK(!g_instance); 127 DCHECK(!g_instance);
126 g_instance = this; 128 g_instance = this;
129 UpgradeDetector::GetInstance()->AddObserver(this);
127 } 130 }
128 131
129 SystemTrayClient::~SystemTrayClient() { 132 SystemTrayClient::~SystemTrayClient() {
130 DCHECK_EQ(this, g_instance); 133 DCHECK_EQ(this, g_instance);
131 g_instance = nullptr; 134 g_instance = nullptr;
132 135
133 policy::BrowserPolicyConnectorChromeOS* connector = 136 policy::BrowserPolicyConnectorChromeOS* connector =
134 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 137 g_browser_process->platform_part()->browser_policy_connector_chromeos();
135 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 138 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
136 connector->GetDeviceCloudPolicyManager(); 139 connector->GetDeviceCloudPolicyManager();
137 if (policy_manager) 140 if (policy_manager)
138 policy_manager->core()->store()->RemoveObserver(this); 141 policy_manager->core()->store()->RemoveObserver(this);
139 142
140 g_browser_process->platform_part()->GetSystemClock()->RemoveObserver(this); 143 g_browser_process->platform_part()->GetSystemClock()->RemoveObserver(this);
144 UpgradeDetector::GetInstance()->RemoveObserver(this);
141 } 145 }
142 146
143 // static 147 // static
144 SystemTrayClient* SystemTrayClient::Get() { 148 SystemTrayClient* SystemTrayClient::Get() {
145 return g_instance; 149 return g_instance;
146 } 150 }
147 151
148 // static 152 // static
149 ash::LoginStatus SystemTrayClient::GetUserLoginStatus() { 153 ash::LoginStatus SystemTrayClient::GetUserLoginStatus() {
150 if (!LoginState::Get()->IsUserLoggedIn()) 154 if (!LoginState::Get()->IsUserLoggedIn())
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 chrome::ScopedTabbedBrowserDisplayer displayer( 291 chrome::ScopedTabbedBrowserDisplayer displayer(
288 ProfileManager::GetPrimaryUserProfile()); 292 ProfileManager::GetPrimaryUserProfile());
289 chrome::ShowSlow(displayer.browser()); 293 chrome::ShowSlow(displayer.browser());
290 } 294 }
291 295
292 void SystemTrayClient::ShowIMESettings() { 296 void SystemTrayClient::ShowIMESettings() {
293 base::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog")); 297 base::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog"));
294 ShowSettingsSubPageForActiveUser(chrome::kLanguageOptionsSubPage); 298 ShowSettingsSubPageForActiveUser(chrome::kLanguageOptionsSubPage);
295 } 299 }
296 300
301 void SystemTrayClient::ShowAboutChromeOS() {
302 // We always want to check for updates when showing the about page from the
303 // Ash UI.
304 ShowSettingsSubPageForActiveUser(std::string(chrome::kHelpSubPage) +
305 "?checkForUpdate=true");
306 }
307
297 void SystemTrayClient::ShowHelp() { 308 void SystemTrayClient::ShowHelp() {
298 chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(), 309 chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(),
299 chrome::HELP_SOURCE_MENU); 310 chrome::HELP_SOURCE_MENU);
300 } 311 }
301 312
302 void SystemTrayClient::ShowAccessibilityHelp() { 313 void SystemTrayClient::ShowAccessibilityHelp() {
303 chrome::ScopedTabbedBrowserDisplayer displayer( 314 chrome::ScopedTabbedBrowserDisplayer displayer(
304 ProfileManager::GetActiveUserProfile()); 315 ProfileManager::GetActiveUserProfile());
305 chromeos::accessibility::ShowAccessibilityHelp(displayer.browser()); 316 chromeos::accessibility::ShowAccessibilityHelp(displayer.browser());
306 } 317 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 // Show a string specific to updating flash player if there is no system 464 // Show a string specific to updating flash player if there is no system
454 // update. 465 // update.
455 ash::mojom::UpdateType update_type = detector->notify_upgrade() 466 ash::mojom::UpdateType update_type = detector->notify_upgrade()
456 ? ash::mojom::UpdateType::SYSTEM 467 ? ash::mojom::UpdateType::SYSTEM
457 : ash::mojom::UpdateType::FLASH; 468 : ash::mojom::UpdateType::FLASH;
458 469
459 system_tray_->ShowUpdateIcon(severity, detector->is_factory_reset_required(), 470 system_tray_->ShowUpdateIcon(severity, detector->is_factory_reset_required(),
460 update_type); 471 update_type);
461 } 472 }
462 473
474 void SystemTrayClient::HandleUpdateOverCellularAvailable() {
475 system_tray_->ShowUpdateOverCellularAvailableIcon();
476 }
477
463 //////////////////////////////////////////////////////////////////////////////// 478 ////////////////////////////////////////////////////////////////////////////////
464 // chromeos::system::SystemClockObserver: 479 // chromeos::system::SystemClockObserver:
465 480
466 void SystemTrayClient::OnSystemClockChanged( 481 void SystemTrayClient::OnSystemClockChanged(
467 chromeos::system::SystemClock* clock) { 482 chromeos::system::SystemClock* clock) {
468 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); 483 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock());
469 } 484 }
470 485
471 void SystemTrayClient::Observe(int type, 486 void SystemTrayClient::Observe(int type,
472 const content::NotificationSource& source, 487 const content::NotificationSource& source,
473 const content::NotificationDetails& details) { 488 const content::NotificationDetails& details) {
474 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type); 489 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type);
475 HandleUpdateAvailable(); 490 HandleUpdateAvailable();
476 } 491 }
477 492
478 //////////////////////////////////////////////////////////////////////////////// 493 ////////////////////////////////////////////////////////////////////////////////
494 // UpgradeDetector::UpgradeObserver:
495 void SystemTrayClient::OnUpdateOverCellularAvailable() {
496 HandleUpdateOverCellularAvailable();
497 }
498
499 ////////////////////////////////////////////////////////////////////////////////
479 // policy::CloudPolicyStore::Observer 500 // policy::CloudPolicyStore::Observer
480 void SystemTrayClient::OnStoreLoaded(policy::CloudPolicyStore* store) { 501 void SystemTrayClient::OnStoreLoaded(policy::CloudPolicyStore* store) {
481 UpdateEnterpriseDomain(); 502 UpdateEnterpriseDomain();
482 } 503 }
483 504
484 void SystemTrayClient::OnStoreError(policy::CloudPolicyStore* store) { 505 void SystemTrayClient::OnStoreError(policy::CloudPolicyStore* store) {
485 UpdateEnterpriseDomain(); 506 UpdateEnterpriseDomain();
486 } 507 }
487 508
488 void SystemTrayClient::UpdateEnterpriseDomain() { 509 void SystemTrayClient::UpdateEnterpriseDomain() {
489 policy::BrowserPolicyConnectorChromeOS* connector = 510 policy::BrowserPolicyConnectorChromeOS* connector =
490 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 511 g_browser_process->platform_part()->browser_policy_connector_chromeos();
491 const std::string enterprise_domain = connector->GetEnterpriseDomain(); 512 const std::string enterprise_domain = connector->GetEnterpriseDomain();
492 const bool active_directory_managed = connector->IsActiveDirectoryManaged(); 513 const bool active_directory_managed = connector->IsActiveDirectoryManaged();
493 if (enterprise_domain == last_enterprise_domain_ && 514 if (enterprise_domain == last_enterprise_domain_ &&
494 active_directory_managed == last_active_directory_managed_) { 515 active_directory_managed == last_active_directory_managed_) {
495 return; 516 return;
496 } 517 }
497 // Send to ash, which will add an item to the system tray. 518 // Send to ash, which will add an item to the system tray.
498 system_tray_->SetEnterpriseDomain(enterprise_domain, 519 system_tray_->SetEnterpriseDomain(enterprise_domain,
499 active_directory_managed); 520 active_directory_managed);
500 last_enterprise_domain_ = enterprise_domain; 521 last_enterprise_domain_ = enterprise_domain;
501 last_active_directory_managed_ = active_directory_managed; 522 last_active_directory_managed_ = active_directory_managed;
502 } 523 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/system_tray_client.h ('k') | chrome/browser/upgrade_detector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698