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

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

Issue 8356010: Merge 106270 - Check for default content settings when requiring user authorization for plug-ins. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/912/src
Patch Set: fix Created 9 years, 2 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
« no previous file with comments | « chrome/common/content_settings_pattern.h ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_split.h" 10 #include "base/string_split.h"
11 #include "base/string_util.h" 11 #include "base/string_util.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/url_constants.h" 14 #include "chrome/common/url_constants.h"
14 #include "net/base/dns_util.h" 15 #include "net/base/dns_util.h"
15 #include "net/base/net_util.h" 16 #include "net/base/net_util.h"
16 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
17 #include "googleurl/src/url_canon.h" 18 #include "googleurl/src/url_canon.h"
19 #include "ipc/ipc_message_utils.h"
18 20
19 namespace { 21 namespace {
20 22
21 std::string GetDefaultPort(const std::string& scheme) { 23 std::string GetDefaultPort(const std::string& scheme) {
22 if (scheme == chrome::kHttpScheme) 24 if (scheme == chrome::kHttpScheme)
23 return "80"; 25 return "80";
24 if (scheme == chrome::kHttpsScheme) 26 if (scheme == chrome::kHttpsScheme)
25 return "443"; 27 return "443";
26 return ""; 28 return "";
27 } 29 }
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 : is_valid_(false) { 363 : is_valid_(false) {
362 } 364 }
363 365
364 ContentSettingsPattern::ContentSettingsPattern( 366 ContentSettingsPattern::ContentSettingsPattern(
365 const PatternParts& parts, 367 const PatternParts& parts,
366 bool valid) 368 bool valid)
367 : parts_(parts), 369 : parts_(parts),
368 is_valid_(valid) { 370 is_valid_(valid) {
369 } 371 }
370 372
373 void ContentSettingsPattern::WriteToMessage(IPC::Message* m) const {
374 IPC::WriteParam(m, is_valid_);
375 IPC::WriteParam(m, parts_);
376 }
377
378 bool ContentSettingsPattern::ReadFromMessage(const IPC::Message* m,
379 void** iter) {
380 return IPC::ReadParam(m, iter, &is_valid_) &&
381 IPC::ReadParam(m, iter, &parts_);
382 }
383
371 bool ContentSettingsPattern::Matches( 384 bool ContentSettingsPattern::Matches(
372 const GURL& url) const { 385 const GURL& url) const {
373 // An invalid pattern matches nothing. 386 // An invalid pattern matches nothing.
374 if (!is_valid_) 387 if (!is_valid_)
375 return false; 388 return false;
376 389
377 // Match the scheme part. 390 // Match the scheme part.
378 const std::string scheme(url.scheme()); 391 const std::string scheme(url.scheme());
379 if (!parts_.is_scheme_wildcard && 392 if (!parts_.is_scheme_wildcard &&
380 parts_.scheme != scheme) { 393 parts_.scheme != scheme) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 if (!parts.is_port_wildcard && other_parts.is_port_wildcard) 614 if (!parts.is_port_wildcard && other_parts.is_port_wildcard)
602 return ContentSettingsPattern::PREDECESSOR; 615 return ContentSettingsPattern::PREDECESSOR;
603 616
604 int result = parts.port.compare(other_parts.port); 617 int result = parts.port.compare(other_parts.port);
605 if (result == 0) 618 if (result == 0)
606 return ContentSettingsPattern::IDENTITY; 619 return ContentSettingsPattern::IDENTITY;
607 if (result > 0) 620 if (result > 0)
608 return ContentSettingsPattern::DISJOINT_ORDER_PRE; 621 return ContentSettingsPattern::DISJOINT_ORDER_PRE;
609 return ContentSettingsPattern::DISJOINT_ORDER_POST; 622 return ContentSettingsPattern::DISJOINT_ORDER_POST;
610 } 623 }
OLDNEW
« no previous file with comments | « chrome/common/content_settings_pattern.h ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698