diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-25 17:10:23 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-25 17:10:23 +0000 |
commit | c8de64a361acfe2be034fdc0d925f07e25889a07 (patch) | |
tree | 24ff13965f60528de6d5a0288cec536282bb5dcc | |
parent | 25736ca0a41f68ae6546b976d16a95af2f7ec3e5 (diff) | |
download | chromium_src-c8de64a361acfe2be034fdc0d925f07e25889a07.zip chromium_src-c8de64a361acfe2be034fdc0d925f07e25889a07.tar.gz chromium_src-c8de64a361acfe2be034fdc0d925f07e25889a07.tar.bz2 |
Fix DOMUI pref mode handling of Mac menu items
In DOMUI pref mode, Mac menu items should open prefs via a browser window. Also fixes OpenSyncMyBookmarksDialog on all platforms.
BUG=67670
TEST=Choosing a pref-opening menu item from the Chrome menu on Mac should open DOMUI prefs.
Review URL: http://codereview.chromium.org/6293018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72500 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/app_controller_mac.mm | 35 | ||||
-rw-r--r-- | chrome/browser/sync/sync_ui_util.cc | 26 | ||||
-rw-r--r-- | chrome/browser/sync/sync_ui_util.h | 11 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 16 | ||||
-rw-r--r-- | chrome/browser/ui/browser.h | 4 |
5 files changed, 74 insertions, 18 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index 058ed16..c77d3f3 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -848,15 +848,33 @@ void RecordLastRunAppBundlePath() { break; case IDC_CLEAR_BROWSING_DATA: { // There may not be a browser open, so use the default profile. - [ClearBrowsingDataController - showClearBrowsingDialogForProfile:defaultProfile]; + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableTabbedOptions)) { + [ClearBrowsingDataController + showClearBrowsingDialogForProfile:defaultProfile]; + } else { + if (Browser* browser = ActivateBrowser(defaultProfile)) { + browser->OpenClearBrowsingDataDialog(); + } else { + Browser::OpenClearBrowingDataDialogWindow(defaultProfile); + } + } break; } case IDC_IMPORT_SETTINGS: { - UserMetrics::RecordAction(UserMetricsAction("Import_ShowDlg"), - defaultProfile); - [ImportSettingsDialogController - showImportSettingsDialogForProfile:defaultProfile]; + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableTabbedOptions)) { + UserMetrics::RecordAction(UserMetricsAction("Import_ShowDlg"), + defaultProfile); + [ImportSettingsDialogController + showImportSettingsDialogForProfile:defaultProfile]; + } else { + if (Browser* browser = ActivateBrowser(defaultProfile)) { + browser->OpenImportSettingsDialog(); + } else { + Browser::OpenImportSettingsDialogWindow(defaultProfile); + } + } break; } case IDC_SHOW_BOOKMARK_MANAGER: @@ -918,7 +936,8 @@ void RecordLastRunAppBundlePath() { // TODO(akalin): Add a constant to denote starting sync from the // main menu and use that instead of START_FROM_WRENCH. sync_ui_util::OpenSyncMyBookmarksDialog( - defaultProfile, ProfileSyncService::START_FROM_WRENCH); + defaultProfile, ActivateBrowser(defaultProfile), + ProfileSyncService::START_FROM_WRENCH); break; case IDC_TASK_MANAGER: UserMetrics::RecordAction(UserMetricsAction("TaskManager"), diff --git a/chrome/browser/sync/sync_ui_util.cc b/chrome/browser/sync/sync_ui_util.cc index f23fe75..06785ca 100644 --- a/chrome/browser/sync/sync_ui_util.cc +++ b/chrome/browser/sync/sync_ui_util.cc @@ -1,17 +1,21 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. #include "chrome/browser/sync/sync_ui_util.h" +#include "base/command_line.h" #include "base/i18n/number_formatting.h" #include "base/i18n/time_formatting.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/profile_sync_service.h" +#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/options/options_window.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/net/gaia/google_service_auth_error.h" +#include "chrome/common/url_constants.h" #include "grit/browser_resources.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -266,16 +270,30 @@ string16 GetSyncMenuLabel(ProfileSyncService* service) { return l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL); } -void OpenSyncMyBookmarksDialog( - Profile* profile, ProfileSyncService::SyncEventCodes code) { +void OpenSyncMyBookmarksDialog(Profile* profile, + Browser* browser, + ProfileSyncService::SyncEventCodes code) { ProfileSyncService* service = profile->GetOriginalProfile()->GetProfileSyncService(); if (!service || !service->IsSyncEnabled()) { LOG(DFATAL) << "OpenSyncMyBookmarksDialog called with sync disabled"; return; } + + bool use_tabbed_options = !CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableTabbedOptions); + if (service->HasSyncSetupCompleted()) { - ShowOptionsWindow(OPTIONS_PAGE_CONTENT, OPTIONS_GROUP_NONE, profile); + if (use_tabbed_options) { + bool create_window = browser == NULL; + if (create_window) + browser = Browser::Create(profile); + browser->ShowOptionsTab(chrome::kPersonalOptionsSubPage); + if (create_window) + browser->window()->Show(); + } else { + ShowOptionsWindow(OPTIONS_PAGE_CONTENT, OPTIONS_GROUP_NONE, profile); + } } else { service->ShowLoginDialog(NULL); ProfileSyncService::SyncEvent(code); // UMA stats diff --git a/chrome/browser/sync/sync_ui_util.h b/chrome/browser/sync/sync_ui_util.h index 5ea41f3..065f82f 100644 --- a/chrome/browser/sync/sync_ui_util.h +++ b/chrome/browser/sync/sync_ui_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -12,6 +12,7 @@ #include "base/values.h" #include "chrome/browser/sync/profile_sync_service.h" +class Browser; class Profile; class ListValue; class DictionaryValue; @@ -53,9 +54,11 @@ bool ShouldShowSyncErrorButton(ProfileSyncService* service); string16 GetSyncMenuLabel(ProfileSyncService* service); // 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); +// incognito). |browser| is the browser window that should be used if the UI +// is in-window (i.e., DOMUI). |code| should be one of the START_FROM_* codes. +void OpenSyncMyBookmarksDialog(Profile* profile, + Browser* browser, + ProfileSyncService::SyncEventCodes code); void AddBoolSyncDetail(ListValue* details, const std::string& stat_name, diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 1281094..c95aa7d 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -689,6 +689,20 @@ void Browser::OpenOptionsWindow(Profile* profile) { browser->ShowOptionsTab(chrome::kDefaultOptionsSubPage); browser->window()->Show(); } + +// static +void Browser::OpenClearBrowingDataDialogWindow(Profile* profile) { + Browser* browser = Browser::Create(profile); + browser->OpenClearBrowsingDataDialog(); + browser->window()->Show(); +} + +// static +void Browser::OpenImportSettingsDialogWindow(Profile* profile) { + Browser* browser = Browser::Create(profile); + browser->OpenImportSettingsDialog(); + browser->window()->Show(); +} #endif // static @@ -1847,7 +1861,7 @@ void Browser::OpenImportSettingsDialog() { void Browser::OpenSyncMyBookmarksDialog() { sync_ui_util::OpenSyncMyBookmarksDialog( - profile_, ProfileSyncService::START_FROM_WRENCH); + profile_, this, ProfileSyncService::START_FROM_WRENCH); } void Browser::OpenAboutChromeDialog() { diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index a72e7e9..d59030e 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -277,6 +277,8 @@ class Browser : public TabHandlerDelegate, static void OpenDownloadsWindow(Profile* profile); static void OpenHelpWindow(Profile* profile); static void OpenOptionsWindow(Profile* profile); + static void OpenClearBrowingDataDialogWindow(Profile* profile); + static void OpenImportSettingsDialogWindow(Profile* profile); #endif // Opens a window with the extensions tab in it - needed by long-lived |