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

Side by Side Diff: chrome/browser/chromeos/upgrade_detector_chromeos.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/BUILD.gn ('k') | chrome/browser/resources/settings/about_page/about_page.js » ('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/upgrade_detector_chromeos.h" 5 #include "chrome/browser/chromeos/upgrade_detector_chromeos.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 void UpgradeDetectorChromeos::Shutdown() { 86 void UpgradeDetectorChromeos::Shutdown() {
87 // Init() may not be called from tests. 87 // Init() may not be called from tests.
88 if (!initialized_) 88 if (!initialized_)
89 return; 89 return;
90 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); 90 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this);
91 } 91 }
92 92
93 void UpgradeDetectorChromeos::UpdateStatusChanged( 93 void UpgradeDetectorChromeos::UpdateStatusChanged(
94 const UpdateEngineClient::Status& status) { 94 const UpdateEngineClient::Status& status) {
95 if (status.status != UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT) 95 if (status.status == UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT) {
96 return; 96 upgrade_detected_time_ = base::Time::Now();
97 97
98 upgrade_detected_time_ = base::Time::Now(); 98 channels_requester_.reset(new UpgradeDetectorChromeos::ChannelsRequester());
99 99 channels_requester_->RequestChannels(
100 channels_requester_.reset(new UpgradeDetectorChromeos::ChannelsRequester()); 100 base::Bind(&UpgradeDetectorChromeos::OnChannelsReceived,
101 channels_requester_->RequestChannels( 101 weak_factory_.GetWeakPtr()));
102 base::Bind(&UpgradeDetectorChromeos::OnChannelsReceived, 102 } else if (status.status ==
103 weak_factory_.GetWeakPtr())); 103 UpdateEngineClient::UPDATE_STATUS_NEED_PERMISSION_TO_UPDATE) {
104 // Update engine broadcasts this state only when update is available but
105 // downloading over cellular connection requires user's agreement
106 NotifyUpdateOverCellularAvailable();
107 }
104 } 108 }
105 109
106 void UpgradeDetectorChromeos::NotifyOnUpgrade() { 110 void UpgradeDetectorChromeos::NotifyOnUpgrade() {
107 base::TimeDelta delta = base::Time::Now() - upgrade_detected_time_; 111 base::TimeDelta delta = base::Time::Now() - upgrade_detected_time_;
108 int64_t time_passed = delta.InDays(); 112 int64_t time_passed = delta.InDays();
109 113
110 const int kSevereThreshold = 7; 114 const int kSevereThreshold = 7;
111 const int kHighThreshold = 4; 115 const int kHighThreshold = 4;
112 const int kElevatedThreshold = 2; 116 const int kElevatedThreshold = 2;
113 const int kLowThreshold = 0; 117 const int kLowThreshold = 0;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 157
154 // static 158 // static
155 UpgradeDetectorChromeos* UpgradeDetectorChromeos::GetInstance() { 159 UpgradeDetectorChromeos* UpgradeDetectorChromeos::GetInstance() {
156 return base::Singleton<UpgradeDetectorChromeos>::get(); 160 return base::Singleton<UpgradeDetectorChromeos>::get();
157 } 161 }
158 162
159 // static 163 // static
160 UpgradeDetector* UpgradeDetector::GetInstance() { 164 UpgradeDetector* UpgradeDetector::GetInstance() {
161 return UpgradeDetectorChromeos::GetInstance(); 165 return UpgradeDetectorChromeos::GetInstance();
162 } 166 }
OLDNEW
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/resources/settings/about_page/about_page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698