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 "base/memory/weak_ptr.h" | 5 #include "base/memory/weak_ptr.h" |
6 #include "base/strings/string16.h" | 6 #include "base/strings/string16.h" |
7 #include "base/task_runner_util.h" | 7 #include "base/task_runner_util.h" |
8 #include "base/win/win_util.h" | 8 #include "base/win/win_util.h" |
9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 // VersionUpdater: | 35 // VersionUpdater: |
36 void CheckForUpdate(const StatusCallback& callback) override; | 36 void CheckForUpdate(const StatusCallback& callback) override; |
37 void RelaunchBrowser() const override; | 37 void RelaunchBrowser() const override; |
38 | 38 |
39 // UpdateCheckDelegate: | 39 // UpdateCheckDelegate: |
40 void OnUpdateCheckComplete(const base::string16& new_version) override; | 40 void OnUpdateCheckComplete(const base::string16& new_version) override; |
41 void OnUpgradeProgress(int progress, | 41 void OnUpgradeProgress(int progress, |
42 const base::string16& new_version) override; | 42 const base::string16& new_version) override; |
43 void OnUpgradeComplete(const base::string16& new_version) override; | 43 void OnUpgradeComplete(const base::string16& new_version) override; |
44 void OnError(GoogleUpdateErrorCode error_code, | 44 void OnError(GoogleUpdateErrorCode error_code, |
45 const base::string16& error_message, | 45 const base::string16& html_error_message, |
46 const base::string16& new_version) override; | 46 const base::string16& new_version) override; |
47 | 47 |
48 private: | 48 private: |
49 void BeginUpdateCheckOnFileThread(bool install_update_if_possible); | 49 void BeginUpdateCheckOnFileThread(bool install_update_if_possible); |
50 | 50 |
51 // A task run on the UI thread with the result of checking for a pending | 51 // A task run on the UI thread with the result of checking for a pending |
52 // restart. | 52 // restart. |
53 void OnPendingRestartCheck(bool is_update_pending_restart); | 53 void OnPendingRestartCheck(bool is_update_pending_restart); |
54 | 54 |
55 // The widget owning the UI for the update check. | 55 // The widget owning the UI for the update check. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 125 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
126 callback_.Run(UPDATING, progress, base::string16()); | 126 callback_.Run(UPDATING, progress, base::string16()); |
127 } | 127 } |
128 | 128 |
129 void VersionUpdaterWin::OnUpgradeComplete(const base::string16& new_version) { | 129 void VersionUpdaterWin::OnUpgradeComplete(const base::string16& new_version) { |
130 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 130 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
131 callback_.Run(NEARLY_UPDATED, 0, base::string16()); | 131 callback_.Run(NEARLY_UPDATED, 0, base::string16()); |
132 } | 132 } |
133 | 133 |
134 void VersionUpdaterWin::OnError(GoogleUpdateErrorCode error_code, | 134 void VersionUpdaterWin::OnError(GoogleUpdateErrorCode error_code, |
135 const base::string16& error_message, | 135 const base::string16& html_error_message, |
136 const base::string16& new_version) { | 136 const base::string16& new_version) { |
137 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 137 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
138 base::string16 message; | 138 base::string16 message; |
139 | 139 |
140 // Current versions of Google Update provide a nice message for the policy | 140 // html_error_message already mentions error_code so don't combine messages. |
141 // case. Use this generic error for the policy case only if no message from | 141 if (html_error_message.empty()) { |
142 // Google Update is present. | |
143 if (error_code != GOOGLE_UPDATE_DISABLED_BY_POLICY || error_message.empty()) | |
144 message = l10n_util::GetStringFUTF16Int(IDS_UPGRADE_ERROR, error_code); | 142 message = l10n_util::GetStringFUTF16Int(IDS_UPGRADE_ERROR, error_code); |
145 | 143 } else { |
146 if (!error_message.empty()) { | 144 message = l10n_util::GetStringFUTF16( |
147 message += l10n_util::GetStringFUTF16( | 145 IDS_ABOUT_BOX_ERROR_DURING_UPDATE_CHECK, html_error_message); |
148 IDS_ABOUT_BOX_ERROR_DURING_UPDATE_CHECK, error_message); | |
149 } | 146 } |
150 callback_.Run(FAILED, 0, message); | 147 callback_.Run(FAILED, 0, message); |
151 } | 148 } |
152 | 149 |
153 void VersionUpdaterWin::BeginUpdateCheckOnFileThread( | 150 void VersionUpdaterWin::BeginUpdateCheckOnFileThread( |
154 bool install_update_if_possible) { | 151 bool install_update_if_possible) { |
155 BeginUpdateCheck(content::BrowserThread::GetMessageLoopProxyForThread( | 152 BeginUpdateCheck(content::BrowserThread::GetMessageLoopProxyForThread( |
156 content::BrowserThread::FILE), | 153 content::BrowserThread::FILE), |
157 g_browser_process->GetApplicationLocale(), | 154 g_browser_process->GetApplicationLocale(), |
158 install_update_if_possible, owner_widget_, | 155 install_update_if_possible, owner_widget_, |
(...skipping 13 matching lines...) Expand all Loading... |
172 // this this window will no longer have focus by the time UAC is needed. In | 169 // this this window will no longer have focus by the time UAC is needed. In |
173 // that case, the UAC prompt will appear in the taskbar and will require a | 170 // that case, the UAC prompt will appear in the taskbar and will require a |
174 // user click. This is the least surprising thing we can do for the user, and | 171 // user click. This is the least surprising thing we can do for the user, and |
175 // is the intended behavior for Windows applications. It's also possible that | 172 // is the intended behavior for Windows applications. It's also possible that |
176 // the browser window hosting the update check will have been closed by the | 173 // the browser window hosting the update check will have been closed by the |
177 // time the UAC prompt is needed. This will behave similarly. | 174 // time the UAC prompt is needed. This will behave similarly. |
178 return new VersionUpdaterWin(web_contents->GetTopLevelNativeWindow() | 175 return new VersionUpdaterWin(web_contents->GetTopLevelNativeWindow() |
179 ->GetHost() | 176 ->GetHost() |
180 ->GetAcceleratedWidget()); | 177 ->GetAcceleratedWidget()); |
181 } | 178 } |
OLD | NEW |