OLD | NEW |
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/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
9 #include "content/public/renderer/document_state.h" | 9 #include "content/public/renderer/document_state.h" |
10 #include "content/public/renderer/navigation_state.h" | 10 #include "content/public/renderer/navigation_state.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } | 312 } |
313 | 313 |
314 bool ContentSettingsObserver::IsWhitelistedForContentSettings(WebFrame* frame) { | 314 bool ContentSettingsObserver::IsWhitelistedForContentSettings(WebFrame* frame) { |
315 return IsWhitelistedForContentSettings(frame->document().securityOrigin(), | 315 return IsWhitelistedForContentSettings(frame->document().securityOrigin(), |
316 frame->document().url()); | 316 frame->document().url()); |
317 } | 317 } |
318 | 318 |
319 bool ContentSettingsObserver::IsWhitelistedForContentSettings( | 319 bool ContentSettingsObserver::IsWhitelistedForContentSettings( |
320 const WebSecurityOrigin& origin, | 320 const WebSecurityOrigin& origin, |
321 const GURL& document_url) { | 321 const GURL& document_url) { |
| 322 if (document_url == GURL(content::kUnreachableWebDataURL)) |
| 323 return true; |
| 324 |
322 if (origin.isUnique()) | 325 if (origin.isUnique()) |
323 return false; // Uninitialized document? | 326 return false; // Uninitialized document? |
324 | 327 |
325 if (EqualsASCII(origin.protocol(), chrome::kChromeUIScheme)) | 328 if (EqualsASCII(origin.protocol(), chrome::kChromeUIScheme)) |
326 return true; // Browser UI elements should still work. | 329 return true; // Browser UI elements should still work. |
327 | 330 |
328 if (EqualsASCII(origin.protocol(), chrome::kChromeDevToolsScheme)) | 331 if (EqualsASCII(origin.protocol(), chrome::kChromeDevToolsScheme)) |
329 return true; // DevTools UI elements should still work. | 332 return true; // DevTools UI elements should still work. |
330 | 333 |
331 if (EqualsASCII(origin.protocol(), chrome::kExtensionScheme)) | 334 if (EqualsASCII(origin.protocol(), chrome::kExtensionScheme)) |
332 return true; | 335 return true; |
333 | 336 |
334 if (EqualsASCII(origin.protocol(), chrome::kChromeInternalScheme)) | 337 if (EqualsASCII(origin.protocol(), chrome::kChromeInternalScheme)) |
335 return true; | 338 return true; |
336 | 339 |
337 // If the scheme is ftp: or file:, an empty file name indicates a directory | 340 // If the scheme is ftp: or file:, an empty file name indicates a directory |
338 // listing, which requires JavaScript to function properly. | 341 // listing, which requires JavaScript to function properly. |
339 const char* kDirProtocols[] = { chrome::kFtpScheme, chrome::kFileScheme }; | 342 const char* kDirProtocols[] = { chrome::kFtpScheme, chrome::kFileScheme }; |
340 for (size_t i = 0; i < arraysize(kDirProtocols); ++i) { | 343 for (size_t i = 0; i < arraysize(kDirProtocols); ++i) { |
341 if (EqualsASCII(origin.protocol(), kDirProtocols[i])) { | 344 if (EqualsASCII(origin.protocol(), kDirProtocols[i])) { |
342 return document_url.SchemeIs(kDirProtocols[i]) && | 345 return document_url.SchemeIs(kDirProtocols[i]) && |
343 document_url.ExtractFileName().empty(); | 346 document_url.ExtractFileName().empty(); |
344 } | 347 } |
345 } | 348 } |
346 | 349 |
347 return false; | 350 return false; |
348 } | 351 } |
OLD | NEW |