diff options
-rw-r--r-- | chrome/app/generated_resources.grd | 7 | ||||
-rw-r--r-- | chrome/browser/about_flags.cc | 7 | ||||
-rw-r--r-- | chrome/browser/browser_about_handler.cc | 20 | ||||
-rw-r--r-- | chrome/browser/resources/uber/uber.html | 2 | ||||
-rw-r--r-- | chrome/browser/resources/uber/uber.js | 84 | ||||
-rw-r--r-- | chrome/browser/resources/uber/uber_frame.html | 2 | ||||
-rw-r--r-- | chrome/browser/resources/uber/uber_frame.js | 3 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 27 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/common/url_constants.cc | 1 | ||||
-rw-r--r-- | chrome/common/url_constants.h | 1 | ||||
-rw-r--r-- | chrome/test/base/in_process_browser_test.cc | 2 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.cc | 1 |
14 files changed, 139 insertions, 22 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index e5d39eb..b24680e 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -7907,6 +7907,13 @@ To hide access to this program, you need to uninstall it by using Would you like to start <ph name="CONTROL_PANEL_APPLET_NAME">$1<ex>Add/Remove Programs</ex></ph>? </message> + <message name="IDS_FLAGS_DISABLE_UBER_PAGE_NAME" desc="Title for the flag to disable uber page URL redirection."> + Disable new settings and extensions web-ui + </message> + <message name="IDS_FLAGS_DISABLE_UBER_PAGE_DESCRIPTION" desc="Description for the flag to disable uber page URL redirection."> + The settings and extensions web-ui will be reverted to the prior implementation. + </message> + <if expr="pp_ifdef('chromeos')"> <message name="IDS_SETTINGS_TITLE" desc="Title for the settings tab."> Settings diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index b9685b7..4861c7f 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -541,6 +541,13 @@ const Experiment kExperiments[] = { kOsWin | kOsLinux | kOsMac, SINGLE_VALUE_TYPE(switches::kEnableMediaStream) }, + { + "disable-uber-page", + IDS_FLAGS_DISABLE_UBER_PAGE_NAME, + IDS_FLAGS_DISABLE_UBER_PAGE_DESCRIPTION, + kOsAll, + SINGLE_VALUE_TYPE(switches::kDisableUberPage) + }, }; const Experiment* experiments = kExperiments; diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 93347ca..0cb3bf4 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -6,12 +6,14 @@ #include <string> +#include "base/command_line.h" #include "base/logging.h" #include "base/memory/singleton.h" #include "base/string_util.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/common/about_handler.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" #include "content/browser/gpu/gpu_process_host_ui_shim.h" #include "content/browser/sensors/sensors_provider.h" @@ -106,6 +108,9 @@ bool WillHandleBrowserAboutURL(GURL* url, if (chrome_about_handler::WillHandle(*url)) return false; + CommandLine* cl = CommandLine::ForCurrentProcess(); + bool enableUberPage = !cl->HasSwitch(switches::kDisableUberPage); + std::string host(url->host()); std::string path; // Replace about with chrome-urls. @@ -120,10 +125,19 @@ bool WillHandleBrowserAboutURL(GURL* url, // Replace sync with sync-internals (for legacy reasons). } else if (host == chrome::kChromeUISyncHost) { host = chrome::kChromeUISyncInternalsHost; - // Redirect chrome://extensions to chrome://settings/extensions. + // Redirect chrome://extensions. } else if (host == chrome::kChromeUIExtensionsHost) { - host = chrome::kChromeUISettingsHost; - path = chrome::kExtensionsSubPage; + if (enableUberPage) { + host = chrome::kChromeUIUberHost; + path = chrome::kChromeUIExtensionsHost + url->path(); + } else { + host = chrome::kChromeUISettingsHost; + path = chrome::kExtensionsSubPage; + } + // Redirect chrome://settings + } else if (enableUberPage && host == chrome::kChromeUISettingsHost) { + host = chrome::kChromeUIUberHost; + path = chrome::kChromeUISettingsHost + url->path(); } GURL::Replacements replacements; replacements.SetHostStr(host); diff --git a/chrome/browser/resources/uber/uber.html b/chrome/browser/resources/uber/uber.html index c47866f..07c4ab35 100644 --- a/chrome/browser/resources/uber/uber.html +++ b/chrome/browser/resources/uber/uber.html @@ -18,7 +18,7 @@ <div id="navigation"><iframe src="chrome://uber-frame/"></iframe></div> -<div class="iframe-container selected" i18n-values="id:settingsHost"> +<div class="iframe-container" i18n-values="id:settingsHost"> <iframe src="chrome://settings-frame/"></iframe></div> <div class="iframe-container" i18n-values="id:extensionsHost"> <iframe src="chrome://extensions-frame/"></iframe></div> diff --git a/chrome/browser/resources/uber/uber.js b/chrome/browser/resources/uber/uber.js index 2f31d5c..5186d2a 100644 --- a/chrome/browser/resources/uber/uber.js +++ b/chrome/browser/resources/uber/uber.js @@ -5,19 +5,67 @@ cr.define('uber', function() { /** + * Options for how web history should be handled. + **/ + var HISTORY_STATE_OPTION = { + PUSH: 1, // Push a new history state. + REPLACE: 2 // Replace the current history state. + }; + + /** * Handles page initialization. */ - function onLoad() { - // Update the URL if need be. - if (window.location.pathname === '/') { - var pageId = getSelectedIframe().id; - window.history.replaceState({pageId: pageId}, '', '/' + pageId); + function onLoad(e) { + // If the pathname points to a sub-page, we may need to alter the location + // of one of the frames. + var params = resolvePageInfoFromPath(window.location.pathname); + if (params.path) { + var iframe = $(params.id).querySelector('iframe'); + iframe.contentWindow.location.replace(iframe.src + params.path); } + // Select a page based on the page-URL. + showPage(params.id, HISTORY_STATE_OPTION.REPLACE); + window.addEventListener('message', handleWindowMessage); } /** + * Find page information from the given path. If the path doesn't point to one + * of our pages, return default parameters. + * @param {string} path A path taken from the page URL. + * @return {Object} An object containining the following parameters: + * id - The 'id' of the page. + * path - A path into the page. Optional. + */ + function resolvePageInfoFromPath(path) { + var params = {}; + if (path.length > 1) { + // Split the path into id and the remaining path. + path = path.slice(1); + var index = path.indexOf('/'); + if (index != -1) { + params.id = path.slice(0, index); + params.path = path.slice(index + 1); + } else { + params.id = path; + } + // If the target sub-page does not exist, discard the params we + // generated. + var container = $(params.id); + if (!container) { + params.id = undefined; + params.path = undefined; + } + } + // If we don't have a valid page, get a default. + if (!params.id) + params.id = getDefaultIframe().id; + + return params; + } + + /** * Selects the page for |navItem|, or does nothing if that item has already * been selected. * @param {Object} navItem The navigation control li. @@ -52,7 +100,16 @@ cr.define('uber', function() { */ function onPopHistoryState(e) { if (e.state && e.state.pageId) - showPage(e.state.pageId); + showPage(e.state.pageId, HISTORY_STATE_OPTION.PUSH); + } + + /** + * @return {Object} The default iframe container. + */ + function getDefaultIframe() { + // TODO(csilv): This will select the first iframe as the default, but + // perhaps we want to use some other logic? + return document.querySelector('.iframe-container'); } /** @@ -85,7 +142,7 @@ cr.define('uber', function() { else if (e.data.method === 'setTitle') setTitle_(e.origin, e.data.params); else if (e.data.method === 'showPage') - showPage(e.data.params.pageId); + showPage(e.data.params.pageId, HISTORY_STATE_OPTION.PUSH); else if (e.data.method === 'navigationControlsLoaded') onNavigationControlsLoaded(); else @@ -130,18 +187,25 @@ cr.define('uber', function() { /** * Selects a subpage. This is called from uber-frame. * @param {String} pageId Should matche an id of one of the iframe containers. + * @param {integer} historyOption Indicates whether we should push or replace + * browser history. */ - function showPage(pageId) { + function showPage(pageId, historyOption) { var container = $(pageId); var lastSelected = document.querySelector('.iframe-container.selected'); if (lastSelected === container) return; - lastSelected.classList.remove('selected'); + if (lastSelected) + lastSelected.classList.remove('selected'); container.classList.add('selected'); document.title = container.title; - window.history.pushState({pageId: pageId}, '', '/' + pageId); + if (historyOption == HISTORY_STATE_OPTION.PUSH) + window.history.pushState({pageId: pageId}, '', '/' + pageId); + else if (historyOption == HISTORY_STATE_OPTION.REPLACE) + window.history.replaceState({pageId: pageId}, '', '/' + pageId); + updateNavigationControls(); } diff --git a/chrome/browser/resources/uber/uber_frame.html b/chrome/browser/resources/uber/uber_frame.html index afdedba..68a9cac 100644 --- a/chrome/browser/resources/uber/uber_frame.html +++ b/chrome/browser/resources/uber/uber_frame.html @@ -15,7 +15,7 @@ <h1 i18n-content="shortProductName"></h1> <ol> <li i18n-content="settingsDisplayName" - i18n-values="controls:settingsHost" class="selected"></li> + i18n-values="controls:settingsHost"></li> <li i18n-content="extensionsDisplayName" i18n-values="controls:extensionsHost"></li> <if expr="pp_ifdef('chromeos')"> diff --git a/chrome/browser/resources/uber/uber_frame.js b/chrome/browser/resources/uber/uber_frame.js index 05abf0e..37eb412 100644 --- a/chrome/browser/resources/uber/uber_frame.js +++ b/chrome/browser/resources/uber/uber_frame.js @@ -66,7 +66,8 @@ cr.define('uber_frame', function() { var lastSelectedNavItem = document.querySelector('li.selected'); if (lastSelectedNavItem !== newSelection) { newSelection.classList.add('selected'); - lastSelectedNavItem.classList.remove('selected'); + if (lastSelectedNavItem) + lastSelectedNavItem.classList.remove('selected'); } } diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 04ea7e9..97b9dd2 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -2230,7 +2230,15 @@ void Browser::ShowDownloadsTab() { void Browser::ShowExtensionsTab() { content::RecordAction(UserMetricsAction("ShowExtensions")); - ShowOptionsTab(chrome::kExtensionsSubPage); + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableUberPage)) { + ShowOptionsTab(chrome::kExtensionsSubPage); + } else { + browser::NavigateParams params(GetSingletonTabNavigateParams( + GURL(std::string(chrome::kChromeUIUberURL) + + chrome::kChromeUIExtensionsHost))); + params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; + ShowSingletonTabOverwritingNTP(params); + } } void Browser::ShowAboutConflictsTab() { @@ -2254,11 +2262,18 @@ void Browser::ShowBrokenPageTab(WebContents* contents) { } void Browser::ShowOptionsTab(const std::string& sub_page) { - browser::NavigateParams params(GetSingletonTabNavigateParams( - GURL(chrome::kChromeUISettingsURL + sub_page))); - params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; - - ShowSingletonTabOverwritingNTP(params); + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableUberPage)) { + browser::NavigateParams params(GetSingletonTabNavigateParams( + GURL(chrome::kChromeUISettingsURL + sub_page))); + params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; + ShowSingletonTabOverwritingNTP(params); + } else { + browser::NavigateParams params(GetSingletonTabNavigateParams( + GURL(std::string(chrome::kChromeUIUberURL) + + chrome::kChromeUISettingsHost + '/' + sub_page))); + params.path_behavior = browser::NavigateParams::IGNORE_AND_NAVIGATE; + ShowSingletonTabOverwritingNTP(params); + } } void Browser::OpenClearBrowsingDataDialog() { diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 5399dab..39e8c68 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -407,6 +407,9 @@ const char kDisableTLS1[] = "disable-tls1"; // disable translate with the preference. const char kDisableTranslate[] = "disable-translate"; +// Disable uber page command and URL redirection. +const char kDisableUberPage[] = "disable-uber-page"; + // Disables the backend service for web resources. const char kDisableWebResources[] = "disable-web-resources"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index a50073f..c925cda 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -119,6 +119,7 @@ extern const char kDisableSyncTypedUrls[]; extern const char kDisableTabCloseableStateWatcher[]; extern const char kDisableTLS1[]; extern const char kDisableTranslate[]; +extern const char kDisableUberPage[]; extern const char kDisableWebResources[]; extern const char kDisableWebSecurity[]; extern const char kDisableXSSAuditor[]; diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index e32ca7e..7d860d1 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -78,6 +78,7 @@ const char kChromeUISyncPromoURL[] = "chrome://syncpromo/"; const char kChromeUITaskManagerURL[] = "chrome://tasks/"; const char kChromeUITermsURL[] = "chrome://terms/"; const char kChromeUIThumbnailURL[] = "chrome://thumb/"; +const char kChromeUIUberURL[] = "chrome://chrome/"; const char kChromeUIUberFrameURL[] = "chrome://uber-frame/"; const char kChromeUIVersionURL[] = "chrome://version/"; const char kChromeUIWorkersURL[] = "chrome://workers/"; diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index ba5a610..f11abc0 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -69,6 +69,7 @@ extern const char kChromeUISyncPromoURL[]; extern const char kChromeUITaskManagerURL[]; extern const char kChromeUITermsURL[]; extern const char kChromeUIThumbnailURL[]; +extern const char kChromeUIUberURL[]; extern const char kChromeUIUberFrameURL[]; extern const char kChromeUIVersionURL[]; extern const char kChromeUIWorkersURL[]; diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc index 109869d..f5ef96f 100644 --- a/chrome/test/base/in_process_browser_test.cc +++ b/chrome/test/base/in_process_browser_test.cc @@ -172,6 +172,8 @@ void InProcessBrowserTest::PrepareTestCommandLine(CommandLine* command_line) { // If neccessary, disable TabCloseableStateWatcher. if (!tab_closeable_state_watcher_enabled_) command_line->AppendSwitch(switches::kDisableTabCloseableStateWatcher); + + command_line->AppendSwitch(switches::kDisableUberPage); } bool InProcessBrowserTest::CreateUserDataDirectory() { diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index d6fa88c..cf01364 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -208,6 +208,7 @@ void UITestBase::SetLaunchSwitches() { launch_arguments_.AppendSwitch(switches::kTestCompositor); } #endif + launch_arguments_.AppendSwitch(switches::kDisableUberPage); } void UITestBase::SetUpProfile() { |