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

Side by Side Diff: chrome/renderer/content_settings_observer.cc

Issue 2938163002: Store base::Value in ContentSettingPatternSource instead of an enum (Closed)
Patch Set: ps Created 3 years, 6 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
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/renderer/content_settings_observer.h" 5 #include "chrome/renderer/content_settings_observer.h"
6 6
7 #include "chrome/common/render_messages.h" 7 #include "chrome/common/render_messages.h"
8 #include "chrome/common/ssl_insecure_content.h" 8 #include "chrome/common/ssl_insecure_content.h"
9 #include "components/content_settings/core/common/content_settings_utils.h"
9 #include "content/public/common/url_constants.h" 10 #include "content/public/common/url_constants.h"
10 #include "content/public/renderer/document_state.h" 11 #include "content/public/renderer/document_state.h"
11 #include "content/public/renderer/render_frame.h" 12 #include "content/public/renderer/render_frame.h"
12 #include "content/public/renderer/render_view.h" 13 #include "content/public/renderer/render_view.h"
13 #include "extensions/features/features.h" 14 #include "extensions/features/features.h"
14 #include "services/service_manager/public/cpp/binder_registry.h" 15 #include "services/service_manager/public/cpp/binder_registry.h"
15 #include "third_party/WebKit/public/platform/URLConversion.h" 16 #include "third_party/WebKit/public/platform/URLConversion.h"
16 #include "third_party/WebKit/public/platform/WebContentSettingCallbacks.h" 17 #include "third_party/WebKit/public/platform/WebContentSettingCallbacks.h"
17 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 18 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
18 #include "third_party/WebKit/public/platform/WebURL.h" 19 #include "third_party/WebKit/public/platform/WebURL.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 ContentSetting GetContentSettingFromRules( 65 ContentSetting GetContentSettingFromRules(
65 const ContentSettingsForOneType& rules, 66 const ContentSettingsForOneType& rules,
66 const WebFrame* frame, 67 const WebFrame* frame,
67 const URL& secondary_url) { 68 const URL& secondary_url) {
68 ContentSettingsForOneType::const_iterator it; 69 ContentSettingsForOneType::const_iterator it;
69 // If there is only one rule, it's the default rule and we don't need to match 70 // If there is only one rule, it's the default rule and we don't need to match
70 // the patterns. 71 // the patterns.
71 if (rules.size() == 1) { 72 if (rules.size() == 1) {
72 DCHECK(rules[0].primary_pattern == ContentSettingsPattern::Wildcard()); 73 DCHECK(rules[0].primary_pattern == ContentSettingsPattern::Wildcard());
73 DCHECK(rules[0].secondary_pattern == ContentSettingsPattern::Wildcard()); 74 DCHECK(rules[0].secondary_pattern == ContentSettingsPattern::Wildcard());
74 return rules[0].setting; 75 return content_settings::ValueToContentSetting(
76 rules[0].setting_value.get());
75 } 77 }
76 const GURL& primary_url = GetOriginOrURL(frame); 78 const GURL& primary_url = GetOriginOrURL(frame);
77 const GURL& secondary_gurl = secondary_url; 79 const GURL& secondary_gurl = secondary_url;
78 for (it = rules.begin(); it != rules.end(); ++it) { 80 for (it = rules.begin(); it != rules.end(); ++it) {
79 if (it->primary_pattern.Matches(primary_url) && 81 if (it->primary_pattern.Matches(primary_url) &&
80 it->secondary_pattern.Matches(secondary_gurl)) { 82 it->secondary_pattern.Matches(secondary_gurl)) {
81 return it->setting; 83 return content_settings::ValueToContentSetting(it->setting_value.get());
82 } 84 }
83 } 85 }
84 NOTREACHED(); 86 NOTREACHED();
85 return CONTENT_SETTING_DEFAULT; 87 return CONTENT_SETTING_DEFAULT;
86 } 88 }
87 89
88 } // namespace 90 } // namespace
89 91
90 ContentSettingsObserver::ContentSettingsObserver( 92 ContentSettingsObserver::ContentSettingsObserver(
91 content::RenderFrame* render_frame, 93 content::RenderFrame* render_frame,
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 #endif 542 #endif
541 543
542 // If the scheme is file:, an empty file name indicates a directory listing, 544 // If the scheme is file:, an empty file name indicates a directory listing,
543 // which requires JavaScript to function properly. 545 // which requires JavaScript to function properly.
544 if (protocol == url::kFileScheme && 546 if (protocol == url::kFileScheme &&
545 document_url.ProtocolIs(url::kFileScheme)) { 547 document_url.ProtocolIs(url::kFileScheme)) {
546 return GURL(document_url).ExtractFileName().empty(); 548 return GURL(document_url).ExtractFileName().empty();
547 } 549 }
548 return false; 550 return false;
549 } 551 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698