summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-11 03:58:38 +0000
committeratwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-11 03:58:38 +0000
commitbd985a221a00d320a4fb585c3a5a920724d79621 (patch)
tree90ca453866af87f2182b71504a709b25a3fc92de
parentf1ef8ef056879512772a3ee4015cc36dd5ad5dc7 (diff)
downloadchromium_src-bd985a221a00d320a4fb585c3a5a920724d79621.zip
chromium_src-bd985a221a00d320a4fb585c3a5a920724d79621.tar.gz
chromium_src-bd985a221a00d320a4fb585c3a5a920724d79621.tar.bz2
Removed ProfileSyncService::UIShouldDepictAuthInProgress
Changed so all code queries the auth-in-progress status directly from SigninManager. BUG=95269 TEST=existing unit tests suffice Review URL: http://codereview.chromium.org/9959038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131709 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/signin/signin_manager.h5
-rw-r--r--chrome/browser/sync/profile_sync_service.cc6
-rw-r--r--chrome/browser/sync/profile_sync_service.h8
-rw-r--r--chrome/browser/sync/profile_sync_service_mock.h1
-rw-r--r--chrome/browser/sync/sync_global_error.cc10
-rw-r--r--chrome/browser/sync/sync_global_error.h4
-rw-r--r--chrome/browser/sync/sync_global_error_unittest.cc7
-rw-r--r--chrome/browser/sync/sync_ui_util.cc29
-rw-r--r--chrome/browser/sync/sync_ui_util.h8
-rw-r--r--chrome/browser/sync/sync_ui_util_mac.mm5
-rw-r--r--chrome/browser/sync/sync_ui_util_unittest.cc47
-rw-r--r--chrome/browser/ui/toolbar/wrench_menu_model.cc8
-rw-r--r--chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc4
-rw-r--r--chrome/browser/ui/webui/options2/browser_options_handler2.cc7
14 files changed, 93 insertions, 56 deletions
diff --git a/chrome/browser/signin/signin_manager.h b/chrome/browser/signin/signin_manager.h
index 3fc50c8..0ef4f1a 100644
--- a/chrome/browser/signin/signin_manager.h
+++ b/chrome/browser/signin/signin_manager.h
@@ -98,8 +98,9 @@ class SigninManager : public GaiaAuthConsumer,
// associated with the user, and canceling all auth in progress.
virtual void SignOut();
- // Returns true if there's a signin in progress.
- bool AuthInProgress() const;
+ // Returns true if there's a signin in progress. Virtual so it can be
+ // overridden by mocks.
+ virtual bool AuthInProgress() const;
// Handles errors if a required user info key is not returned from the
// GetUserInfo call.
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 5c01d32..ca25aab 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -413,7 +413,7 @@ void ProfileSyncService::StartUp() {
InitializeBackend(!HasSyncSetupCompleted());
if (!sync_global_error_.get()) {
- sync_global_error_.reset(new SyncGlobalError(this));
+ sync_global_error_.reset(new SyncGlobalError(this, signin()));
GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError(
sync_global_error_.get());
AddObserver(sync_global_error_.get());
@@ -1002,10 +1002,6 @@ bool ProfileSyncService::unrecoverable_error_detected() const {
return unrecoverable_error_detected_;
}
-bool ProfileSyncService::UIShouldDepictAuthInProgress() const {
- return signin()->AuthInProgress();
-}
-
bool ProfileSyncService::IsPassphraseRequired() const {
return passphrase_required_reason_ !=
sync_api::REASON_PASSPHRASE_NOT_REQUIRED;
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index 62dca68..3b37103 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -296,14 +296,6 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
return unrecoverable_error_location_;
}
- // Reports whether the user is currently authenticating or not. This is used
- // by the sync_ui_util helper routines to allow the UI to properly display
- // an "authenticating..." status message instead of an auth error when we are
- // in the process of trying to update credentials.
- // TODO(atwilson): This state now resides in SigninManager - this method
- // will be removed once we've cleaned up the callers. http://crbug.com/95269.
- virtual bool UIShouldDepictAuthInProgress() const;
-
// Returns true if OnPassphraseRequired has been called for any reason.
virtual bool IsPassphraseRequired() const;
diff --git a/chrome/browser/sync/profile_sync_service_mock.h b/chrome/browser/sync/profile_sync_service_mock.h
index e42efeb..bcad588 100644
--- a/chrome/browser/sync/profile_sync_service_mock.h
+++ b/chrome/browser/sync/profile_sync_service_mock.h
@@ -76,7 +76,6 @@ class ProfileSyncServiceMock : public ProfileSyncService {
MOCK_CONST_METHOD0(GetLastSessionSnapshot,
const browser_sync::sessions::SyncSessionSnapshot*());
- MOCK_CONST_METHOD0(UIShouldDepictAuthInProgress, bool());
MOCK_METHOD0(QueryDetailedSyncStatus,
browser_sync::SyncBackendHost::Status());
MOCK_CONST_METHOD0(GetAuthError, const GoogleServiceAuthError&());
diff --git a/chrome/browser/sync/sync_global_error.cc b/chrome/browser/sync/sync_global_error.cc
index 57d3353..8dab40d 100644
--- a/chrome/browser/sync/sync_global_error.cc
+++ b/chrome/browser/sync/sync_global_error.cc
@@ -18,8 +18,12 @@
typedef GoogleServiceAuthError AuthError;
-SyncGlobalError::SyncGlobalError(ProfileSyncService* service)
- : service_(service) {
+SyncGlobalError::SyncGlobalError(ProfileSyncService* service,
+ SigninManager* signin)
+ : service_(service),
+ signin_(signin) {
+ DCHECK(service_);
+ DCHECK(signin_);
OnStateChanged();
}
@@ -96,7 +100,7 @@ void SyncGlobalError::OnStateChanged() {
string16 bubble_message;
string16 bubble_accept_label;
sync_ui_util::GetStatusLabelsForSyncGlobalError(
- service_, &menu_label, &bubble_message, &bubble_accept_label);
+ service_, *signin_, &menu_label, &bubble_message, &bubble_accept_label);
// All the labels should be empty or all of them non-empty.
DCHECK((menu_label.empty() && bubble_message.empty() &&
diff --git a/chrome/browser/sync/sync_global_error.h b/chrome/browser/sync/sync_global_error.h
index c58dc99..f04df48 100644
--- a/chrome/browser/sync/sync_global_error.h
+++ b/chrome/browser/sync/sync_global_error.h
@@ -12,13 +12,14 @@
#include "chrome/browser/ui/global_error.h"
class ProfileSyncService;
+class SigninManager;
// Shows sync errors on the wrench menu using a bubble view and a
// menu item.
class SyncGlobalError : public GlobalError,
public ProfileSyncServiceObserver {
public:
- explicit SyncGlobalError(ProfileSyncService* service);
+ SyncGlobalError(ProfileSyncService* service, SigninManager* signin);
virtual ~SyncGlobalError();
virtual bool HasBadge() OVERRIDE;
@@ -49,6 +50,7 @@ class SyncGlobalError : public GlobalError,
string16 bubble_message_;
string16 menu_label_;
ProfileSyncService* service_;
+ SigninManager* signin_;
DISALLOW_COPY_AND_ASSIGN(SyncGlobalError);
};
diff --git a/chrome/browser/sync/sync_global_error_unittest.cc b/chrome/browser/sync/sync_global_error_unittest.cc
index 0f7943e..cfe75e1 100644
--- a/chrome/browser/sync/sync_global_error_unittest.cc
+++ b/chrome/browser/sync/sync_global_error_unittest.cc
@@ -8,6 +8,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/signin/signin_manager.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_mock.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/browser_with_test_window_test.h"
@@ -112,7 +113,8 @@ TEST_F(SyncGlobalErrorTest, PassphraseGlobalError) {
scoped_ptr<Profile> profile(
ProfileSyncServiceMock::MakeSignedInTestingProfile());
NiceMock<ProfileSyncServiceMock> service(profile.get());
- SyncGlobalError error(&service);
+ SigninManager* signin = SigninManagerFactory::GetForProfile(profile.get());
+ SyncGlobalError error(&service, signin);
EXPECT_CALL(service, IsPassphraseRequired())
.WillRepeatedly(Return(true));
@@ -129,7 +131,8 @@ TEST_F(SyncGlobalErrorTest, AuthStateGlobalError) {
scoped_ptr<Profile> profile(
ProfileSyncServiceMock::MakeSignedInTestingProfile());
NiceMock<ProfileSyncServiceMock> service(profile.get());
- SyncGlobalError error(&service);
+ SigninManager* signin = SigninManagerFactory::GetForProfile(profile.get());
+ SyncGlobalError error(&service, signin);
browser_sync::SyncBackendHost::Status status;
EXPECT_CALL(service, QueryDetailedSyncStatus())
diff --git a/chrome/browser/sync/sync_ui_util.cc b/chrome/browser/sync/sync_ui_util.cc
index 3024a4c..fa47391 100644
--- a/chrome/browser/sync/sync_ui_util.cc
+++ b/chrome/browser/sync/sync_ui_util.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
@@ -220,6 +221,7 @@ void GetStatusForActionableError(
// status_label and link_label must either be both NULL or both non-NULL.
MessageType GetStatusInfo(ProfileSyncService* service,
+ const SigninManager& signin,
StatusLabelStyle style,
string16* status_label,
string16* link_label) {
@@ -248,7 +250,7 @@ MessageType GetStatusInfo(ProfileSyncService* service,
}
// For auth errors first check if an auth is in progress.
- if (service->UIShouldDepictAuthInProgress()) {
+ if (signin.AuthInProgress()) {
if (status_label) {
status_label->assign(
l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL));
@@ -306,7 +308,7 @@ MessageType GetStatusInfo(ProfileSyncService* service,
status_label->assign(
l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS));
}
- if (service->UIShouldDepictAuthInProgress()) {
+ if (signin.AuthInProgress()) {
if (status_label) {
status_label->assign(
l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL));
@@ -339,6 +341,7 @@ MessageType GetStatusInfo(ProfileSyncService* service,
// Returns the status info for use on the new tab page, where we want slightly
// different information than in the settings panel.
MessageType GetStatusInfoForNewTabPage(ProfileSyncService* service,
+ const SigninManager& signin,
string16* status_label,
string16* link_label) {
DCHECK(status_label);
@@ -370,30 +373,34 @@ MessageType GetStatusInfoForNewTabPage(ProfileSyncService* service,
}
// Fallback to default.
- return GetStatusInfo(service, WITH_HTML, status_label, link_label);
+ return GetStatusInfo(service, signin, WITH_HTML, status_label, link_label);
}
} // namespace
MessageType GetStatusLabels(ProfileSyncService* service,
+ const SigninManager& signin,
StatusLabelStyle style,
string16* status_label,
string16* link_label) {
DCHECK(status_label);
DCHECK(link_label);
- return sync_ui_util::GetStatusInfo(service, style, status_label, link_label);
+ return sync_ui_util::GetStatusInfo(
+ service, signin, style, status_label, link_label);
}
MessageType GetStatusLabelsForNewTabPage(ProfileSyncService* service,
+ const SigninManager& signin,
string16* status_label,
string16* link_label) {
DCHECK(status_label);
DCHECK(link_label);
return sync_ui_util::GetStatusInfoForNewTabPage(
- service, status_label, link_label);
+ service, signin, status_label, link_label);
}
void GetStatusLabelsForSyncGlobalError(ProfileSyncService* service,
+ const SigninManager& signin,
string16* menu_label,
string16* bubble_message,
string16* bubble_accept_label) {
@@ -420,7 +427,7 @@ void GetStatusLabelsForSyncGlobalError(ProfileSyncService* service,
return;
}
- MessageType status = GetStatus(service);
+ MessageType status = GetStatus(service, signin);
if (status != SYNC_ERROR)
return;
@@ -431,12 +438,14 @@ void GetStatusLabelsForSyncGlobalError(ProfileSyncService* service,
}
}
-MessageType GetStatus(ProfileSyncService* service) {
- return sync_ui_util::GetStatusInfo(service, WITH_HTML, NULL, NULL);
+MessageType GetStatus(
+ ProfileSyncService* service, const SigninManager& signin) {
+ return sync_ui_util::GetStatusInfo(service, signin, WITH_HTML, NULL, NULL);
}
-string16 GetSyncMenuLabel(ProfileSyncService* service) {
- MessageType type = GetStatus(service);
+string16 GetSyncMenuLabel(
+ ProfileSyncService* service, const SigninManager& signin) {
+ MessageType type = GetStatus(service, signin);
if (type == sync_ui_util::SYNCED)
return l10n_util::GetStringUTF16(IDS_SYNC_MENU_SYNCED_LABEL);
diff --git a/chrome/browser/sync/sync_ui_util.h b/chrome/browser/sync/sync_ui_util.h
index 222a891..1bade70 100644
--- a/chrome/browser/sync/sync_ui_util.h
+++ b/chrome/browser/sync/sync_ui_util.h
@@ -44,6 +44,7 @@ enum StatusLabelStyle {
// by querying |service|.
// |style| sets the link properties, see |StatusLabelStyle|.
MessageType GetStatusLabels(ProfileSyncService* service,
+ const SigninManager& signin,
StatusLabelStyle style,
string16* status_label,
string16* link_label);
@@ -51,6 +52,7 @@ MessageType GetStatusLabels(ProfileSyncService* service,
// Same as above but for use specifically on the New Tab Page.
// |status_label| may contain an HTML-formatted link.
MessageType GetStatusLabelsForNewTabPage(ProfileSyncService* service,
+ const SigninManager& signin,
string16* status_label,
string16* link_label);
@@ -58,14 +60,16 @@ MessageType GetStatusLabelsForNewTabPage(ProfileSyncService* service,
// |menu_item_label|, |bubble_message|, and |bubble_accept_label| must not be
// NULL.
void GetStatusLabelsForSyncGlobalError(ProfileSyncService* service,
+ const SigninManager& signin,
string16* menu_item_label,
string16* bubble_message,
string16* bubble_accept_label);
-MessageType GetStatus(ProfileSyncService* service);
+MessageType GetStatus(ProfileSyncService* service, const SigninManager& signin);
// Returns a string with the synchronization status.
-string16 GetSyncMenuLabel(ProfileSyncService* service);
+string16 GetSyncMenuLabel(ProfileSyncService* service,
+ const SigninManager& signin);
void AddBoolSyncDetail(base::ListValue* details,
const std::string& stat_name,
diff --git a/chrome/browser/sync/sync_ui_util_mac.mm b/chrome/browser/sync/sync_ui_util_mac.mm
index 322c1ca..dbf40f9 100644
--- a/chrome/browser/sync/sync_ui_util_mac.mm
+++ b/chrome/browser/sync/sync_ui_util_mac.mm
@@ -10,6 +10,8 @@
#include "base/logging.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/signin_manager.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/sync_ui_util.h"
@@ -29,10 +31,11 @@ void UpdateSyncItem(id syncItem, BOOL syncEnabled, Profile* profile) {
ProfileSyncService* syncService =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(
profile->GetOriginalProfile());
+ SigninManager* signin = SigninManagerFactory::GetForProfile(profile);
UpdateSyncItemForStatus(
syncItem,
syncEnabled,
- sync_ui_util::GetStatus(syncService),
+ sync_ui_util::GetStatus(syncService, *signin),
profile->GetPrefs()->GetString(prefs::kGoogleServicesUsername));
}
diff --git a/chrome/browser/sync/sync_ui_util_unittest.cc b/chrome/browser/sync/sync_ui_util_unittest.cc
index 69ff19b..b1b54a9 100644
--- a/chrome/browser/sync/sync_ui_util_unittest.cc
+++ b/chrome/browser/sync/sync_ui_util_unittest.cc
@@ -7,6 +7,8 @@
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/signin_manager.h"
+#include "chrome/browser/signin/signin_manager_fake.h"
#include "chrome/browser/sync/profile_sync_service_mock.h"
#include "chrome/browser/sync/sync_ui_util.h"
#include "content/test/test_browser_thread.h"
@@ -35,9 +37,16 @@ enum DistinctState {
namespace {
+// Mock that allows us to mock a SigninManager that is authenticating.
+class SigninManagerMock : public SigninManager {
+ public:
+ MOCK_CONST_METHOD0(AuthInProgress, bool());
+};
+
// Utility function to test that GetStatusLabelsForSyncGlobalError returns
// the correct results for the given states.
void VerifySyncGlobalErrorResult(NiceMock<ProfileSyncServiceMock>* service,
+ const SigninManager& signin,
GoogleServiceAuthError::State error_state,
bool is_signed_in,
bool is_error) {
@@ -49,7 +58,7 @@ void VerifySyncGlobalErrorResult(NiceMock<ProfileSyncServiceMock>* service,
string16 label1, label2, label3;
sync_ui_util::GetStatusLabelsForSyncGlobalError(
- service, &label1, &label2, &label3);
+ service, signin, &label1, &label2, &label3);
EXPECT_EQ(label1.empty(), !is_error);
EXPECT_EQ(label2.empty(), !is_error);
EXPECT_EQ(label3.empty(), !is_error);
@@ -97,13 +106,14 @@ TEST(SyncUIUtilTest, PassphraseGlobalError) {
scoped_ptr<Profile> profile(
ProfileSyncServiceMock::MakeSignedInTestingProfile());
NiceMock<ProfileSyncServiceMock> service(profile.get());
+ FakeSigninManager signin;
EXPECT_CALL(service, IsPassphraseRequired())
.WillOnce(Return(true));
EXPECT_CALL(service, IsPassphraseRequiredForDecryption())
.WillOnce(Return(true));
VerifySyncGlobalErrorResult(
- &service, GoogleServiceAuthError::NONE, true, true);
+ &service, signin, GoogleServiceAuthError::NONE, true, true);
}
// Test that GetStatusLabelsForSyncGlobalError indicates errors for conditions
@@ -137,16 +147,18 @@ TEST(SyncUIUtilTest, AuthStateGlobalError) {
{ GoogleServiceAuthError::HOSTED_NOT_ALLOWED, true },
};
+ FakeSigninManager signin;
for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) {
VerifySyncGlobalErrorResult(
- &service, table[i].error_state, true, table[i].is_error);
+ &service, signin, table[i].error_state, true, table[i].is_error);
VerifySyncGlobalErrorResult(
- &service, table[i].error_state, false, false);
+ &service, signin, table[i].error_state, false, false);
}
}
// Loads a ProfileSyncServiceMock to emulate one of a number of distinct cases
// in order to perform tests on the generated messages.
void GetDistinctCase(ProfileSyncServiceMock& service,
+ SigninManagerMock& signin,
GoogleServiceAuthError** auth_error,
int caseNumber) {
// Auth Error object is returned by reference in mock and needs to stay in
@@ -164,8 +176,7 @@ void GetDistinctCase(ProfileSyncServiceMock& service,
*auth_error = new GoogleServiceAuthError(GoogleServiceAuthError::NONE);
EXPECT_CALL(service, GetAuthError())
.WillOnce(ReturnRef(**auth_error));
- EXPECT_CALL(service, UIShouldDepictAuthInProgress())
- .WillOnce(Return(false));
+ EXPECT_CALL(signin, AuthInProgress()).WillRepeatedly(Return(false));
return;
}
case STATUS_CASE_SETUP_ERROR: {
@@ -175,6 +186,7 @@ void GetDistinctCase(ProfileSyncServiceMock& service,
.WillOnce(Return(false));
EXPECT_CALL(service, unrecoverable_error_detected())
.WillOnce(Return(true));
+ EXPECT_CALL(signin, AuthInProgress()).WillRepeatedly(Return(false));
browser_sync::SyncBackendHost::Status status;
EXPECT_CALL(service, QueryDetailedSyncStatus())
.WillOnce(Return(status));
@@ -188,8 +200,7 @@ void GetDistinctCase(ProfileSyncServiceMock& service,
.WillOnce(Return(status));
EXPECT_CALL(service, unrecoverable_error_detected())
.WillOnce(Return(false));
- EXPECT_CALL(service, UIShouldDepictAuthInProgress())
- .WillOnce(Return(true));
+ EXPECT_CALL(signin, AuthInProgress()).WillRepeatedly(Return(true));
*auth_error = new GoogleServiceAuthError(GoogleServiceAuthError::NONE);
EXPECT_CALL(service, GetAuthError())
.WillOnce(ReturnRef(**auth_error));
@@ -205,10 +216,9 @@ void GetDistinctCase(ProfileSyncServiceMock& service,
GoogleServiceAuthError::SERVICE_UNAVAILABLE);
EXPECT_CALL(service, unrecoverable_error_detected())
.WillOnce(Return(false));
+ EXPECT_CALL(signin, AuthInProgress()).WillRepeatedly(Return(false));
EXPECT_CALL(service, GetAuthError())
.WillOnce(ReturnRef(**auth_error));
- EXPECT_CALL(service, UIShouldDepictAuthInProgress())
- .WillOnce(Return(false));
return;
}
case STATUS_CASE_PROTOCOL_ERROR: {
@@ -223,10 +233,9 @@ void GetDistinctCase(ProfileSyncServiceMock& service,
*auth_error = new GoogleServiceAuthError(GoogleServiceAuthError::NONE);
EXPECT_CALL(service, GetAuthError())
.WillOnce(ReturnRef(**auth_error));
+ EXPECT_CALL(signin, AuthInProgress()).WillRepeatedly(Return(false));
EXPECT_CALL(service, unrecoverable_error_detected())
.WillOnce(Return(false));
- EXPECT_CALL(service, UIShouldDepictAuthInProgress())
- .WillOnce(Return(false));
return;
}
case STATUS_CASE_PASSPHRASE_ERROR: {
@@ -240,8 +249,7 @@ void GetDistinctCase(ProfileSyncServiceMock& service,
.WillOnce(ReturnRef(**auth_error));
EXPECT_CALL(service, unrecoverable_error_detected())
.WillOnce(Return(false));
- EXPECT_CALL(service, UIShouldDepictAuthInProgress())
- .WillOnce(Return(false));
+ EXPECT_CALL(signin, AuthInProgress()).WillRepeatedly(Return(false));
EXPECT_CALL(service, IsPassphraseRequired())
.WillOnce(Return(true));
EXPECT_CALL(service, IsPassphraseRequiredForDecryption())
@@ -257,10 +265,9 @@ void GetDistinctCase(ProfileSyncServiceMock& service,
*auth_error = new GoogleServiceAuthError(GoogleServiceAuthError::NONE);
EXPECT_CALL(service, GetAuthError())
.WillOnce(ReturnRef(**auth_error));
+ EXPECT_CALL(signin, AuthInProgress()).WillRepeatedly(Return(false));
EXPECT_CALL(service, unrecoverable_error_detected())
.WillOnce(Return(false));
- EXPECT_CALL(service, UIShouldDepictAuthInProgress())
- .WillOnce(Return(false));
EXPECT_CALL(service, IsPassphraseRequired())
.WillOnce(Return(false));
return;
@@ -279,11 +286,13 @@ TEST(SyncUIUtilTest, DistinctCasesReportUniqueMessageSets) {
scoped_ptr<Profile> profile(
ProfileSyncServiceMock::MakeSignedInTestingProfile());
ProfileSyncServiceMock service(profile.get());
+ NiceMock<SigninManagerMock> signin;
GoogleServiceAuthError* auth_error = NULL;
- GetDistinctCase(service, &auth_error, idx);
+ GetDistinctCase(service, signin, &auth_error, idx);
string16 status_label;
string16 link_label;
sync_ui_util::GetStatusLabels(&service,
+ signin,
sync_ui_util::WITH_HTML,
&status_label,
&link_label);
@@ -306,11 +315,13 @@ TEST(SyncUIUtilTest, HtmlNotIncludedInStatusIfNotRequested) {
scoped_ptr<Profile> profile(
ProfileSyncServiceMock::MakeSignedInTestingProfile());
ProfileSyncServiceMock service(profile.get());
+ NiceMock<SigninManagerMock> signin;
GoogleServiceAuthError* auth_error = NULL;
- GetDistinctCase(service, &auth_error, idx);
+ GetDistinctCase(service, signin, &auth_error, idx);
string16 status_label;
string16 link_label;
sync_ui_util::GetStatusLabels(&service,
+ signin,
sync_ui_util::PLAIN_TEXT,
&status_label,
&link_label);
diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.cc b/chrome/browser/ui/toolbar/wrench_menu_model.cc
index 28b53c1..9a3d519 100644
--- a/chrome/browser/ui/toolbar/wrench_menu_model.cc
+++ b/chrome/browser/ui/toolbar/wrench_menu_model.cc
@@ -18,6 +18,8 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/signin/signin_manager.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/sync_global_error.h"
@@ -574,6 +576,8 @@ void WrenchMenuModel::UpdateZoomControls() {
}
string16 WrenchMenuModel::GetSyncMenuLabel() const {
- return sync_ui_util::GetSyncMenuLabel(ProfileSyncServiceFactory::
- GetInstance()->GetForProfile(browser_->profile()->GetOriginalProfile()));
+ Profile* profile = browser_->profile()->GetOriginalProfile();
+ return sync_ui_util::GetSyncMenuLabel(
+ ProfileSyncServiceFactory::GetForProfile(profile),
+ *SigninManagerFactory::GetForProfile(profile));
}
diff --git a/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc b/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc
index 6c36981..fb85261 100644
--- a/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc
+++ b/chrome/browser/ui/webui/ntp/new_tab_page_sync_handler.cc
@@ -109,8 +109,12 @@ void NewTabPageSyncHandler::BuildAndSendSyncStatus() {
// message).
string16 status_msg;
string16 link_text;
+ SigninManager* signin = SigninManagerFactory::GetForProfile(
+ Profile::FromWebUI(web_ui()));
+
sync_ui_util::MessageType type =
sync_ui_util::GetStatusLabelsForNewTabPage(sync_service_,
+ *signin,
&status_msg,
&link_text);
SendSyncMessageToPage(FromSyncStatusMessageType(type),
diff --git a/chrome/browser/ui/webui/options2/browser_options_handler2.cc b/chrome/browser/ui/webui/options2/browser_options_handler2.cc
index 7756a54..b68e5bc 100644
--- a/chrome/browser/ui/webui/options2/browser_options_handler2.cc
+++ b/chrome/browser/ui/webui/options2/browser_options_handler2.cc
@@ -41,6 +41,8 @@
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/service/service_process_control.h"
+#include "chrome/browser/signin/signin_manager.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/sync_ui_util.h"
@@ -1014,8 +1016,11 @@ DictionaryValue* BrowserOptionsHandler::GetSyncStateDictionary() {
string16 status_label;
string16 link_label;
+ SigninManager* signin = SigninManagerFactory::GetForProfile(
+ Profile::FromWebUI(web_ui()));
+
bool status_has_error = sync_ui_util::GetStatusLabels(
- service, sync_ui_util::WITH_HTML, &status_label, &link_label) ==
+ service, *signin, sync_ui_util::WITH_HTML, &status_label, &link_label) ==
sync_ui_util::SYNC_ERROR;
sync_status->SetString("statusText", status_label);
sync_status->SetString("actionLinkText", link_label);