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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "chrome/browser/chromeos/cros_settings.h" | 9 #include "chrome/browser/chromeos/cros_settings.h" |
10 #include "chrome/browser/chromeos/cros_settings_names.h" | 10 #include "chrome/browser/chromeos/cros_settings_names.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 callback_ = callback; | 27 callback_ = callback; |
28 | 28 |
29 UpdateEngineClient* update_engine_client = | 29 UpdateEngineClient* update_engine_client = |
30 DBusThreadManager::Get()->GetUpdateEngineClient(); | 30 DBusThreadManager::Get()->GetUpdateEngineClient(); |
31 update_engine_client->AddObserver(this); | 31 update_engine_client->AddObserver(this); |
32 | 32 |
33 // Make sure that libcros is loaded and OOBE is complete. | 33 // Make sure that libcros is loaded and OOBE is complete. |
34 if (!WizardController::default_controller() || | 34 if (!WizardController::default_controller() || |
35 WizardController::IsDeviceRegistered()) { | 35 WizardController::IsDeviceRegistered()) { |
36 update_engine_client->RequestUpdateCheck( | 36 update_engine_client->RequestUpdateCheck( |
37 base::Bind(&VersionUpdaterCros::OnUpdateCheck, base::Unretained(this))); | 37 base::Bind(&VersionUpdaterCros::OnUpdateCheck, |
| 38 weak_ptr_factory_.GetWeakPtr())); |
38 } | 39 } |
39 } | 40 } |
40 | 41 |
41 void VersionUpdaterCros::RelaunchBrowser() const { | 42 void VersionUpdaterCros::RelaunchBrowser() const { |
42 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | 43 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
43 } | 44 } |
44 | 45 |
45 void VersionUpdaterCros::SetReleaseChannel(const std::string& channel) { | 46 void VersionUpdaterCros::SetReleaseChannel(const std::string& channel) { |
46 DBusThreadManager::Get()->GetUpdateEngineClient()->SetReleaseTrack(channel); | 47 DBusThreadManager::Get()->GetUpdateEngineClient()->SetReleaseTrack(channel); |
47 // For local owner set the field in the policy blob too. | 48 // For local owner set the field in the policy blob too. |
48 if (UserManager::Get()->IsCurrentUserOwner()) | 49 if (UserManager::Get()->IsCurrentUserOwner()) |
49 CrosSettings::Get()->SetString(chromeos::kReleaseChannel, channel); | 50 CrosSettings::Get()->SetString(chromeos::kReleaseChannel, channel); |
50 } | 51 } |
51 | 52 |
52 void VersionUpdaterCros::GetReleaseChannel(const ChannelCallback& cb) { | 53 void VersionUpdaterCros::GetReleaseChannel(const ChannelCallback& cb) { |
53 channel_callback_ = cb; | 54 channel_callback_ = cb; |
54 | 55 |
55 // TODO(jhawkins): Store on this object. | 56 // TODO(jhawkins): Store on this object. |
56 UpdateEngineClient* update_engine_client = | 57 UpdateEngineClient* update_engine_client = |
57 DBusThreadManager::Get()->GetUpdateEngineClient(); | 58 DBusThreadManager::Get()->GetUpdateEngineClient(); |
58 | 59 |
59 // Request the channel information. Use the observer to track the help page | 60 // Request the channel information. Use the observer to track the help page |
60 // handler and ensure it does not get deleted before the callback. | 61 // handler and ensure it does not get deleted before the callback. |
61 update_engine_client->GetReleaseTrack( | 62 update_engine_client->GetReleaseTrack( |
62 base::Bind(&VersionUpdaterCros::UpdateSelectedChannel, | 63 base::Bind(&VersionUpdaterCros::UpdateSelectedChannel, |
63 base::Unretained(this))); | 64 weak_ptr_factory_.GetWeakPtr())); |
64 } | 65 } |
65 | 66 |
66 VersionUpdaterCros::VersionUpdaterCros() {} | 67 VersionUpdaterCros::VersionUpdaterCros() : weak_ptr_factory_(this) {} |
67 | 68 |
68 VersionUpdaterCros::~VersionUpdaterCros() { | 69 VersionUpdaterCros::~VersionUpdaterCros() { |
69 UpdateEngineClient* update_engine_client = | 70 UpdateEngineClient* update_engine_client = |
70 DBusThreadManager::Get()->GetUpdateEngineClient(); | 71 DBusThreadManager::Get()->GetUpdateEngineClient(); |
71 update_engine_client->RemoveObserver(this); | 72 update_engine_client->RemoveObserver(this); |
72 } | 73 } |
73 | 74 |
74 void VersionUpdaterCros::UpdateStatusChanged( | 75 void VersionUpdaterCros::UpdateStatusChanged( |
75 const UpdateEngineClient::Status& status) { | 76 const UpdateEngineClient::Status& status) { |
76 Status my_status = UPDATED; | 77 Status my_status = UPDATED; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 UpdateEngineClient::UpdateCheckResult result) { | 109 UpdateEngineClient::UpdateCheckResult result) { |
109 // If version updating is not implemented, this binary is the most up-to-date | 110 // If version updating is not implemented, this binary is the most up-to-date |
110 // possible with respect to automatic updating. | 111 // possible with respect to automatic updating. |
111 if (result == UpdateEngineClient::UPDATE_RESULT_NOTIMPLEMENTED) | 112 if (result == UpdateEngineClient::UPDATE_RESULT_NOTIMPLEMENTED) |
112 callback_.Run(UPDATED, 0, string16()); | 113 callback_.Run(UPDATED, 0, string16()); |
113 } | 114 } |
114 | 115 |
115 void VersionUpdaterCros::UpdateSelectedChannel(const std::string& channel) { | 116 void VersionUpdaterCros::UpdateSelectedChannel(const std::string& channel) { |
116 channel_callback_.Run(channel); | 117 channel_callback_.Run(channel); |
117 } | 118 } |
OLD | NEW |