Commit 692c534e authored by msw@chromium.org's avatar msw@chromium.org

Normalize chrome://foo/ trailing slashes (add a few).

Add web_ui_util::ChromeURLHostEquals and update some checks.
RIP kChromeUIAppLauncherURL (arv:r46266 - tfarina:r62866).
RIP kDefaultOptionsSubPage (zelidrag:r56816 - estade:r76329/r76490).
Remove unnecessary stdlib.h include and some extra spaces.

BUG=55771
TEST=None

Review URL: http://codereview.chromium.org/7049004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86673 0039d316-1c4b-4281-b951-d872f2087c98
parent e2776455
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/webui/web_ui_util.h"
#include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_icon_set.h" #include "chrome/common/extensions/extension_icon_set.h"
#include "chrome/common/extensions/extension_resource.h" #include "chrome/common/extensions/extension_resource.h"
...@@ -69,9 +70,8 @@ void ShowAppInstalledAnimation(Browser* browser, const std::string& app_id) { ...@@ -69,9 +70,8 @@ void ShowAppInstalledAnimation(Browser* browser, const std::string& app_id) {
// Select an already open NTP, if there is one. Existing NTPs will // Select an already open NTP, if there is one. Existing NTPs will
// automatically show the install animation for any new apps. // automatically show the install animation for any new apps.
for (int i = 0; i < browser->tab_count(); ++i) { for (int i = 0; i < browser->tab_count(); ++i) {
TabContents* tab_contents = browser->GetTabContentsAt(i); GURL url = browser->GetTabContentsAt(i)->GetURL();
GURL url = tab_contents->GetURL(); if (web_ui_util::ChromeURLHostEquals(url, chrome::kChromeUINewTabHost)) {
if (StartsWithASCII(url.spec(), chrome::kChromeUINewTabURL, false)) {
browser->ActivateTabAt(i, false); browser->ActivateTabAt(i, false);
return; return;
} }
...@@ -79,7 +79,7 @@ void ShowAppInstalledAnimation(Browser* browser, const std::string& app_id) { ...@@ -79,7 +79,7 @@ void ShowAppInstalledAnimation(Browser* browser, const std::string& app_id) {
// If there isn't an NTP, open one and pass it the ID of the installed app. // If there isn't an NTP, open one and pass it the ID of the installed app.
std::string url = base::StringPrintf( std::string url = base::StringPrintf(
"%s/#app-id=%s", chrome::kChromeUINewTabURL, app_id.c_str()); "%s#app-id=%s", chrome::kChromeUINewTabURL, app_id.c_str());
browser->AddSelectedTabWithURL(GURL(url), PageTransition::TYPED); browser->AddSelectedTabWithURL(GURL(url), PageTransition::TYPED);
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "chrome/browser/tabs/tab_strip_model_delegate.h" #include "chrome/browser/tabs/tab_strip_model_delegate.h"
#include "chrome/browser/tabs/tab_strip_model_order_controller.h" #include "chrome/browser/tabs/tab_strip_model_order_controller.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/webui/web_ui_util.h"
#include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "content/browser/renderer_host/render_process_host.h" #include "content/browser/renderer_host/render_process_host.h"
...@@ -1102,8 +1103,8 @@ std::vector<int> TabStripModel::GetIndicesForCommand(int index) const { ...@@ -1102,8 +1103,8 @@ std::vector<int> TabStripModel::GetIndicesForCommand(int index) const {
bool TabStripModel::IsNewTabAtEndOfTabStrip( bool TabStripModel::IsNewTabAtEndOfTabStrip(
TabContentsWrapper* contents) const { TabContentsWrapper* contents) const {
return LowerCaseEqualsASCII(contents->tab_contents()->GetURL().spec(), const GURL& url = contents->tab_contents()->GetURL();
chrome::kChromeUINewTabURL) && return web_ui_util::ChromeURLHostEquals(url, chrome::kChromeUINewTabHost) &&
contents == GetContentsAt(count() - 1) && contents == GetContentsAt(count() - 1) &&
contents->controller().entry_count() == 1; contents->controller().entry_count() == 1;
} }
......
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
#include "chrome/browser/ui/webui/active_downloads_ui.h" #include "chrome/browser/ui/webui/active_downloads_ui.h"
#include "chrome/browser/ui/webui/bug_report_ui.h" #include "chrome/browser/ui/webui/bug_report_ui.h"
#include "chrome/browser/ui/webui/options/content_settings_handler.h" #include "chrome/browser/ui/webui/options/content_settings_handler.h"
#include "chrome/browser/ui/webui/web_ui_util.h"
#include "chrome/browser/ui/window_sizer.h" #include "chrome/browser/ui/window_sizer.h"
#include "chrome/browser/upgrade_detector.h" #include "chrome/browser/upgrade_detector.h"
#include "chrome/browser/web_applications/web_app.h" #include "chrome/browser/web_applications/web_app.h"
...@@ -1600,8 +1601,8 @@ void Browser::ToggleFullscreenMode() { ...@@ -1600,8 +1601,8 @@ void Browser::ToggleFullscreenMode() {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
void Browser::Search() { void Browser::Search() {
// If the NTP is showing, close it. // If the NTP is showing, close it.
if (StartsWithASCII(GetSelectedTabContents()->GetURL().spec(), const GURL& url = GetSelectedTabContents()->GetURL();
chrome::kChromeUINewTabURL, true)) { if (web_ui_util::ChromeURLHostEquals(url, chrome::kChromeUINewTabHost)) {
CloseTab(); CloseTab();
return; return;
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h"
#include "chrome/browser/ui/gtk/view_id_util.h" #include "chrome/browser/ui/gtk/view_id_util.h"
#include "chrome/browser/ui/toolbar/encoding_menu_controller.h" #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
#include "chrome/browser/ui/webui/web_ui_util.h"
#include "chrome/browser/upgrade_detector.h" #include "chrome/browser/upgrade_detector.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
...@@ -606,7 +607,8 @@ void BrowserToolbarGtk::OnDragDataReceived(GtkWidget* widget, ...@@ -606,7 +607,8 @@ void BrowserToolbarGtk::OnDragDataReceived(GtkWidget* widget,
if (!url.is_valid()) if (!url.is_valid())
return; return;
bool url_is_newtab = url.spec() == chrome::kChromeUINewTabURL; bool url_is_newtab =
web_ui_util::ChromeURLHostEquals(url, chrome::kChromeUINewTabHost);
home_page_is_new_tab_page_.SetValue(url_is_newtab); home_page_is_new_tab_page_.SetValue(url_is_newtab);
if (!url_is_newtab) if (!url_is_newtab)
home_page_.SetValue(url.spec()); home_page_.SetValue(url.spec());
......
...@@ -71,10 +71,6 @@ IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, TestAboutPageLTR) {\ ...@@ -71,10 +71,6 @@ IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, TestAboutPageLTR) {\
RunBidiCheckerOnPage(chrome::kChromeUIAboutURL, false);\ RunBidiCheckerOnPage(chrome::kChromeUIAboutURL, false);\
} }
IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, TestAppLauncherPageLTR) {\
RunBidiCheckerOnPage(chrome::kChromeUIAppLauncherURL, false);\
}
// Times out. http://code.google.com/p/chromium/issues/detail?id=82896 // Times out. http://code.google.com/p/chromium/issues/detail?id=82896
IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest, IN_PROC_BROWSER_TEST_F(WebUIBidiCheckerBrowserTest,
DISABLED_TestBookmarksPageLTR) {\ DISABLED_TestBookmarksPageLTR) {\
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
#include <vector> #include <vector>
#include "base/base64.h" #include "base/base64.h"
#include "base/string_util.h"
#include "chrome/common/url_constants.h"
#include "googleurl/src/gurl.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/codec/png_codec.h" #include "ui/gfx/codec/png_codec.h"
...@@ -39,4 +42,10 @@ std::string GetImageDataUrlFromResource(int res) { ...@@ -39,4 +42,10 @@ std::string GetImageDataUrlFromResource(int res) {
return str_url; return str_url;
} }
bool ChromeURLHostEquals(const GURL& url, const char* host) {
return (url.SchemeIs(chrome::kChromeUIScheme) ||
url.SchemeIs(chrome::kAboutScheme)) &&
LowerCaseEqualsASCII(url.host(), host);
}
} // namespace web_ui_util } // namespace web_ui_util
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <string> #include <string>
class GURL;
class SkBitmap; class SkBitmap;
namespace web_ui_util { namespace web_ui_util {
...@@ -24,6 +25,10 @@ std::string GetImageDataUrl(const SkBitmap& bitmap); ...@@ -24,6 +25,10 @@ std::string GetImageDataUrl(const SkBitmap& bitmap);
// |resource_id|. // |resource_id|.
std::string GetImageDataUrlFromResource(int resource_id); std::string GetImageDataUrlFromResource(int resource_id);
// Returns true if |url| has a chrome: or about: scheme and matching |host|.
// The url may contain a path under the host.
bool ChromeURLHostEquals(const GURL& url, const char* host);
} // namespace web_ui_util } // namespace web_ui_util
#endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_UTIL_H_ #endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_UTIL_H_
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <stdlib.h>
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "googleurl/src/url_util.h" #include "googleurl/src/url_util.h"
namespace chrome { namespace chrome {
...@@ -51,10 +50,9 @@ const char kAboutVersionURL[] = "about:version"; ...@@ -51,10 +50,9 @@ const char kAboutVersionURL[] = "about:version";
// to be used for testing. // to be used for testing.
const char kAboutBrowserCrash[] = "about:inducebrowsercrashforrealz"; const char kAboutBrowserCrash[] = "about:inducebrowsercrashforrealz";
const char kChromeUIAboutAboutURL[] = "chrome://about/about"; const char kChromeUIAboutAboutURL[] = "chrome://about/about/";
const char kChromeUIAboutCreditsURL[] = "chrome://about/credits"; const char kChromeUIAboutCreditsURL[] = "chrome://about/credits/";
const char kChromeUIAboutURL[] = "chrome://settings/about"; const char kChromeUIAboutURL[] = "chrome://settings/about/";
const char kChromeUIAppLauncherURL[] = "chrome://newtab/#mode=app-launcher";
const char kChromeUIBookmarksURL[] = "chrome://bookmarks/"; const char kChromeUIBookmarksURL[] = "chrome://bookmarks/";
const char kChromeUIBugReportURL[] = "chrome://bugreport/"; const char kChromeUIBugReportURL[] = "chrome://bugreport/";
const char kChromeUIConflictsURL[] = "chrome://conflicts/"; const char kChromeUIConflictsURL[] = "chrome://conflicts/";
...@@ -68,16 +66,16 @@ const char kChromeUIFaviconURL[] = "chrome://favicon/"; ...@@ -68,16 +66,16 @@ const char kChromeUIFaviconURL[] = "chrome://favicon/";
const char kChromeUIFlagsURL[] = "chrome://flags/"; const char kChromeUIFlagsURL[] = "chrome://flags/";
const char kChromeUIHistory2URL[] = "chrome://history2/"; const char kChromeUIHistory2URL[] = "chrome://history2/";
const char kChromeUIHistoryURL[] = "chrome://history/"; const char kChromeUIHistoryURL[] = "chrome://history/";
const char kChromeUIIPCURL[] = "chrome://about/ipc"; const char kChromeUIIPCURL[] = "chrome://about/ipc/";
const char kChromeUIKeyboardURL[] = "chrome://keyboard/"; const char kChromeUIKeyboardURL[] = "chrome://keyboard/";
const char kChromeUINewTabURL[] = "chrome://newtab"; const char kChromeUINewTabURL[] = "chrome://newtab/";
const char kChromeUIPluginsURL[] = "chrome://plugins/"; const char kChromeUIPluginsURL[] = "chrome://plugins/";
const char kChromeUIPrintURL[] = "chrome://print/"; const char kChromeUIPrintURL[] = "chrome://print/";
const char kChromeUISettingsURL[] = "chrome://settings/"; const char kChromeUISettingsURL[] = "chrome://settings/";
const char kChromeUITextfieldsURL[] = "chrome://textfields/"; const char kChromeUITextfieldsURL[] = "chrome://textfields/";
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
const char kChromeUIAboutOSCreditsURL[] = "chrome://about/os-credits"; const char kChromeUIAboutOSCreditsURL[] = "chrome://about/os-credits/";
const char kChromeUIActivationMessage[] = "chrome://activationmessage/"; const char kChromeUIActivationMessage[] = "chrome://activationmessage/";
const char kChromeUIActiveDownloadsURL[] = "chrome://active-downloads/"; const char kChromeUIActiveDownloadsURL[] = "chrome://active-downloads/";
const char kChromeUIChooseMobileNetworkURL[] = const char kChromeUIChooseMobileNetworkURL[] =
...@@ -174,18 +172,17 @@ const char kSyncGoogleDashboardURL[] = "https://www.google.com/dashboard/"; ...@@ -174,18 +172,17 @@ const char kSyncGoogleDashboardURL[] = "https://www.google.com/dashboard/";
const char kGpuInternalsURL[] = "chrome://gpu-internals/"; const char kGpuInternalsURL[] = "chrome://gpu-internals/";
// Option sub pages. // Option sub pages.
const char kAdvancedOptionsSubPage[] = "advanced"; const char kAdvancedOptionsSubPage[] = "advanced";
const char kAutofillSubPage[] = "autofill"; const char kAutofillSubPage[] = "autofill";
const char kBrowserOptionsSubPage[] = "browser"; const char kBrowserOptionsSubPage[] = "browser";
const char kClearBrowserDataSubPage[] = "clearBrowserData"; const char kClearBrowserDataSubPage[] = "clearBrowserData";
const char kContentSettingsSubPage[] = "content"; const char kContentSettingsSubPage[] = "content";
const char kContentSettingsExceptionsSubPage[] = "contentExceptions"; const char kContentSettingsExceptionsSubPage[] = "contentExceptions";
const char kDefaultOptionsSubPage[] = "";
const char kImportDataSubPage[] = "importData"; const char kImportDataSubPage[] = "importData";
const char kInstantConfirmPage[] = "instantConfirm"; const char kInstantConfirmPage[] = "instantConfirm";
const char kLanguageOptionsSubPage[] = "languages"; const char kLanguageOptionsSubPage[] = "languages";
const char kPersonalOptionsSubPage[] = "personal"; const char kPersonalOptionsSubPage[] = "personal";
const char kPasswordManagerSubPage[] = "passwords"; const char kPasswordManagerSubPage[] = "passwords";
const char kSearchEnginesSubPage[] = "searchEngines"; const char kSearchEnginesSubPage[] = "searchEngines";
const char kSyncSetupSubPage[] = "syncSetup"; const char kSyncSetupSubPage[] = "syncSetup";
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
...@@ -45,7 +45,6 @@ extern const char kAboutVersionURL[]; ...@@ -45,7 +45,6 @@ extern const char kAboutVersionURL[];
extern const char kChromeUIAboutAboutURL[]; extern const char kChromeUIAboutAboutURL[];
extern const char kChromeUIAboutCreditsURL[]; extern const char kChromeUIAboutCreditsURL[];
extern const char kChromeUIAboutURL[]; extern const char kChromeUIAboutURL[];
extern const char kChromeUIAppLauncherURL[];
extern const char kChromeUIBookmarksURL[]; extern const char kChromeUIBookmarksURL[];
extern const char kChromeUIBugReportURL[]; extern const char kChromeUIBugReportURL[];
extern const char kChromeUIConflictsURL[]; extern const char kChromeUIConflictsURL[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment