Skip to content

Commit

Permalink
Cleanup: Use http/https constants in components.
Browse files Browse the repository at this point in the history
Review URL: https://codereview.chromium.org/726923004

Cr-Commit-Position: refs/heads/master@{#304851}
  • Loading branch information
leizleiz authored and Commit bot committed Nov 19, 2014
1 parent b6ed298 commit 65a3dc6
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 26 deletions.
4 changes: 1 addition & 3 deletions components/autofill/core/browser/autofill_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ bool SectionIsAutofilled(const FormStructure& form_structure,
}

bool FormIsHTTPS(const FormStructure& form) {
// TODO(blundell): Change this to use a constant once crbug.com/306258 is
// fixed.
return form.source_url().SchemeIs("https");
return form.source_url().SchemeIs(url::kHttpsScheme);
}

// Uses the existing personal data in |profiles| and |credit_cards| to determine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_http_job.h"
#include "net/url_request/url_request_job_factory.h"
#include "url/url_constants.h"

namespace data_reduction_proxy {

Expand Down Expand Up @@ -46,9 +47,9 @@ net::URLRequestJob* DataReductionProxyInterceptor::MaybeInterceptResponse(
return nullptr;
// Returning non-NULL has the effect of restarting the request with the
// supplied job.
DCHECK(request->url().SchemeIs("http"));
DCHECK(request->url().SchemeIs(url::kHttpScheme));
return request->context()->job_factory()->MaybeCreateJobWithProtocolHandler(
"http", request, network_delegate);
url::kHttpScheme, request, network_delegate);
}

} // namespace data_reduction_proxy
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "net/proxy/proxy_retry_info.h"
#include "net/proxy/proxy_service.h"
#include "net/url_request/url_request_context.h"
#include "url/url_constants.h"

namespace data_reduction_proxy {

Expand Down Expand Up @@ -292,9 +293,9 @@ class DailyDataSavingUpdate {

DataReductionProxyRequestType GetDataReductionProxyRequestType(
const net::URLRequest* request) {
if (request->url().SchemeIs("https"))
if (request->url().SchemeIs(url::kHttpsScheme))
return HTTPS;
if (!request->url().SchemeIs("http")) {
if (!request->url().SchemeIs(url::kHttpScheme)) {
NOTREACHED();
return UNKNOWN_TYPE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bool SetProxyServerFromGURL(const GURL& gurl,
DCHECK(proxy_server);
if (!gurl.SchemeIsHTTPOrHTTPS())
return false;
*proxy_server = net::ProxyServer(gurl.SchemeIs("http") ?
*proxy_server = net::ProxyServer(gurl.SchemeIs(url::kHttpScheme) ?
net::ProxyServer::SCHEME_HTTP :
net::ProxyServer::SCHEME_HTTPS,
net::HostPortPair::FromURL(gurl));
Expand Down Expand Up @@ -174,7 +174,7 @@ bool IsRequestIdempotent(const net::URLRequest* request) {

void MarkProxiesAsBadUntil(
net::URLRequest* request,
base::TimeDelta& bypass_duration,
const base::TimeDelta& bypass_duration,
bool bypass_all,
const std::pair<GURL, GURL>& data_reduction_proxies) {
DCHECK(!data_reduction_proxies.first.is_empty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void OverrideResponseAsRedirect(
// |data_reduction_proxies.second| to the retry list only if |bypass_all| is
// true. Visible as part of the public API for testing.
void MarkProxiesAsBadUntil(net::URLRequest* request,
base::TimeDelta& bypass_duration,
const base::TimeDelta& bypass_duration,
bool bypass_all,
const std::pair<GURL, GURL>& data_reduction_proxies);

Expand Down
3 changes: 2 additions & 1 deletion components/error_page/renderer/net_error_helper_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "third_party/WebKit/public/platform/WebURLError.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
#include "url/url_constants.h"

namespace error_page {

Expand Down Expand Up @@ -153,7 +154,7 @@ bool ShouldUseFixUrlServiceForError(const blink::WebURLError& error,
return false;

std::string domain = error.domain.utf8();
if (domain == "http" && error.reason == 404) {
if (domain == url::kHttpScheme && error.reason == 404) {
*error_param = "http404";
return true;
}
Expand Down
19 changes: 9 additions & 10 deletions components/navigation_metrics/navigation_metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ enum Scheme {
SCHEME_MAX,
};

static const char* kSchemeNames[] = {
const char* const kSchemeNames[] = {
"unknown",
"http",
"https",
"file",
"ftp",
"data",
"javascript",
"about",
url::kHttpScheme,
url::kHttpsScheme,
url::kFileScheme,
url::kFtpScheme,
url::kDataScheme,
url::kJavaScriptScheme,
url::kAboutScheme,
"chrome",
"max",
};
Expand All @@ -50,8 +50,7 @@ void RecordMainFrameNavigation(const GURL& url, bool is_in_page) {
break;
}
}
UMA_HISTOGRAM_ENUMERATION(
"Navigation.MainFrameScheme", scheme, SCHEME_MAX);
UMA_HISTOGRAM_ENUMERATION("Navigation.MainFrameScheme", scheme, SCHEME_MAX);
if (!is_in_page) {
UMA_HISTOGRAM_ENUMERATION(
"Navigation.MainFrameSchemeDifferentPage", scheme, SCHEME_MAX);
Expand Down
8 changes: 3 additions & 5 deletions components/translate/core/common/translate_metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "base/basictypes.h"
#include "base/metrics/histogram.h"
#include "url/url_constants.h"

namespace translate {

Expand All @@ -24,9 +25,6 @@ const char kTranslateUserActionDuration[] = "Translate.UserActionDuration";
const char kTranslatePageScheme[] = "Translate.PageScheme";
const char kTranslateSimilarLanguageMatch[] = "Translate.SimilarLanguageMatch";

const char kSchemeHttp[] = "http";
const char kSchemeHttps[] = "https";

struct MetricsEntry {
MetricsNameIndex index;
const char* const name;
Expand Down Expand Up @@ -106,9 +104,9 @@ void ReportUserActionDuration(base::TimeTicks begin, base::TimeTicks end) {

void ReportPageScheme(const std::string& scheme) {
SchemeType type = SCHEME_OTHERS;
if (scheme == kSchemeHttp)
if (scheme == url::kHttpScheme)
type = SCHEME_HTTP;
else if (scheme == kSchemeHttps)
else if (scheme == url::kHttpsScheme)
type = SCHEME_HTTPS;
UMA_HISTOGRAM_ENUMERATION(kTranslatePageScheme, type, SCHEME_MAX);
}
Expand Down

0 comments on commit 65a3dc6

Please sign in to comment.