summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-24 21:34:10 +0000
committersail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-24 21:34:10 +0000
commitcf977b76c00a02922a6b888d363688e89dded110 (patch)
tree8307d82eb88a72004496ef79b2c807160f6d8179
parentc8a118e51bbdfb7a7a6e8e87e1926779edd0c4de (diff)
downloadchromium_src-cf977b76c00a02922a6b888d363688e89dded110.zip
chromium_src-cf977b76c00a02922a6b888d363688e89dded110.tar.gz
chromium_src-cf977b76c00a02922a6b888d363688e89dded110.tar.bz2
Fix crash when showing error in wrench menu
This is speculative fix for a crash in WrenchMenuModel::AddGlobalErrorMenuItems(). My guess is that we're modifying a list while iterating over it. Fix is to move the modifying call out of the loop. BUG=278543 TEST=Can't repro the crash. Just built and ran Chrome. NOTRY=true Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=224987 Review URL: https://chromiumcodereview.appspot.com/23435011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225064 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/profile_sync_service.cc4
-rw-r--r--chrome/browser/ui/global_error/global_error_service.cc3
-rw-r--r--chrome/browser/ui/toolbar/wrench_menu_model.cc16
3 files changed, 16 insertions, 7 deletions
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index a771866..d108ebf 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -572,14 +572,14 @@ void ProfileSyncService::StartUp(StartUpDeferredOption deferred_option) {
}
#endif
- if (!sync_global_error_) {
#if !defined(OS_ANDROID)
+ if (!sync_global_error_) {
sync_global_error_.reset(new SyncGlobalError(this, signin()));
-#endif
GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError(
sync_global_error_.get());
AddObserver(sync_global_error_.get());
}
+#endif
} else {
// We don't care to prevent multiple calls to StartUp in deferred mode
// because it's fast and has no side effects.
diff --git a/chrome/browser/ui/global_error/global_error_service.cc b/chrome/browser/ui/global_error/global_error_service.cc
index 2acf270..041efd3 100644
--- a/chrome/browser/ui/global_error/global_error_service.cc
+++ b/chrome/browser/ui/global_error/global_error_service.cc
@@ -21,6 +21,9 @@ GlobalErrorService::~GlobalErrorService() {
}
void GlobalErrorService::AddGlobalError(GlobalError* error) {
+ // Verify that we're not adding NULL errors. TODO(sail) Make this a DCHECK
+ // once crbug.com/278543 is fixed.
+ CHECK(error);
errors_.push_back(error);
NotifyErrorsChanged(error);
}
diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.cc b/chrome/browser/ui/toolbar/wrench_menu_model.cc
index fbd3904..e6fadea 100644
--- a/chrome/browser/ui/toolbar/wrench_menu_model.cc
+++ b/chrome/browser/ui/toolbar/wrench_menu_model.cc
@@ -675,18 +675,24 @@ void WrenchMenuModel::AddGlobalErrorMenuItems() {
// it won't show in the existing wrench menu. To fix this we need to some
// how update the menu if new errors are added.
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
+ // GetSignedInServiceErrors() can modify the global error list, so call it
+ // before iterating through that list below.
+ std::vector<GlobalError*> signin_errors =
+ signin_ui_util::GetSignedInServiceErrors(
+ browser_->profile()->GetOriginalProfile());
const GlobalErrorService::GlobalErrorList& errors =
GlobalErrorServiceFactory::GetForProfile(browser_->profile())->errors();
for (GlobalErrorService::GlobalErrorList::const_iterator
it = errors.begin(); it != errors.end(); ++it) {
GlobalError* error = *it;
+ // Verify that we're not getting NULL errors. TODO(sail) Make this a DCHECK
+ // once crbug.com/278543 is fixed.
+ CHECK(error);
if (error->HasMenuItem()) {
- // Don't add a signin error if it's already being displayed elsewhere.
#if !defined(OS_CHROMEOS)
- std::vector<GlobalError*> errors =
- signin_ui_util::GetSignedInServiceErrors(
- browser_->profile()->GetOriginalProfile());
- if (std::find(errors.begin(), errors.end(), error) != errors.end()) {
+ // Don't add a signin error if it's already being displayed elsewhere.
+ if (std::find(signin_errors.begin(), signin_errors.end(), error) !=
+ signin_errors.end()) {
MenuModel* model = this;
int index = 0;
if (MenuModel::GetModelAndIndexForCommandId(