summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 03:54:40 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 03:54:40 +0000
commit40f04797e143e6b3fe59dbccdf7053aa2a7a2fe6 (patch)
tree0037cf6381a4876ee66f1f6330b0d1aef551815e /chrome/browser/sync
parent6a7e698052d3b0d0aafebd5ac6af0ef2f95ff2a9 (diff)
downloadchromium_src-40f04797e143e6b3fe59dbccdf7053aa2a7a2fe6.zip
chromium_src-40f04797e143e6b3fe59dbccdf7053aa2a7a2fe6.tar.gz
chromium_src-40f04797e143e6b3fe59dbccdf7053aa2a7a2fe6.tar.bz2
Changed SyncStatusUIHelper namespace class into a real namespace (sync_ui_util), per style guide.
Changed static functions into anonymous-namespace functions. Renamed files/namespaces from sync_status_ui_helper to sync_ui_util. Moved sync_ui_util_mac.mm functions into sync_ui_util namespace. Updated all callers. BUG=none TEST=trybots Review URL: http://codereview.chromium.org/414065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33044 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r--chrome/browser/sync/sync_status_ui_helper.h38
-rw-r--r--chrome/browser/sync/sync_ui_util.cc (renamed from chrome/browser/sync/sync_status_ui_helper.cc)29
-rw-r--r--chrome/browser/sync/sync_ui_util.h36
-rw-r--r--chrome/browser/sync/sync_ui_util_mac.h (renamed from chrome/browser/sync/sync_status_ui_helper_mac.h)14
-rw-r--r--chrome/browser/sync/sync_ui_util_mac.mm (renamed from chrome/browser/sync/sync_status_ui_helper_mac.mm)20
-rw-r--r--chrome/browser/sync/sync_ui_util_mac_unittest.mm (renamed from chrome/browser/sync/sync_status_ui_helper_mac_unittest.mm)28
6 files changed, 84 insertions, 81 deletions
diff --git a/chrome/browser/sync/sync_status_ui_helper.h b/chrome/browser/sync/sync_status_ui_helper.h
deleted file mode 100644
index fac77ea..0000000
--- a/chrome/browser/sync/sync_status_ui_helper.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_SYNC_SYNC_STATUS_UI_HELPER_H_
-#define CHROME_BROWSER_SYNC_SYNC_STATUS_UI_HELPER_H_
-
-#include "base/string16.h"
-#include "chrome/browser/sync/profile_sync_service.h"
-
-class Profile;
-
-// Utility to gather current sync status information from the sync service and
-// constructs messages suitable for showing in UI.
-class SyncStatusUIHelper {
- public:
- enum MessageType {
- PRE_SYNCED, // User has not set up sync.
- SYNCED, // We are synced and authenticated to a gmail account.
- SYNC_ERROR, // A sync error (such as invalid credentials) has occurred.
- };
-
- // Create status and link labels for the current status labels and link text
- // by querying |service|.
- static MessageType GetLabels(ProfileSyncService* service,
- string16* status_label,
- string16* link_label);
-
- // Open the appropriate sync dialog for the given profile (which can be
- // incognito). |code| should be one of the START_FROM_* codes.
- static void OpenSyncMyBookmarksDialog(
- Profile* profile, ProfileSyncService::SyncEventCodes code);
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(SyncStatusUIHelper);
-};
-
-#endif // CHROME_BROWSER_SYNC_SYNC_STATUS_UI_HELPER_H_
diff --git a/chrome/browser/sync/sync_status_ui_helper.cc b/chrome/browser/sync/sync_ui_util.cc
index c6a2aa7..b973362 100644
--- a/chrome/browser/sync/sync_status_ui_helper.cc
+++ b/chrome/browser/sync/sync_ui_util.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/sync/sync_status_ui_helper.h"
+#include "chrome/browser/sync/sync_ui_util.h"
#include "app/l10n_util.h"
#include "base/string_util.h"
@@ -14,10 +14,14 @@
typedef GoogleServiceAuthError AuthError;
+namespace sync_ui_util {
+
+namespace {
+
// Given an authentication state, this helper function returns the appropriate
// status message and, if necessary, the text that should appear in the
// re-login link.
-static void GetLabelsForAuthError(const AuthError& auth_error,
+void GetStatusLabelsForAuthError(const AuthError& auth_error,
ProfileSyncService* service, string16* status_label,
string16* link_label) {
if (link_label)
@@ -48,7 +52,7 @@ static void GetLabelsForAuthError(const AuthError& auth_error,
// Returns the message that should be displayed when the user is authenticated
// and can connect to the sync server. If the user hasn't yet authenticated, an
// empty string is returned.
-static string16 GetSyncedStateStatusLabel(ProfileSyncService* service) {
+string16 GetSyncedStateStatusLabel(ProfileSyncService* service) {
string16 label;
string16 user_name(service->GetAuthenticatedUsername());
if (user_name.empty())
@@ -60,10 +64,11 @@ static string16 GetSyncedStateStatusLabel(ProfileSyncService* service) {
WideToUTF16(service->GetLastSyncedTimeString()));
}
-// static
-SyncStatusUIHelper::MessageType SyncStatusUIHelper::GetLabels(
- ProfileSyncService* service, string16* status_label,
- string16* link_label) {
+} // namespace
+
+MessageType GetStatusLabels(ProfileSyncService* service,
+ string16* status_label,
+ string16* link_label) {
MessageType result_type(SYNCED);
if (!service) {
@@ -85,7 +90,8 @@ SyncStatusUIHelper::MessageType SyncStatusUIHelper::GetLabels(
l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL));
result_type = PRE_SYNCED;
} else if (auth_error.state() != AuthError::NONE) {
- GetLabelsForAuthError(auth_error, service, status_label, link_label);
+ GetStatusLabelsForAuthError(auth_error, service,
+ status_label, link_label);
result_type = SYNC_ERROR;
}
} else {
@@ -102,7 +108,7 @@ SyncStatusUIHelper::MessageType SyncStatusUIHelper::GetLabels(
l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL));
} else if (auth_error.state() != AuthError::NONE) {
status_label->clear();
- GetLabelsForAuthError(auth_error, service, status_label, NULL);
+ GetStatusLabelsForAuthError(auth_error, service, status_label, NULL);
result_type = SYNC_ERROR;
} else if (!status.authenticated) {
status_label->assign(
@@ -118,8 +124,7 @@ SyncStatusUIHelper::MessageType SyncStatusUIHelper::GetLabels(
return result_type;
}
-// static
-void SyncStatusUIHelper::OpenSyncMyBookmarksDialog(
+void OpenSyncMyBookmarksDialog(
Profile* profile, ProfileSyncService::SyncEventCodes code) {
ProfileSyncService* service =
profile->GetOriginalProfile()->GetProfileSyncService();
@@ -135,3 +140,5 @@ void SyncStatusUIHelper::OpenSyncMyBookmarksDialog(
}
}
+} // namespace sync_ui_util
+
diff --git a/chrome/browser/sync/sync_ui_util.h b/chrome/browser/sync/sync_ui_util.h
new file mode 100644
index 0000000..a80359b
--- /dev/null
+++ b/chrome/browser/sync/sync_ui_util.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SYNC_SYNC_UI_UTIL_H_
+#define CHROME_BROWSER_SYNC_SYNC_UI_UTIL_H_
+
+#include "base/string16.h"
+#include "chrome/browser/sync/profile_sync_service.h"
+
+class Profile;
+
+// Utility functions to gather current sync status information from the sync
+// service and constructs messages suitable for showing in UI.
+namespace sync_ui_util {
+
+enum MessageType {
+ PRE_SYNCED, // User has not set up sync.
+ SYNCED, // We are synced and authenticated to a gmail account.
+ SYNC_ERROR, // A sync error (such as invalid credentials) has occurred.
+};
+
+// Create status and link labels for the current status labels and link text
+// by querying |service|.
+MessageType GetStatusLabels(ProfileSyncService* service,
+ string16* status_label,
+ string16* link_label);
+
+// Open the appropriate sync dialog for the given profile (which can be
+// incognito). |code| should be one of the START_FROM_* codes.
+void OpenSyncMyBookmarksDialog(
+ Profile* profile, ProfileSyncService::SyncEventCodes code);
+} // namespace sync_ui_util
+
+#endif // CHROME_BROWSER_SYNC_SYNC_UI_UTIL_H_
+
diff --git a/chrome/browser/sync/sync_status_ui_helper_mac.h b/chrome/browser/sync/sync_ui_util_mac.h
index 36b9bb3..65fba88 100644
--- a/chrome/browser/sync/sync_status_ui_helper_mac.h
+++ b/chrome/browser/sync/sync_ui_util_mac.h
@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_SYNC_SYNC_STATUS_UI_HELPER_MAC_H_
-#define CHROME_BROWSER_SYNC_SYNC_STATUS_UI_HELPER_MAC_H_
+#ifndef CHROME_BROWSER_SYNC_SYNC_UI_UTIL_MAC_H_
+#define CHROME_BROWSER_SYNC_SYNC_UI_UTIL_MAC_H_
-#include "chrome/browser/sync/sync_status_ui_helper.h"
+#include "chrome/browser/sync/sync_ui_util.h"
#import <Cocoa/Cocoa.h>
class Profile;
-namespace browser_sync {
+namespace sync_ui_util {
// Updates a bookmark sync UI item (expected to be a menu item). This is
// called every time a menu containing a sync UI item is displayed.
@@ -20,9 +20,9 @@ void UpdateSyncItem(id syncItem, BOOL syncEnabled, Profile* profile);
// This function (used by UpdateSyncItem) is only exposed for testing.
// Just use UpdateSyncItem() instead.
void UpdateSyncItemForStatus(id syncItem, BOOL syncEnabled,
- SyncStatusUIHelper::MessageType status);
+ sync_ui_util::MessageType status);
-} // namespace browser_sync
+} // namespace sync_ui_util
-#endif // CHROME_BROWSER_SYNC_SYNC_STATUS_UI_HELPER_H_
+#endif // CHROME_BROWSER_SYNC_SYNC_UI_UTIL_MAC_H_
diff --git a/chrome/browser/sync/sync_status_ui_helper_mac.mm b/chrome/browser/sync/sync_ui_util_mac.mm
index 75d199f..1e04b22 100644
--- a/chrome/browser/sync/sync_status_ui_helper_mac.mm
+++ b/chrome/browser/sync/sync_ui_util_mac.mm
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/sync/sync_status_ui_helper_mac.h"
+#include "chrome/browser/sync/sync_ui_util_mac.h"
#import <Cocoa/Cocoa.h>
#include "app/l10n_util_mac.h"
#include "base/logging.h"
#include "chrome/browser/profile.h"
-#include "chrome/browser/sync/sync_status_ui_helper.h"
+#include "chrome/browser/sync/sync_ui_util.h"
#include "grit/generated_resources.h"
-namespace browser_sync {
+namespace sync_ui_util {
void UpdateSyncItem(id syncItem, BOOL syncEnabled, Profile* profile) {
ProfileSyncService* syncService =
@@ -20,13 +20,13 @@ void UpdateSyncItem(id syncItem, BOOL syncEnabled, Profile* profile) {
// TODO(timsteele): Need a ui helper method to just get the type
// without needing labels.
string16 label, link;
- SyncStatusUIHelper::MessageType status =
- SyncStatusUIHelper::GetLabels(syncService, &label, &link);
+ sync_ui_util::MessageType status =
+ sync_ui_util::GetStatusLabels(syncService, &label, &link);
UpdateSyncItemForStatus(syncItem, syncEnabled, status);
}
void UpdateSyncItemForStatus(id syncItem, BOOL syncEnabled,
- SyncStatusUIHelper::MessageType status) {
+ sync_ui_util::MessageType status) {
DCHECK([syncItem isKindOfClass:[NSMenuItem class]]);
NSMenuItem* syncMenuItem = static_cast<NSMenuItem*>(syncItem);
// Look for a separator immediately after the menu item.
@@ -47,13 +47,13 @@ void UpdateSyncItemForStatus(id syncItem, BOOL syncEnabled,
// chrome/browser/views/toolbar_view.cc.
int titleId;
switch (status) {
- case SyncStatusUIHelper::SYNCED:
+ case sync_ui_util::SYNCED:
titleId = IDS_SYNC_MENU_BOOKMARKS_SYNCED_LABEL;
break;
- case SyncStatusUIHelper::SYNC_ERROR:
+ case sync_ui_util::SYNC_ERROR:
titleId = IDS_SYNC_MENU_BOOKMARK_SYNC_ERROR_LABEL;
break;
- case SyncStatusUIHelper::PRE_SYNCED:
+ case sync_ui_util::PRE_SYNCED:
titleId = IDS_SYNC_START_SYNC_BUTTON_LABEL;
break;
default:
@@ -72,4 +72,4 @@ void UpdateSyncItemForStatus(id syncItem, BOOL syncEnabled,
[followingSeparator setHidden:!syncEnabled];
}
-} // namespace browser_sync
+} // namespace sync_ui_util
diff --git a/chrome/browser/sync/sync_status_ui_helper_mac_unittest.mm b/chrome/browser/sync/sync_ui_util_mac_unittest.mm
index e5418e1..ebe3bcc 100644
--- a/chrome/browser/sync/sync_status_ui_helper_mac_unittest.mm
+++ b/chrome/browser/sync/sync_ui_util_mac_unittest.mm
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/sync/sync_status_ui_helper_mac.h"
+#include "chrome/browser/sync/sync_ui_util_mac.h"
#import <Cocoa/Cocoa.h>
@@ -35,22 +35,22 @@ TEST_F(SyncStatusUIHelperMacTest, UpdateSyncItem) {
[syncMenuItem setTitle:@""];
[syncMenuItem setHidden:NO];
- browser_sync::UpdateSyncItemForStatus(syncMenuItem, NO,
- SyncStatusUIHelper::PRE_SYNCED);
+ sync_ui_util::UpdateSyncItemForStatus(syncMenuItem, NO,
+ sync_ui_util::PRE_SYNCED);
EXPECT_TRUE([[syncMenuItem title] isEqualTo:startSync]);
EXPECT_TRUE([syncMenuItem isHidden]);
[syncMenuItem setTitle:@""];
[syncMenuItem setHidden:YES];
- browser_sync::UpdateSyncItemForStatus(syncMenuItem, YES,
- SyncStatusUIHelper::SYNC_ERROR);
+ sync_ui_util::UpdateSyncItemForStatus(syncMenuItem, YES,
+ sync_ui_util::SYNC_ERROR);
EXPECT_TRUE([[syncMenuItem title] isEqualTo:bookmarkSyncError]);
EXPECT_FALSE([syncMenuItem isHidden]);
[syncMenuItem setTitle:@""];
[syncMenuItem setHidden:NO];
- browser_sync::UpdateSyncItemForStatus(syncMenuItem, NO,
- SyncStatusUIHelper::SYNCED);
+ sync_ui_util::UpdateSyncItemForStatus(syncMenuItem, NO,
+ sync_ui_util::SYNCED);
EXPECT_TRUE([[syncMenuItem title] isEqualTo:bookmarksSynced]);
EXPECT_TRUE([syncMenuItem isHidden]);
}
@@ -65,19 +65,18 @@ TEST_F(SyncStatusUIHelperMacTest, UpdateSyncItemWithSeparator) {
NSMenuItem* followingSeparator = [NSMenuItem separatorItem];
[menu addItem:followingSeparator];
- const SyncStatusUIHelper::MessageType kStatus =
- SyncStatusUIHelper::PRE_SYNCED;
+ const sync_ui_util::MessageType kStatus = sync_ui_util::PRE_SYNCED;
[syncMenuItem setHidden:NO];
[followingSeparator setHidden:NO];
- browser_sync::UpdateSyncItemForStatus(syncMenuItem, NO, kStatus);
+ sync_ui_util::UpdateSyncItemForStatus(syncMenuItem, NO, kStatus);
EXPECT_FALSE([followingSeparator isEnabled]);
EXPECT_TRUE([syncMenuItem isHidden]);
EXPECT_TRUE([followingSeparator isHidden]);
[syncMenuItem setHidden:YES];
[followingSeparator setHidden:YES];
- browser_sync::UpdateSyncItemForStatus(syncMenuItem, YES, kStatus);
+ sync_ui_util::UpdateSyncItemForStatus(syncMenuItem, YES, kStatus);
EXPECT_FALSE([followingSeparator isEnabled]);
EXPECT_FALSE([syncMenuItem isHidden]);
EXPECT_FALSE([followingSeparator isHidden]);
@@ -95,14 +94,13 @@ TEST_F(SyncStatusUIHelperMacTest, UpdateSyncItemWithNonSeparator) {
action:@selector(commandDispatch)
keyEquivalent:@""];
- const SyncStatusUIHelper::MessageType kStatus =
- SyncStatusUIHelper::PRE_SYNCED;
+ const sync_ui_util::MessageType kStatus = sync_ui_util::PRE_SYNCED;
- browser_sync::UpdateSyncItemForStatus(syncMenuItem, NO, kStatus);
+ sync_ui_util::UpdateSyncItemForStatus(syncMenuItem, NO, kStatus);
EXPECT_TRUE([followingNonSeparator isEnabled]);
EXPECT_FALSE([followingNonSeparator isHidden]);
- browser_sync::UpdateSyncItemForStatus(syncMenuItem, YES, kStatus);
+ sync_ui_util::UpdateSyncItemForStatus(syncMenuItem, YES, kStatus);
EXPECT_TRUE([followingNonSeparator isEnabled]);
EXPECT_FALSE([followingNonSeparator isHidden]);
}