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

Unified Diff: chrome/browser/google/google_update.cc

Issue 8394042: Pass through installer errors from Google Update to the About box. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/google/google_update.cc
===================================================================
--- chrome/browser/google/google_update.cc (revision 107092)
+++ chrome/browser/google/google_update.cc (working copy)
@@ -22,7 +22,9 @@
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/install_util.h"
#include "content/browser/browser_thread.h"
+#include "grit/generated_resources.h"
#include "google_update_idl_i.c"
+#include "ui/base/l10n/l10n_util.h"
#include "views/widget/widget.h"
namespace {
@@ -31,16 +33,16 @@
// Returns GOOGLE_UPDATE_NO_ERROR only if the instance running is a Google
// Chrome distribution installed in a standard location.
GoogleUpdateErrorCode CanUpdateCurrentChrome(
- const std::wstring& chrome_exe_path) {
+ const string16& chrome_exe_path) {
#if !defined(GOOGLE_CHROME_BUILD)
return CANNOT_UPGRADE_CHROME_IN_THIS_DIRECTORY;
#else
// TODO(tommi): Check if using the default distribution is always the right
// thing to do.
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
- std::wstring user_exe_path =
+ string16 user_exe_path =
installer::GetChromeInstallPath(false, dist).value();
- std::wstring machine_exe_path =
+ string16 machine_exe_path =
installer::GetChromeInstallPath(true, dist).value();
std::transform(user_exe_path.begin(), user_exe_path.end(),
user_exe_path.begin(), tolower);
@@ -55,7 +57,7 @@
return CANNOT_UPGRADE_CHROME_IN_THIS_DIRECTORY;
}
- std::wstring app_guid = installer::GetAppGuidForUpdates(
+ string16 app_guid = installer::GetAppGuidForUpdates(
!InstallUtil::IsPerUserInstall(chrome_exe_path.c_str()));
DCHECK(!app_guid.empty());
@@ -84,7 +86,7 @@
StringFromGUID2(class_id, class_id_as_string,
arraysize(class_id_as_string));
- std::wstring elevation_moniker_name =
+ string16 elevation_moniker_name =
base::StringPrintf(L"Elevation:Administrator!new:%ls",
class_id_as_string);
@@ -166,6 +168,8 @@
result_ = UPGRADE_ALREADY_UP_TO_DATE;
break;
}
+ case COMPLETION_CODE_ERROR:
+ error_message_ = text;
default: {
NOTREACHED();
result_ = UPGRADE_ERROR;
@@ -196,18 +200,28 @@
// Returns which version Google Update found on the server (if a more
// recent version was found). Otherwise, this will be blank.
- STDMETHOD(GetVersionInfo)(std::wstring* version_string) {
+ STDMETHOD(GetVersionInfo)(string16* version_string) {
*version_string = new_version_;
return S_OK;
}
+ // Returns which version Google Update found on the server (if a more
+ // recent version was found). Otherwise, this will be blank.
+ STDMETHOD(GetErrorMessage)(string16* error_message) {
+ *error_message = error_message_;
+ return S_OK;
+ }
+
private:
// The status/result of the Google Update operation.
GoogleUpdateUpgradeResult result_;
// The version string Google Update found.
- std::wstring new_version_;
+ string16 new_version_;
+ // An error message, if any.
+ string16 error_message_;
+
// Allows us control the upgrade process to a small degree. After OnComplete
// has been called, this object can not be used.
base::win::ScopedComPtr<IProgressWndEvents> event_sink_;
@@ -246,7 +260,7 @@
if (!PathService::Get(base::DIR_EXE, &chrome_exe_path))
NOTREACHED();
- std::wstring chrome_exe = chrome_exe_path.value();
+ string16 chrome_exe = chrome_exe_path.value();
std::transform(chrome_exe.begin(), chrome_exe.end(),
chrome_exe.begin(), tolower);
@@ -256,7 +270,7 @@
main_loop->PostTask(
FROM_HERE,
base::Bind(&GoogleUpdate::ReportResults, this,
- UPGRADE_ERROR, error_code));
+ UPGRADE_ERROR, error_code, string16()));
return;
}
@@ -264,7 +278,12 @@
HRESULT hr =
CComObject<GoogleUpdateJobObserver>::CreateInstance(&job_observer);
if (hr != S_OK) {
- ReportFailure(hr, GOOGLE_UPDATE_JOB_SERVER_CREATION_FAILED, main_loop);
+ // Most of the error messages come straight from Google Update. This one is
+ // deemed worthy enough to also warrant its own error.
+ ReportFailure(
+ hr, GOOGLE_UPDATE_JOB_SERVER_CREATION_FAILED,
+ l10n_util::GetStringUTF16(IDS_ABOUT_BOX_ERROR_COCREATE_FAILED),
+ main_loop);
return;
}
@@ -296,11 +315,12 @@
}
if (hr != S_OK) {
- ReportFailure(hr, GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND, main_loop);
+ ReportFailure(hr, GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND,
+ string16(), main_loop);
return;
}
- std::wstring app_guid = installer::GetAppGuidForUpdates(system_level);
+ string16 app_guid = installer::GetAppGuidForUpdates(system_level);
DCHECK(!app_guid.empty());
if (!install_if_newer)
@@ -309,7 +329,8 @@
hr = on_demand->Update(app_guid.c_str(), job_observer);
if (hr != S_OK) {
- ReportFailure(hr, GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR, main_loop);
+ ReportFailure(hr, GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR,
+ string16(), main_loop);
return;
}
@@ -322,45 +343,55 @@
GoogleUpdateUpgradeResult results;
hr = job_observer->GetResult(&results);
if (hr != S_OK) {
- ReportFailure(hr, GOOGLE_UPDATE_GET_RESULT_CALL_FAILED, main_loop);
+ ReportFailure(hr, GOOGLE_UPDATE_GET_RESULT_CALL_FAILED,
+ string16(), main_loop);
return;
}
if (results == UPGRADE_ERROR) {
- ReportFailure(hr, GOOGLE_UPDATE_ERROR_UPDATING, main_loop);
+ string16 error_message;
+ job_observer->GetErrorMessage(&error_message);
+ ReportFailure(hr, GOOGLE_UPDATE_ERROR_UPDATING, error_message, main_loop);
return;
}
hr = job_observer->GetVersionInfo(&version_available_);
if (hr != S_OK) {
- ReportFailure(hr, GOOGLE_UPDATE_GET_VERSION_INFO_FAILED, main_loop);
+ ReportFailure(hr, GOOGLE_UPDATE_GET_VERSION_INFO_FAILED,
+ string16(), main_loop);
return;
}
main_loop->PostTask(
FROM_HERE,
base::Bind(&GoogleUpdate::ReportResults, this,
- results, GOOGLE_UPDATE_NO_ERROR));
+ results, GOOGLE_UPDATE_NO_ERROR, string16()));
job_holder = NULL;
on_demand = NULL;
}
void GoogleUpdate::ReportResults(GoogleUpdateUpgradeResult results,
- GoogleUpdateErrorCode error_code) {
+ GoogleUpdateErrorCode error_code,
+ const string16& error_message) {
// If we get an error, then error code must not be blank, and vice versa.
DCHECK(results == UPGRADE_ERROR ? error_code != GOOGLE_UPDATE_NO_ERROR :
error_code == GOOGLE_UPDATE_NO_ERROR);
- if (listener_)
- listener_->OnReportResults(results, error_code, version_available_);
+ if (listener_) {
+ listener_->OnReportResults(
+ results, error_code, error_message, version_available_);
+ }
}
-bool GoogleUpdate::ReportFailure(HRESULT hr, GoogleUpdateErrorCode error_code,
+bool GoogleUpdate::ReportFailure(HRESULT hr,
+ GoogleUpdateErrorCode error_code,
+ const string16& error_message,
MessageLoop* main_loop) {
NOTREACHED() << "Communication with Google Update failed: " << hr
- << " error: " << error_code;
+ << " error: " << error_code
+ << ", message: " << error_message.c_str();
main_loop->PostTask(
FROM_HERE,
base::Bind(&GoogleUpdate::ReportResults, this,
- UPGRADE_ERROR, error_code));
+ UPGRADE_ERROR, error_code, error_message));
return false;
}

Powered by Google App Engine
This is Rietveld 408576698