Commit 3f8cb62b authored by brettw@chromium.org's avatar brettw@chromium.org

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
parent 8793b4d1
......@@ -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_);
}
......
......@@ -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
......
......@@ -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.
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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());
}
......@@ -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);
}
......
......@@ -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
......
......@@ -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));
......
......@@ -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) {
......
......@@ -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.
......
......@@ -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);
}
......
......@@ -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();
......
......@@ -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
......@@ -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
......
......@@ -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;
......
......@@ -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 &&
......
......@@ -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) {
......
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