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/ui/webui/help/version_updater_chromeos.h" | 5 #include "chrome/browser/ui/webui/help/version_updater_chromeos.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/chromeos/login/startup_utils.h" | 12 #include "chrome/browser/chromeos/login/startup_utils.h" |
13 #include "chrome/browser/chromeos/login/wizard_controller.h" | 13 #include "chrome/browser/chromeos/login/wizard_controller.h" |
14 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" | 14 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" |
15 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" | 15 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" |
16 #include "chrome/browser/chromeos/settings/cros_settings.h" | 16 #include "chrome/browser/chromeos/settings/cros_settings.h" |
17 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" | 17 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" |
18 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
19 #include "chromeos/dbus/dbus_thread_manager.h" | 19 #include "chromeos/dbus/dbus_thread_manager.h" |
20 #include "chromeos/dbus/power_manager_client.h" | 20 #include "chromeos/dbus/power_manager_client.h" |
21 #include "chromeos/network/network_handler.h" | 21 #include "chromeos/network/network_handler.h" |
22 #include "chromeos/network/network_state.h" | 22 #include "chromeos/network/network_state.h" |
23 #include "chromeos/network/network_state_handler.h" | 23 #include "chromeos/network/network_state_handler.h" |
24 #include "chromeos/settings/cros_settings_names.h" | 24 #include "chromeos/settings/cros_settings_names.h" |
| 25 #include "content/public/browser/web_contents.h" |
25 #include "third_party/cros_system_api/dbus/service_constants.h" | 26 #include "third_party/cros_system_api/dbus/service_constants.h" |
26 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
27 | 28 |
28 using chromeos::CrosSettings; | 29 using chromeos::CrosSettings; |
29 using chromeos::DBusThreadManager; | 30 using chromeos::DBusThreadManager; |
30 using chromeos::OwnerSettingsServiceChromeOS; | 31 using chromeos::OwnerSettingsServiceChromeOS; |
31 using chromeos::OwnerSettingsServiceChromeOSFactory; | 32 using chromeos::OwnerSettingsServiceChromeOSFactory; |
32 using chromeos::UpdateEngineClient; | 33 using chromeos::UpdateEngineClient; |
33 using chromeos::WizardController; | 34 using chromeos::WizardController; |
34 | 35 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 help_utils_chromeos::GetConnectionTypeAsUTF16(network->type())); | 103 help_utils_chromeos::GetConnectionTypeAsUTF16(network->type())); |
103 callback.Run(VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED, 0, message); | 104 callback.Run(VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED, 0, message); |
104 return false; | 105 return false; |
105 } | 106 } |
106 | 107 |
107 return true; | 108 return true; |
108 } | 109 } |
109 | 110 |
110 } // namespace | 111 } // namespace |
111 | 112 |
112 VersionUpdater* VersionUpdater::Create(content::BrowserContext* context) { | 113 VersionUpdater* VersionUpdater::Create(content::WebContents* web_contents) { |
113 return new VersionUpdaterCros(context); | 114 return new VersionUpdaterCros(web_contents); |
114 } | 115 } |
115 | 116 |
116 void VersionUpdaterCros::GetUpdateStatus(const StatusCallback& callback) { | 117 void VersionUpdaterCros::GetUpdateStatus(const StatusCallback& callback) { |
117 callback_ = callback; | 118 callback_ = callback; |
118 | 119 |
119 if (!EnsureCanUpdate(callback)) | 120 if (!EnsureCanUpdate(callback)) |
120 return; | 121 return; |
121 | 122 |
122 UpdateEngineClient* update_engine_client = | 123 UpdateEngineClient* update_engine_client = |
123 DBusThreadManager::Get()->GetUpdateEngineClient(); | 124 DBusThreadManager::Get()->GetUpdateEngineClient(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 175 |
175 void VersionUpdaterCros::GetChannel(bool get_current_channel, | 176 void VersionUpdaterCros::GetChannel(bool get_current_channel, |
176 const ChannelCallback& cb) { | 177 const ChannelCallback& cb) { |
177 UpdateEngineClient* update_engine_client = | 178 UpdateEngineClient* update_engine_client = |
178 DBusThreadManager::Get()->GetUpdateEngineClient(); | 179 DBusThreadManager::Get()->GetUpdateEngineClient(); |
179 | 180 |
180 // Request the channel information. | 181 // Request the channel information. |
181 update_engine_client->GetChannel(get_current_channel, cb); | 182 update_engine_client->GetChannel(get_current_channel, cb); |
182 } | 183 } |
183 | 184 |
184 VersionUpdaterCros::VersionUpdaterCros(content::BrowserContext* context) | 185 VersionUpdaterCros::VersionUpdaterCros(content::WebContents* web_contents) |
185 : context_(context), | 186 : context_(web_contents ? web_contents->GetBrowserContext() : nullptr), |
186 last_operation_(UpdateEngineClient::UPDATE_STATUS_IDLE), | 187 last_operation_(UpdateEngineClient::UPDATE_STATUS_IDLE), |
187 check_for_update_when_idle_(false), | 188 check_for_update_when_idle_(false), |
188 weak_ptr_factory_(this) { | 189 weak_ptr_factory_(this) { |
189 } | 190 } |
190 | 191 |
191 VersionUpdaterCros::~VersionUpdaterCros() { | 192 VersionUpdaterCros::~VersionUpdaterCros() { |
192 UpdateEngineClient* update_engine_client = | 193 UpdateEngineClient* update_engine_client = |
193 DBusThreadManager::Get()->GetUpdateEngineClient(); | 194 DBusThreadManager::Get()->GetUpdateEngineClient(); |
194 update_engine_client->RemoveObserver(this); | 195 update_engine_client->RemoveObserver(this); |
195 } | 196 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 } | 252 } |
252 } | 253 } |
253 | 254 |
254 void VersionUpdaterCros::OnUpdateCheck( | 255 void VersionUpdaterCros::OnUpdateCheck( |
255 UpdateEngineClient::UpdateCheckResult result) { | 256 UpdateEngineClient::UpdateCheckResult result) { |
256 // If version updating is not implemented, this binary is the most up-to-date | 257 // If version updating is not implemented, this binary is the most up-to-date |
257 // possible with respect to automatic updating. | 258 // possible with respect to automatic updating. |
258 if (result == UpdateEngineClient::UPDATE_RESULT_NOTIMPLEMENTED) | 259 if (result == UpdateEngineClient::UPDATE_RESULT_NOTIMPLEMENTED) |
259 callback_.Run(UPDATED, 0, base::string16()); | 260 callback_.Run(UPDATED, 0, base::string16()); |
260 } | 261 } |
OLD | NEW |