diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 18:39:24 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 18:39:24 +0000 |
commit | 3f8cb62b2416b1365407eaaf935664509ebcef5c (patch) | |
tree | 4293fcd06e7de652e09967d7b9479135704886e9 /chrome | |
parent | 8793b4d15e6af6b41cc5a3f819c219cfb65b1e73 (diff) | |
download | chromium_src-3f8cb62b2416b1365407eaaf935664509ebcef5c.zip chromium_src-3f8cb62b2416b1365407eaaf935664509ebcef5c.tar.gz chromium_src-3f8cb62b2416b1365407eaaf935664509ebcef5c.tar.bz2 |
More URL constants replacement.
Review URL: http://codereview.chromium.org/28170
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10487 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser.cc | 3 | ||||
-rw-r--r-- | chrome/browser/browser_about_handler.cc | 6 | ||||
-rw-r--r-- | chrome/browser/crash_recovery_uitest.cc | 5 | ||||
-rw-r--r-- | chrome/browser/history/history.cc | 3 | ||||
-rw-r--r-- | chrome/browser/history/url_database.cc | 3 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_unittest.cc | 5 | ||||
-rw-r--r-- | chrome/browser/renderer_host/renderer_security_policy_unittest.cc | 24 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/site_instance_unittest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/tab_contents/navigation_controller.cc | 3 | ||||
-rw-r--r-- | chrome/browser/tab_contents/site_instance.cc | 12 | ||||
-rw-r--r-- | chrome/browser/task_manager.cc | 3 | ||||
-rw-r--r-- | chrome/browser/toolbar_model.cc | 4 | ||||
-rw-r--r-- | chrome/common/url_constants.cc | 5 | ||||
-rw-r--r-- | chrome/common/url_constants.h | 5 | ||||
-rw-r--r-- | chrome/renderer/about_handler.cc | 11 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 2 | ||||
-rw-r--r-- | chrome/test/automated_ui_tests/automated_ui_tests.cc | 3 |
18 files changed, 62 insertions, 44 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 311d500..6b9fe7d 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -34,6 +34,7 @@ #include "chrome/common/page_transition_types.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" +#include "chrome/common/url_constants.h" #ifdef CHROME_PERSONALIZATION #include "chrome/personalization/personalization.h" #endif @@ -2281,7 +2282,7 @@ NavigationController* Browser::BuildRestoredNavigationController( } else { // No navigations. Create a tab with about:blank. TabContents* contents = - CreateTabContentsForURL(GURL("about:blank"), GURL(), profile_, + CreateTabContentsForURL(GURL(chrome::kAboutBlankURL), GURL(), profile_, PageTransition::START_PAGE, false, NULL); return new NavigationController(contents, profile_); } diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 7f25a60..0d83902 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -169,7 +169,7 @@ bool BrowserAboutHandler::MaybeHandle(GURL* url, // about:blank is special. Frames are allowed to access about:blank, // but they are not allowed to access other types of about pages. // Just ignore the about:blank and let the TAB_CONTENTS_WEB handle it. - if (StringToLowerASCII(url->path()) == "blank") { + if (LowerCaseEqualsASCII(url->spec(), chrome::kAboutBlankURL)) { return false; } @@ -192,7 +192,7 @@ bool BrowserAboutHandler::MaybeHandle(GURL* url, // Navigate the renderer to about:blank. This is kind of stupid but is the // easiest thing to do in this situation without adding a lot of complexity // for this developer-only feature. - *url = GURL("about:blank"); + *url = GURL(chrome::kAboutBlankURL); return false; } @@ -205,7 +205,7 @@ bool BrowserAboutHandler::MaybeHandle(GURL* url, NOTIMPLEMENTED(); // TODO(port) Implement this. #endif - *url = GURL("about:blank"); + *url = GURL(chrome::kAboutBlankURL); return false; } #endif diff --git a/chrome/browser/crash_recovery_uitest.cc b/chrome/browser/crash_recovery_uitest.cc index d094124..0355ec0 100644 --- a/chrome/browser/crash_recovery_uitest.cc +++ b/chrome/browser/crash_recovery_uitest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/file_util.h" +#include "chrome/common/url_constants.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/ui/ui_test.h" @@ -30,7 +31,7 @@ TEST_F(CrashRecoveryUITest, Reload) { // Cause the renderer to crash. expected_crashes_ = 1; - tab->NavigateToURLAsync(GURL("about:crash")); + tab->NavigateToURLAsync(GURL(chrome::kAboutCrashURL)); Sleep(1000); // Wait for the browser to notice the renderer crash. @@ -63,7 +64,7 @@ TEST_F(CrashRecoveryUITest, LoadInNewTab) { // Cause the renderer to crash. expected_crashes_ = 1; - tab->NavigateToURLAsync(GURL("about:crash")); + tab->NavigateToURLAsync(GURL(chrome::kAboutCrashURL)); Sleep(1000); // Wait for the browser to notice the renderer crash. diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc index 49707cf..ced7b64 100644 --- a/chrome/browser/history/history.cc +++ b/chrome/browser/history/history.cc @@ -578,8 +578,7 @@ bool HistoryService::CanAddURL(const GURL& url) const { return false; if (url.SchemeIs(chrome::kAboutScheme)) { - std::string path = url.path(); - if (path.empty() || LowerCaseEqualsASCII(path, "blank")) + if (LowerCaseEqualsASCII(url.spec(), chrome::kAboutBlankURL)) return false; // We allow all other about URLs since the user may like to see things // like "about:memory" or "about:histograms" in their history and diff --git a/chrome/browser/history/url_database.cc b/chrome/browser/history/url_database.cc index 6db3b10..5bef3f5 100644 --- a/chrome/browser/history/url_database.cc +++ b/chrome/browser/history/url_database.cc @@ -10,6 +10,7 @@ #include "base/string_util.h" #include "chrome/common/l10n_util.h" #include "chrome/common/sqlite_utils.h" +#include "chrome/common/url_constants.h" #include "googleurl/src/gurl.h" using base::Time; @@ -408,7 +409,7 @@ void URLDatabase::GetMostRecentKeywordSearchTerms( bool URLDatabase::MigrateFromVersion11ToVersion12() { URLRow about_row; - if (GetRowForURL(GURL("about:blank"), &about_row)) { + if (GetRowForURL(GURL(chrome::kAboutBlankURL), &about_row)) { about_row.set_favicon_id(0); return UpdateURLRow(about_row.id(), about_row); } diff --git a/chrome/browser/renderer_host/render_view_host_unittest.cc b/chrome/browser/renderer_host/render_view_host_unittest.cc index 0ae9e46..22ee2ab 100644 --- a/chrome/browser/renderer_host/render_view_host_unittest.cc +++ b/chrome/browser/renderer_host/render_view_host_unittest.cc @@ -4,6 +4,7 @@ #include "chrome/browser/renderer_host/test_render_view_host.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
+#include "chrome/common/url_constants.h"
namespace {
@@ -15,7 +16,7 @@ class RenderViewHostTest : public RenderViewHostTestHarness { // All about URLs reported by the renderer should get rewritten to about:blank.
// See RenderViewHost::OnMsgNavigate for a discussion.
TEST_F(RenderViewHostTest, FilterAbout) {
- rvh()->SendNavigate(1, GURL("about:cache"));
+ rvh()->SendNavigate(1, GURL(chrome::kAboutCacheURL));
ASSERT_TRUE(controller_->GetActiveEntry());
- EXPECT_EQ(GURL("about:blank"), controller_->GetActiveEntry()->url());
+ EXPECT_EQ(GURL(chrome::kAboutBlankURL), controller_->GetActiveEntry()->url());
}
diff --git a/chrome/browser/renderer_host/renderer_security_policy_unittest.cc b/chrome/browser/renderer_host/renderer_security_policy_unittest.cc index c9faaea..d237b7e 100644 --- a/chrome/browser/renderer_host/renderer_security_policy_unittest.cc +++ b/chrome/browser/renderer_host/renderer_security_policy_unittest.cc @@ -87,26 +87,26 @@ TEST_F(RendererSecurityPolicyTest, AboutTest) { EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("aBouT:BlAnK"))); EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("aBouT:blank"))); - EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:memory"))); - EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:crash"))); - EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:cache"))); - EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:hang"))); + EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kAboutMemoryURL))); + EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kAboutCrashURL))); + EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kAboutCacheURL))); + EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kAboutHangURL))); EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("aBoUt:memory"))); EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:CrASh"))); EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("abOuT:cAChe"))); - p->GrantRequestURL(kRendererID, GURL("about:memory")); - EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:memory"))); + p->GrantRequestURL(kRendererID, GURL(chrome::kAboutMemoryURL)); + EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kAboutMemoryURL))); - p->GrantRequestURL(kRendererID, GURL("about:crash")); - EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:crash"))); + p->GrantRequestURL(kRendererID, GURL(chrome::kAboutCrashURL)); + EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kAboutCrashURL))); - p->GrantRequestURL(kRendererID, GURL("about:cache")); - EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:cache"))); + p->GrantRequestURL(kRendererID, GURL(chrome::kAboutCacheURL)); + EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kAboutCacheURL))); - p->GrantRequestURL(kRendererID, GURL("about:hang")); - EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:hang"))); + p->GrantRequestURL(kRendererID, GURL(chrome::kAboutHangURL)); + EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL(chrome::kAboutHangURL))); p->Remove(kRendererID); } diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc index 5d3a6b8..61fa1b4 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc @@ -12,6 +12,7 @@ #include "chrome/browser/automation/url_request_failed_dns_job.h" #include "chrome/browser/automation/url_request_mock_http_job.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/url_constants.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/ui/ui_test.h" @@ -189,7 +190,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteAfterCrash) { // Cause the renderer to crash. expected_crashes_ = 1; - tab->NavigateToURLAsync(GURL("about:crash")); + tab->NavigateToURLAsync(GURL(chrome::kAboutCrashURL)); Sleep(sleep_timeout_ms()); // Wait for browser to notice the renderer crash. // Navigate to a new cross-site page. The browser should not wait around for diff --git a/chrome/browser/site_instance_unittest.cc b/chrome/browser/site_instance_unittest.cc index 71fa4d9..85fa7d5 100644 --- a/chrome/browser/site_instance_unittest.cc +++ b/chrome/browser/site_instance_unittest.cc @@ -241,9 +241,9 @@ TEST_F(SiteInstanceTest, IsSameWebSite) { GURL url_foo_https = GURL("https://foo/a.html"); GURL url_foo_port = GURL("http://foo:8080/a.html"); GURL url_javascript = GURL("javascript:alert(1);"); - GURL url_crash = GURL("about:crash"); - GURL url_hang = GURL("about:hang"); - GURL url_shorthang = GURL("about:shorthang"); + GURL url_crash = GURL(chrome::kAboutCrashURL); + GURL url_hang = GURL(chrome::kAboutHangURL); + GURL url_shorthang = GURL(chrome::kAboutShortHangURL); // Same scheme and port -> same site. EXPECT_TRUE(SiteInstance::IsSameWebSite(url_foo, url_foo2)); diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc index def6c34..adf9568 100644 --- a/chrome/browser/tab_contents/navigation_controller.cc +++ b/chrome/browser/tab_contents/navigation_controller.cc @@ -386,7 +386,8 @@ void NavigationController::RemoveEntryAtIndex(int index, NavigateToPendingEntry(false); } else { // If there is nothing to show, show a default page. - LoadURL(default_url.is_empty() ? GURL("about:blank") : default_url, + LoadURL(default_url.is_empty() ? GURL(chrome::kAboutBlankURL) : + default_url, GURL(), PageTransition::START_PAGE); } } else if (last_committed_entry_index_ > index) { diff --git a/chrome/browser/tab_contents/site_instance.cc b/chrome/browser/tab_contents/site_instance.cc index a2a051f..6b6f65f 100644 --- a/chrome/browser/tab_contents/site_instance.cc +++ b/chrome/browser/tab_contents/site_instance.cc @@ -131,12 +131,12 @@ bool SiteInstance::IsSameWebSite(const GURL& url1, const GURL& url2) { // We treat about:crash, about:hang, and about:shorthang as the same site as // any URL, since they are used as demos for crashing/hanging a process. - GURL about_crash = GURL("about:crash"); - GURL about_hang = GURL("about:hang"); - GURL about_shorthang = GURL("about:shorthang"); - if (url1 == about_crash || url2 == about_crash || - url1 == about_hang || url2 == about_hang || - url1 == about_shorthang || url2 == about_shorthang) + if (url1.spec() == chrome::kAboutCrashURL || + url2.spec() == chrome::kAboutCrashURL || + url1.spec() == chrome::kAboutHangURL || + url2.spec() == chrome::kAboutHangURL || + url1.spec() == chrome::kAboutShortHangURL || + url2.spec() == chrome::kAboutShortHangURL) return true; // If either URL is invalid, they aren't part of the same site. diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc index ae17dbe..ba2dafa 100644 --- a/chrome/browser/task_manager.cc +++ b/chrome/browser/task_manager.cc @@ -18,6 +18,7 @@ #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/common/resource_bundle.h" +#include "chrome/common/url_constants.h" #include "chrome/views/accelerator.h" #include "chrome/views/background.h" #include "chrome/views/link.h" @@ -919,7 +920,7 @@ void TaskManagerContents::LinkActivated(views::Link* source, DCHECK(source == about_memory_link_); Browser* browser = BrowserList::GetLastActive(); DCHECK(browser); - browser->OpenURL(GURL("about:memory"), GURL(), NEW_FOREGROUND_TAB, + browser->OpenURL(GURL(chrome::kAboutMemoryURL), GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); } diff --git a/chrome/browser/toolbar_model.cc b/chrome/browser/toolbar_model.cc index 08dc00b..14b99e1 100644 --- a/chrome/browser/toolbar_model.cc +++ b/chrome/browser/toolbar_model.cc @@ -12,6 +12,7 @@ #include "chrome/common/l10n_util.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" +#include "chrome/common/url_constants.h" #include "grit/generated_resources.h" #include "net/base/net_util.h" @@ -30,8 +31,7 @@ ToolbarModel::~ToolbarModel() { // ToolbarModel Implementation. std::wstring ToolbarModel::GetText() { - static const GURL kAboutBlankURL("about:blank"); - GURL url(kAboutBlankURL); + GURL url(chrome::kAboutBlankURL); std::wstring languages; // Empty if we don't have a |navigation_controller|. NavigationController* navigation_controller = GetNavigationController(); diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index fad79f3..52c8605 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -23,5 +23,10 @@ const char kViewSourceScheme[] = "view-source"; const char kStandardSchemeSeparator[] = "://";
const char kAboutBlankURL[] = "about:blank";
+const char kAboutCacheURL[] = "about:cache";
+const char kAboutCrashURL[] = "about:crash";
+const char kAboutHangURL[] = "about:hang";
+const char kAboutMemoryURL[] = "about:memory";
+const char kAboutShortHangURL[] = "about:shorthang";
} // namespace chrome
diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index 1cbf97b..d7cc15e 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -29,6 +29,11 @@ extern const char kStandardSchemeSeparator[]; // About URLs (including schmes).
extern const char kAboutBlankURL[];
+extern const char kAboutCacheURL[];
+extern const char kAboutCrashURL[];
+extern const char kAboutHangURL[];
+extern const char kAboutMemoryURL[];
+extern const char kAboutShortHangURL[];
} // namespace chrome
diff --git a/chrome/renderer/about_handler.cc b/chrome/renderer/about_handler.cc index ff26d85..d0fb504 100644 --- a/chrome/renderer/about_handler.cc +++ b/chrome/renderer/about_handler.cc @@ -5,6 +5,7 @@ #include "chrome/renderer/about_handler.h" #include "base/platform_thread.h" +#include "chrome/common/url_constants.h" #include "googleurl/src/gurl.h" struct AboutHandlerUrl { @@ -13,14 +14,14 @@ struct AboutHandlerUrl { }; static AboutHandlerUrl about_urls[] = { - { "about:crash", AboutHandler::AboutCrash }, - { "about:hang", AboutHandler::AboutHang }, - { "about:shorthang", AboutHandler::AboutShortHang }, + { chrome::kAboutCrashURL, AboutHandler::AboutCrash }, + { chrome::kAboutHangURL, AboutHandler::AboutHang }, + { chrome::kAboutShortHangURL, AboutHandler::AboutShortHang }, { NULL, NULL } }; bool AboutHandler::WillHandle(const GURL& url) { - if (url.scheme() != "about") + if (url.SchemeIs(chrome::kAboutScheme)) return false; struct AboutHandlerUrl* url_handler = about_urls; @@ -34,7 +35,7 @@ bool AboutHandler::WillHandle(const GURL& url) { // static bool AboutHandler::MaybeHandle(const GURL& url) { - if (url.scheme() != "about") + if (!url.SchemeIs(chrome::kAboutScheme)) return false; struct AboutHandlerUrl* url_handler = about_urls; diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 91efbf4..a4351fb 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -1607,7 +1607,7 @@ WindowOpenDisposition RenderView::DispositionForNavigationAction( // JavaScript. bool is_fork = // Must start from a tab showing about:blank, which is later redirected. - frame->GetURL() == GURL("about:blank") && + frame->GetURL() == GURL(chrome::kAboutBlankURL) && // Must be the first real navigation of the tab. GetHistoryBackListCount() < 1 && GetHistoryForwardListCount() < 1 && diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.cc b/chrome/test/automated_ui_tests/automated_ui_tests.cc index d87d521..9baa7e2 100644 --- a/chrome/test/automated_ui_tests/automated_ui_tests.cc +++ b/chrome/test/automated_ui_tests/automated_ui_tests.cc @@ -18,6 +18,7 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/env_vars.h" #include "chrome/common/libxml_utils.h" +#include "chrome/common/url_constants.h" #include "chrome/common/win_util.h" #include "chrome/test/automated_ui_tests/automated_ui_tests.h" #include "chrome/test/automation/browser_proxy.h" @@ -738,7 +739,7 @@ bool AutomatedUITest::ForceCrash() { return false; } scoped_ptr<TabProxy> tab(browser->GetActiveTab()); - GURL test_url("about:crash"); + GURL test_url(chrome::kAboutCrashURL); bool did_timeout; tab->NavigateToURLWithTimeout(test_url, kDebuggingTimeoutMsec, &did_timeout); if (!did_timeout) { |