Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2056)

Side by Side Diff: chrome/common/content_settings_pattern.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/content_settings_pattern.h" 5 #include "chrome/common/content_settings_pattern.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "chrome/common/content_settings_pattern_parser.h" 12 #include "chrome/common/content_settings_pattern_parser.h"
13 #include "chrome/common/render_messages.h" 13 #include "chrome/common/render_messages.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "extensions/common/constants.h" 15 #include "extensions/common/constants.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 #include "googleurl/src/url_canon.h" 17 #include "googleurl/src/url_canon.h"
18 #include "ipc/ipc_message_utils.h" 18 #include "ipc/ipc_message_utils.h"
19 #include "net/base/dns_util.h" 19 #include "net/base/dns_util.h"
20 #include "net/base/net_util.h" 20 #include "net/base/net_util.h"
21 21
22 namespace { 22 namespace {
23 23
24 std::string GetDefaultPort(const std::string& scheme) { 24 std::string GetDefaultPort(const std::string& scheme) {
25 if (scheme == chrome::kHttpScheme) 25 if (scheme == chrome::kHttpScheme)
26 return "80"; 26 return "80";
27 if (scheme == chrome::kHttpsScheme) 27 if (scheme == chrome::kHttpsScheme)
28 return "443"; 28 return "443";
29 return ""; 29 return std::string();
30 } 30 }
31 31
32 // Returns true if |sub_domain| is a sub domain or equls |domain|. E.g. 32 // Returns true if |sub_domain| is a sub domain or equls |domain|. E.g.
33 // "mail.google.com" is a sub domain of "google.com" but "evilhost.com" is not a 33 // "mail.google.com" is a sub domain of "google.com" but "evilhost.com" is not a
34 // subdomain of "host.com". 34 // subdomain of "host.com".
35 bool IsSubDomainOrEqual(const std::string& sub_domain, 35 bool IsSubDomainOrEqual(const std::string& sub_domain,
36 const std::string& domain) { 36 const std::string& domain) {
37 // The empty string serves as wildcard. Each domain is a subdomain of the 37 // The empty string serves as wildcard. Each domain is a subdomain of the
38 // wildcard. 38 // wildcard.
39 if (domain.empty()) 39 if (domain.empty())
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 } 494 }
495 495
496 bool ContentSettingsPattern::MatchesAllHosts() const { 496 bool ContentSettingsPattern::MatchesAllHosts() const {
497 return parts_.has_domain_wildcard && parts_.host.empty(); 497 return parts_.has_domain_wildcard && parts_.host.empty();
498 } 498 }
499 499
500 const std::string ContentSettingsPattern::ToString() const { 500 const std::string ContentSettingsPattern::ToString() const {
501 if (IsValid()) 501 if (IsValid())
502 return content_settings::PatternParser::ToString(parts_); 502 return content_settings::PatternParser::ToString(parts_);
503 else 503 else
504 return ""; 504 return std::string();
505 } 505 }
506 506
507 ContentSettingsPattern::Relation ContentSettingsPattern::Compare( 507 ContentSettingsPattern::Relation ContentSettingsPattern::Compare(
508 const ContentSettingsPattern& other) const { 508 const ContentSettingsPattern& other) const {
509 // Two invalid patterns are identical in the way they behave. They don't match 509 // Two invalid patterns are identical in the way they behave. They don't match
510 // anything and are represented as an empty string. So it's fair to treat them 510 // anything and are represented as an empty string. So it's fair to treat them
511 // as identical. 511 // as identical.
512 if ((this == &other) || 512 if ((this == &other) ||
513 (!is_valid_ && !other.is_valid_)) 513 (!is_valid_ && !other.is_valid_))
514 return IDENTITY; 514 return IDENTITY;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 if (!parts.is_port_wildcard && other_parts.is_port_wildcard) 674 if (!parts.is_port_wildcard && other_parts.is_port_wildcard)
675 return ContentSettingsPattern::PREDECESSOR; 675 return ContentSettingsPattern::PREDECESSOR;
676 676
677 int result = parts.port.compare(other_parts.port); 677 int result = parts.port.compare(other_parts.port);
678 if (result == 0) 678 if (result == 0)
679 return ContentSettingsPattern::IDENTITY; 679 return ContentSettingsPattern::IDENTITY;
680 if (result > 0) 680 if (result > 0)
681 return ContentSettingsPattern::DISJOINT_ORDER_PRE; 681 return ContentSettingsPattern::DISJOINT_ORDER_PRE;
682 return ContentSettingsPattern::DISJOINT_ORDER_POST; 682 return ContentSettingsPattern::DISJOINT_ORDER_POST;
683 } 683 }
OLDNEW
« no previous file with comments | « chrome/common/content_settings_helper.cc ('k') | chrome/common/content_settings_pattern_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698