diff options
author | csilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-18 01:29:42 +0000 |
---|---|---|
committer | csilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-18 01:29:42 +0000 |
commit | 4a42d27f346529b37f839b27b8b1dedd7e507002 (patch) | |
tree | 73c407a059acf1fc1252c64c201a5253135a28c2 /chrome | |
parent | 988506992537ed14bc02c00a2bae38088befcc0e (diff) | |
download | chromium_src-4a42d27f346529b37f839b27b8b1dedd7e507002.zip chromium_src-4a42d27f346529b37f839b27b8b1dedd7e507002.tar.gz chromium_src-4a42d27f346529b37f839b27b8b1dedd7e507002.tar.bz2 |
Enable domui options for use in browser using the switch:
--enable-tabbed-options
BUG=none
TEST=see description
Review URL: http://codereview.chromium.org/2820007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50191 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/app_controller_mac.mm | 20 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 20 | ||||
-rw-r--r-- | chrome/browser/browser.h | 6 | ||||
-rw-r--r-- | chrome/browser/browser_resources.grd | 2 | ||||
-rw-r--r-- | chrome/browser/dom_ui/dom_ui_factory.cc | 14 | ||||
-rw-r--r-- | chrome/browser/dom_ui/options_ui.cc | 8 | ||||
-rw-r--r-- | chrome/browser/dom_ui/options_ui.h | 2 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 |
9 files changed, 67 insertions, 9 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index b44398a..0ed8a0d 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -783,6 +783,9 @@ void RecordLastRunAppBundlePath() { defaultProfile); TaskManagerMac::Show(); break; + case IDC_OPTIONS: + [self showPreferences:sender]; + break; } } @@ -926,9 +929,20 @@ void RecordLastRunAppBundlePath() { // Show the preferences window, or bring it to the front if it's already // visible. - (IBAction)showPreferences:(id)sender { - [self showPreferencesWindow:sender - page:OPTIONS_PAGE_DEFAULT - profile:[self defaultProfile]]; + const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); + if (parsed_command_line.HasSwitch(switches::kEnableTabbedOptions)) { + if (Browser* browser = ActivateBrowser([self defaultProfile])) { + // Show options tab in the active browser window. + browser->ShowOptionsTab(); + } else { + // No browser window, so create one for the options tab. + Browser::OpenOptionsWindow([self defaultProfile]); + } + } else { + [self showPreferencesWindow:sender + page:OPTIONS_PAGE_DEFAULT + profile:[self defaultProfile]]; + } } - (void)showPreferencesWindow:(id)sender diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index dbf62e9..46518f3 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -631,6 +631,12 @@ void Browser::OpenHelpWindow(Profile* profile) { browser->OpenHelpTab(); browser->window()->Show(); } + +void Browser::OpenOptionsWindow(Profile* profile) { + Browser* browser = Browser::Create(profile); + browser->ShowOptionsTab(); + browser->window()->Show(); +} #endif // static @@ -1697,6 +1703,11 @@ void Browser::ShowBrokenPageTab(TabContents* contents) { ShowSingletonTab(GURL(report_page_url)); } +void Browser::ShowOptionsTab() { + UserMetrics::RecordAction(UserMetricsAction("ShowOptions"), profile_); + ShowSingletonTab(GURL(chrome::kChromeUIOptionsURL)); +} + void Browser::OpenClearBrowsingDataDialog() { UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_ShowDlg"), profile_); @@ -1704,8 +1715,13 @@ void Browser::OpenClearBrowsingDataDialog() { } void Browser::OpenOptionsDialog() { - UserMetrics::RecordAction(UserMetricsAction("ShowOptions"), profile_); - ShowOptionsWindow(OPTIONS_PAGE_DEFAULT, OPTIONS_GROUP_NONE, profile_); + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableTabbedOptions)) { + ShowOptionsTab(); + } else { + UserMetrics::RecordAction(UserMetricsAction("ShowOptions"), profile_); + ShowOptionsWindow(OPTIONS_PAGE_DEFAULT, OPTIONS_GROUP_NONE, profile_); + } } void Browser::OpenKeywordEditor() { diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index 9939c2b..da30b6e 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -259,11 +259,12 @@ class Browser : public TabStripModelDelegate, static void OpenBookmarkManagerWindow(Profile* profile); #if defined(OS_MACOSX) - // Open a new window with history/downloads/help (needed on Mac when there are - // no windows). + // Open a new window with history/downloads/help/options (needed on Mac when + // there are no windows). static void OpenHistoryWindow(Profile* profile); static void OpenDownloadsWindow(Profile* profile); static void OpenHelpWindow(Profile* profile); + static void OpenOptionsWindow(Profile* profile); #endif // Opens a window with the extensions tab in it - needed by long-lived @@ -521,6 +522,7 @@ class Browser : public TabStripModelDelegate, void ShowDownloadsTab(); void ShowExtensionsTab(); void ShowBrokenPageTab(TabContents* contents); + void ShowOptionsTab(); void OpenClearBrowsingDataDialog(); void OpenOptionsDialog(); void OpenKeywordEditor(); diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index 330e0df..ef136af 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -43,8 +43,8 @@ without changes to the corresponding grd file. tiiittttrrr --> <include name="IDR_MEDIAPLAYER_HTML" file="resources\mediaplayer.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_MEDIAPLAYERPLAYLIST_HTML" file="resources\playlist.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_ABOUT_SYS_HTML" file="resources\about_sys.html" flattenhtml="true" type="BINDATA" /> - <include name="IDR_OPTIONS_HTML" file="resources\options.html" flattenhtml="true" type="BINDATA" /> </if> + <include name="IDR_OPTIONS_HTML" file="resources\options.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_APP_GALLERY_ICON" file="resources\app_gallery_icon.png" type="BINDATA" /> <include name="IDR_BOOKMARKS_MANIFEST" file="resources\bookmark_manager\manifest.json" type="BINDATA" /> <include name="IDR_GMAIL_APP_MANIFEST" file="resources\gmail_app\manifest.json" type="BINDATA" /> diff --git a/chrome/browser/dom_ui/dom_ui_factory.cc b/chrome/browser/dom_ui/dom_ui_factory.cc index 4ddfac6..d47e266 100644 --- a/chrome/browser/dom_ui/dom_ui_factory.cc +++ b/chrome/browser/dom_ui/dom_ui_factory.cc @@ -4,6 +4,7 @@ #include "chrome/browser/dom_ui/dom_ui_factory.h" +#include "base/command_line.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/dom_ui/bookmarks_ui.h" #include "chrome/browser/dom_ui/downloads_ui.h" @@ -13,19 +14,20 @@ #include "chrome/browser/dom_ui/net_internals_ui.h" #include "chrome/browser/dom_ui/new_tab_ui.h" #include "chrome/browser/dom_ui/plugins_ui.h" +#include "chrome/browser/dom_ui/options_ui.h" #include "chrome/browser/extensions/extension_dom_ui.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/extensions/extensions_ui.h" #include "chrome/browser/printing/print_dialog_cloud.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" #include "googleurl/src/gurl.h" #if defined(OS_CHROMEOS) #include "chrome/browser/dom_ui/filebrowse_ui.h" #include "chrome/browser/dom_ui/mediaplayer_ui.h" -#include "chrome/browser/dom_ui/options_ui.h" #endif const DOMUITypeID DOMUIFactory::kNoDOMUI = NULL; @@ -114,6 +116,13 @@ static DOMUIFactoryFunction GetDOMUIFactoryFunction(const GURL& url) { return &NewDOMUI<MediaplayerUI>; if (url.host() == chrome::kChromeUIOptionsHost) return &NewDOMUI<OptionsUI>; +#else + if (url.host() == chrome::kChromeUIOptionsHost) { + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableTabbedOptions)) { + return &NewDOMUI<OptionsUI>; + } + } #endif return NULL; @@ -170,5 +179,8 @@ RefCountedMemory* DOMUIFactory::GetFaviconResourceBytes(Profile* profile, if (page_url.host() == chrome::kChromeUIPluginsHost) return PluginsUI::GetFaviconResourceBytes(); + if (page_url.host() == chrome::kChromeUIOptionsHost) + return OptionsUI::GetFaviconResourceBytes(); + return NULL; } diff --git a/chrome/browser/dom_ui/options_ui.cc b/chrome/browser/dom_ui/options_ui.cc index 652a168..2994e7c 100644 --- a/chrome/browser/dom_ui/options_ui.cc +++ b/chrome/browser/dom_ui/options_ui.cc @@ -116,6 +116,14 @@ OptionsUI::OptionsUI(TabContents* contents) : DOMUI(contents) { make_scoped_refptr(html_source))); } +// static +RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { +// TODO(csilv): uncomment this once we have a FAVICON +// return ResourceBundle::GetSharedInstance(). +// LoadDataResourceBytes(IDR_OPTIONS_FAVICON); + return NULL; +} + void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings, OptionsPageUIHandler* handler) { DCHECK(handler); diff --git a/chrome/browser/dom_ui/options_ui.h b/chrome/browser/dom_ui/options_ui.h index a79b3bb..a13ab94 100644 --- a/chrome/browser/dom_ui/options_ui.h +++ b/chrome/browser/dom_ui/options_ui.h @@ -73,6 +73,8 @@ class OptionsUI : public DOMUI { explicit OptionsUI(TabContents* contents); virtual ~OptionsUI() {} + static RefCountedMemory* GetFaviconResourceBytes(); + private: void AddOptionsPageUIHandler(DictionaryValue* localized_strings, OptionsPageUIHandler* handler); diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 4ded0ea..f5b6dac 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -369,6 +369,9 @@ const char kEnableSyncThemes[] = "enable-sync-themes"; // Enable syncing browser typed urls. const char kEnableSyncTypedUrls[] = "enable-sync-typed-urls"; +// Enable tabbed options, ie: dom-ui version of options window. +const char kEnableTabbedOptions[] = "enable-tabbed-options"; + // Whether or not the touch events API is exposed. const char kEnableTouch[] = "enable-touch"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 9201666..a6ea1d4 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -122,6 +122,7 @@ extern const char kEnableSyncPasswords[]; extern const char kEnableSyncPreferences[]; extern const char kEnableSyncThemes[]; extern const char kEnableSyncTypedUrls[]; +extern const char kEnableTabbedOptions[]; extern const char kEnableTouch[]; extern const char kEnableVerticalTabs[]; extern const char kEnableVideoFullscreen[]; |