Skip to content

Commit

Permalink
Only show one signed in service error
Browse files Browse the repository at this point in the history
Currently if there's both a sync error and a signin error then both
will be displayed in the wrench menu.

With this change only the one with the highest priority will be
displayed.

BUG=244423

Review URL: https://chromiumcodereview.appspot.com/18159004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209536 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sail@chromium.org committed Jul 1, 2013
1 parent c03e3fb commit af3e1ea
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
16 changes: 13 additions & 3 deletions chrome/browser/signin/signin_ui_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,22 @@ const int kUsernameMaxWidth = 200;
namespace signin_ui_util {

GlobalError* GetSignedInServiceError(Profile* profile) {
std::vector<GlobalError*> errors = GetSignedInServiceErrors(profile);
if (errors.empty())
return NULL;
return errors[0];
}

std::vector<GlobalError*> GetSignedInServiceErrors(Profile* profile) {
std::vector<GlobalError*> errors;

// Auth errors have the highest priority - after that, individual service
// errors.
SigninManagerBase* signin_manager =
SigninManagerFactory::GetForProfile(profile);
SigninGlobalError* signin_error = signin_manager->signin_global_error();
if (signin_error && signin_error->HasMenuItem())
return signin_error;
errors.push_back(signin_error);

// No auth error - now try other services. Currently the list is just hard-
// coded but in the future if we add more we can create some kind of
Expand All @@ -44,9 +53,10 @@ GlobalError* GetSignedInServiceError(Profile* profile) {
ProfileSyncServiceFactory::GetForProfile(profile);
SyncGlobalError* error = service->sync_global_error();
if (error && error->HasMenuItem())
return error;
errors.push_back(error);
}
return NULL;

return errors;
}

string16 GetSigninMenuLabel(Profile* profile) {
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/signin/signin_ui_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_SIGNIN_SIGNIN_UI_UTIL_H_
#define CHROME_BROWSER_SIGNIN_SIGNIN_UI_UTIL_H_

#include <vector>

#include "base/strings/string16.h"

class GlobalError;
Expand All @@ -19,6 +21,9 @@ namespace signin_ui_util {
// object associated with that service, or NULL if no errors are reported.
GlobalError* GetSignedInServiceError(Profile* profile);

// Returns all errors reported by signed in services.
std::vector<GlobalError*> GetSignedInServiceErrors(Profile* profile);

// Return the label that should be displayed in the signin menu (i.e.
// "Sign in to Chromium", "Signin Error...", etc).
string16 GetSigninMenuLabel(Profile* profile);
Expand Down
6 changes: 4 additions & 2 deletions chrome/browser/ui/toolbar/wrench_menu_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,10 @@ void WrenchMenuModel::AddGlobalErrorMenuItems() {
if (error->HasMenuItem()) {
// Don't add a signin error if it's already being displayed elsewhere.
#if !defined(OS_CHROMEOS)
if (error == signin_ui_util::GetSignedInServiceError(
browser_->profile()->GetOriginalProfile())) {
std::vector<GlobalError*> errors =
signin_ui_util::GetSignedInServiceErrors(
browser_->profile()->GetOriginalProfile());
if (std::find(errors.begin(), errors.end(), error) != errors.end()) {
MenuModel* model = this;
int index = 0;
if (MenuModel::GetModelAndIndexForCommandId(
Expand Down

0 comments on commit af3e1ea

Please sign in to comment.