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

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

Issue 6915017: Chrome side to allow WebKit layer to use WebPermissionClient to check if access to local storage ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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) 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/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/url_constants.h" 8 #include "chrome/common/url_constants.h"
9 #include "content/common/database_messages.h" 9 #include "content/common/database_messages.h"
10 #include "content/common/dom_storage_common.h"
10 #include "content/common/view_messages.h" 11 #include "content/common/view_messages.h"
11 #include "content/renderer/render_view.h" 12 #include "content/renderer/render_view.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
18 19
19 using WebKit::WebDataSource; 20 using WebKit::WebDataSource;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 134
134 bool ContentSettingsObserver::AllowDatabase(WebFrame* frame, 135 bool ContentSettingsObserver::AllowDatabase(WebFrame* frame,
135 const WebString& name, 136 const WebString& name,
136 const WebString& display_name, 137 const WebString& display_name,
137 unsigned long estimated_size) { 138 unsigned long estimated_size) {
138 WebSecurityOrigin origin = frame->securityOrigin(); 139 WebSecurityOrigin origin = frame->securityOrigin();
139 if (origin.isEmpty()) 140 if (origin.isEmpty())
140 return false; // Uninitialized document? 141 return false; // Uninitialized document?
141 142
142 bool result; 143 bool result;
143 if (!Send(new ViewHostMsg_AllowDatabase(routing_id(), 144 if (!Send(new ViewHostMsg_AllowDatabase(
144 origin.toString().utf8(), name, display_name, estimated_size, &result))) 145 origin.toString().utf8(), name, display_name, estimated_size, &result)))
145 return false; 146 return false;
146 Send(new ViewHostMsg_WebDatabaseAccessed(routing_id(), 147 Send(new ViewHostMsg_WebDatabaseAccessed(routing_id(),
147 GURL(origin.toString().utf8()), 148 GURL(origin.toString().utf8()),
148 name, 149 name,
149 display_name, 150 display_name,
150 estimated_size, 151 estimated_size,
151 !result)); 152 !result));
152 return result; 153 return result;
153 } 154 }
154 155
155 bool ContentSettingsObserver::AllowImages(WebFrame* frame, 156 bool ContentSettingsObserver::AllowImages(WebFrame* frame,
156 bool enabled_per_settings) { 157 bool enabled_per_settings) {
157 if (enabled_per_settings && 158 if (enabled_per_settings &&
158 AllowContentType(CONTENT_SETTINGS_TYPE_IMAGES)) { 159 AllowContentType(CONTENT_SETTINGS_TYPE_IMAGES)) {
159 return true; 160 return true;
160 } 161 }
161 162
162 if (IsWhitelistedForContentSettings(frame)) 163 if (IsWhitelistedForContentSettings(frame))
163 return true; 164 return true;
164 165
165 DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES, std::string()); 166 DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES, std::string());
166 return false; // Other protocols fall through here. 167 return false; // Other protocols fall through here.
167 } 168 }
168 169
169 bool ContentSettingsObserver::AllowPlugins(WebFrame* frame, 170 bool ContentSettingsObserver::AllowPlugins(WebFrame* frame,
170 bool enabled_per_settings) { 171 bool enabled_per_settings) {
171 return render_view()->WebFrameClient::allowPlugins( 172 return enabled_per_settings;
172 frame, enabled_per_settings);
173 } 173 }
174 174
175 bool ContentSettingsObserver::AllowScript(WebFrame* frame, 175 bool ContentSettingsObserver::AllowScript(WebFrame* frame,
176 bool enabled_per_settings) { 176 bool enabled_per_settings) {
177 if (enabled_per_settings && 177 if (enabled_per_settings &&
178 AllowContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT)) { 178 AllowContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT)) {
179 return true; 179 return true;
180 } 180 }
181 181
182 if (IsWhitelistedForContentSettings(frame)) 182 if (IsWhitelistedForContentSettings(frame))
183 return true; 183 return true;
184 184
185 return false; // Other protocols fall through here. 185 return false; // Other protocols fall through here.
186 } 186 }
187 187
188 bool ContentSettingsObserver::AllowStorage(WebFrame* frame, bool local) {
189 bool result = false;
190 Send(new ViewHostMsg_AllowDOMStorage(
191 routing_id(), frame->url(),
192 local ? DOM_STORAGE_LOCAL : DOM_STORAGE_SESSION,
193 &result));
194 return result;
195 }
196
188 void ContentSettingsObserver::DidNotAllowPlugins(WebFrame* frame) { 197 void ContentSettingsObserver::DidNotAllowPlugins(WebFrame* frame) {
189 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); 198 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, std::string());
190 } 199 }
191 200
192 void ContentSettingsObserver::DidNotAllowScript(WebFrame* frame) { 201 void ContentSettingsObserver::DidNotAllowScript(WebFrame* frame) {
193 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string()); 202 DidBlockContentType(CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string());
194 } 203 }
195 204
196 void ContentSettingsObserver::OnSetContentSettingsForLoadingURL( 205 void ContentSettingsObserver::OnSetContentSettingsForLoadingURL(
197 const GURL& url, 206 const GURL& url,
198 const ContentSettings& content_settings) { 207 const ContentSettings& content_settings) {
199 host_content_settings_[url] = content_settings; 208 host_content_settings_[url] = content_settings;
200 } 209 }
201 210
202 bool ContentSettingsObserver::AllowContentType( 211 bool ContentSettingsObserver::AllowContentType(
203 ContentSettingsType settings_type) { 212 ContentSettingsType settings_type) {
204 // CONTENT_SETTING_ASK is only valid for cookies. 213 // CONTENT_SETTING_ASK is only valid for cookies.
205 return current_content_settings_.settings[settings_type] != 214 return current_content_settings_.settings[settings_type] !=
206 CONTENT_SETTING_BLOCK; 215 CONTENT_SETTING_BLOCK;
207 } 216 }
208 217
209 void ContentSettingsObserver::ClearBlockedContentSettings() { 218 void ContentSettingsObserver::ClearBlockedContentSettings() {
210 for (size_t i = 0; i < arraysize(content_blocked_); ++i) 219 for (size_t i = 0; i < arraysize(content_blocked_); ++i)
211 content_blocked_[i] = false; 220 content_blocked_[i] = false;
212 } 221 }
OLDNEW
« no previous file with comments | « chrome/renderer/content_settings_observer.h ('k') | content/browser/in_process_webkit/dom_storage_area.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698