diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-23 22:48:43 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-23 22:48:43 +0000 |
commit | 4693522c1de4eac9e9b2991402325fef54b5381b (patch) | |
tree | 6055390fdaf866276f0b720229ce3a84e744d93d | |
parent | caa95c8a79b536d2fb023545484f13038e9db4a3 (diff) | |
download | chromium_src-4693522c1de4eac9e9b2991402325fef54b5381b.zip chromium_src-4693522c1de4eac9e9b2991402325fef54b5381b.tar.gz chromium_src-4693522c1de4eac9e9b2991402325fef54b5381b.tar.bz2 |
Moved common OpenSyncMyBookmarksDialog() code into SyncStatusUIHelper.
BUG=none
TEST=trybots
Review URL: http://codereview.chromium.org/414064
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32880 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser.cc | 16 | ||||
-rw-r--r-- | chrome/browser/sync/sync_status_ui_helper.cc | 19 | ||||
-rw-r--r-- | chrome/browser/sync/sync_status_ui_helper.h | 9 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_manager_view.cc | 16 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_manager_view.h | 1 |
5 files changed, 32 insertions, 29 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index c0c23c9..c423e8c 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -46,6 +46,7 @@ #include "chrome/browser/sessions/tab_restore_service.h" #include "chrome/browser/status_bubble.h" #include "chrome/browser/sync/profile_sync_service.h" +#include "chrome/browser/sync/sync_status_ui_helper.h" #include "chrome/browser/tab_contents/interstitial_page.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/navigation_entry.h" @@ -1284,19 +1285,8 @@ void Browser::OpenImportSettingsDialog() { } void Browser::OpenSyncMyBookmarksDialog() { - ProfileSyncService* service = - profile_->GetOriginalProfile()->GetProfileSyncService(); - // It shouldn't be possible to be in this function without a service. - DCHECK(service); - if (!service) - return; - - if (service->HasSyncSetupCompleted()) { - ShowOptionsWindow(OPTIONS_PAGE_CONTENT, OPTIONS_GROUP_NONE, profile_); - } else { - service->EnableForUser(); - ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_WRENCH); - } + SyncStatusUIHelper::OpenSyncMyBookmarksDialog( + profile_, ProfileSyncService::START_FROM_WRENCH); } void Browser::OpenAboutChromeDialog() { diff --git a/chrome/browser/sync/sync_status_ui_helper.cc b/chrome/browser/sync/sync_status_ui_helper.cc index 7c6f30b..c6a2aa7 100644 --- a/chrome/browser/sync/sync_status_ui_helper.cc +++ b/chrome/browser/sync/sync_status_ui_helper.cc @@ -8,6 +8,7 @@ #include "base/string_util.h" #include "chrome/browser/google_service_auth_error.h" #include "chrome/browser/sync/profile_sync_service.h" +#include "chrome/browser/options_window.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -116,3 +117,21 @@ SyncStatusUIHelper::MessageType SyncStatusUIHelper::GetLabels( } return result_type; } + +// static +void SyncStatusUIHelper::OpenSyncMyBookmarksDialog( + Profile* profile, ProfileSyncService::SyncEventCodes code) { + ProfileSyncService* service = + profile->GetOriginalProfile()->GetProfileSyncService(); + if (!service) { + LOG(DFATAL) << "OpenSyncMyBookmarksDialog called with sync disabled"; + return; + } + if (service->HasSyncSetupCompleted()) { + ShowOptionsWindow(OPTIONS_PAGE_CONTENT, OPTIONS_GROUP_NONE, profile); + } else { + service->EnableForUser(); + ProfileSyncService::SyncEvent(code); + } +} + diff --git a/chrome/browser/sync/sync_status_ui_helper.h b/chrome/browser/sync/sync_status_ui_helper.h index e54db5d..fac77ea 100644 --- a/chrome/browser/sync/sync_status_ui_helper.h +++ b/chrome/browser/sync/sync_status_ui_helper.h @@ -6,8 +6,9 @@ #define CHROME_BROWSER_SYNC_SYNC_STATUS_UI_HELPER_H_ #include "base/string16.h" +#include "chrome/browser/sync/profile_sync_service.h" -class ProfileSyncService; +class Profile; // Utility to gather current sync status information from the sync service and // constructs messages suitable for showing in UI. @@ -24,6 +25,12 @@ class SyncStatusUIHelper { 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); }; diff --git a/chrome/browser/views/bookmark_manager_view.cc b/chrome/browser/views/bookmark_manager_view.cc index dd717c4..30a9d21 100644 --- a/chrome/browser/views/bookmark_manager_view.cc +++ b/chrome/browser/views/bookmark_manager_view.cc @@ -21,7 +21,6 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/importer/importer.h" #include "chrome/browser/metrics/user_metrics.h" -#include "chrome/browser/options_window.h" #include "chrome/browser/profile.h" #include "chrome/browser/sync/sync_status_ui_helper.h" #include "chrome/browser/views/bookmark_editor_view.h" @@ -513,7 +512,8 @@ void BookmarkManagerView::ButtonPressed(views::Button* sender, const views::Event& event) { if (sender == sync_status_button_) { UserMetrics::RecordAction("BookmarkManager_Sync", profile_); - OpenSyncMyBookmarksDialog(); + SyncStatusUIHelper::OpenSyncMyBookmarksDialog( + profile_, ProfileSyncService::START_FROM_BOOKMARK_MANAGER); } } @@ -830,15 +830,3 @@ void BookmarkManagerView::UpdateSyncStatus() { sync_status_button_->SetText(status_label); sync_status_button_->GetParent()->Layout(); } - -void BookmarkManagerView::OpenSyncMyBookmarksDialog() { - if (!sync_service_) - return; - if (sync_service_->HasSyncSetupCompleted()) { - ShowOptionsWindow(OPTIONS_PAGE_CONTENT, OPTIONS_GROUP_NONE, profile_); - } else { - sync_service_->EnableForUser(); - ProfileSyncService::SyncEvent( - ProfileSyncService::START_FROM_BOOKMARK_MANAGER); - } -} diff --git a/chrome/browser/views/bookmark_manager_view.h b/chrome/browser/views/bookmark_manager_view.h index 1afe28d..aafa82a 100644 --- a/chrome/browser/views/bookmark_manager_view.h +++ b/chrome/browser/views/bookmark_manager_view.h @@ -209,7 +209,6 @@ class BookmarkManagerView : public views::View, void ShowExportBookmarksFileChooser(); void UpdateSyncStatus(); - void OpenSyncMyBookmarksDialog(); Profile* profile_; BookmarkTableView* table_view_; |