| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 GURL(frame->document().securityOrigin().toString().utf8()), &allowed)); | 389 GURL(frame->document().securityOrigin().toString().utf8()), &allowed)); |
| 390 return allowed; | 390 return allowed; |
| 391 } | 391 } |
| 392 | 392 |
| 393 bool ContentSettingsObserver::allowWebComponents(WebFrame* frame, | 393 bool ContentSettingsObserver::allowWebComponents(WebFrame* frame, |
| 394 bool defaultValue) { | 394 bool defaultValue) { |
| 395 if (defaultValue) | 395 if (defaultValue) |
| 396 return true; | 396 return true; |
| 397 | 397 |
| 398 WebSecurityOrigin origin = frame->document().securityOrigin(); | 398 WebSecurityOrigin origin = frame->document().securityOrigin(); |
| 399 if (EqualsASCII(origin.protocol(), chrome::kChromeUIScheme)) | 399 if (EqualsASCII(origin.protocol(), content::kChromeUIScheme)) |
| 400 return true; | 400 return true; |
| 401 | 401 |
| 402 if (const extensions::Extension* extension = GetExtension(origin)) { | 402 if (const extensions::Extension* extension = GetExtension(origin)) { |
| 403 if (extension->HasAPIPermission(APIPermission::kExperimental)) | 403 if (extension->HasAPIPermission(APIPermission::kExperimental)) |
| 404 return true; | 404 return true; |
| 405 } | 405 } |
| 406 | 406 |
| 407 return false; | 407 return false; |
| 408 } | 408 } |
| 409 | 409 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 | 626 |
| 627 bool ContentSettingsObserver::IsWhitelistedForContentSettings( | 627 bool ContentSettingsObserver::IsWhitelistedForContentSettings( |
| 628 const WebSecurityOrigin& origin, | 628 const WebSecurityOrigin& origin, |
| 629 const GURL& document_url) { | 629 const GURL& document_url) { |
| 630 if (document_url == GURL(content::kUnreachableWebDataURL)) | 630 if (document_url == GURL(content::kUnreachableWebDataURL)) |
| 631 return true; | 631 return true; |
| 632 | 632 |
| 633 if (origin.isUnique()) | 633 if (origin.isUnique()) |
| 634 return false; // Uninitialized document? | 634 return false; // Uninitialized document? |
| 635 | 635 |
| 636 if (EqualsASCII(origin.protocol(), chrome::kChromeUIScheme)) | 636 if (EqualsASCII(origin.protocol(), content::kChromeUIScheme)) |
| 637 return true; // Browser UI elements should still work. | 637 return true; // Browser UI elements should still work. |
| 638 | 638 |
| 639 if (EqualsASCII(origin.protocol(), chrome::kChromeDevToolsScheme)) | 639 if (EqualsASCII(origin.protocol(), chrome::kChromeDevToolsScheme)) |
| 640 return true; // DevTools UI elements should still work. | 640 return true; // DevTools UI elements should still work. |
| 641 | 641 |
| 642 if (EqualsASCII(origin.protocol(), extensions::kExtensionScheme)) | 642 if (EqualsASCII(origin.protocol(), extensions::kExtensionScheme)) |
| 643 return true; | 643 return true; |
| 644 | 644 |
| 645 // TODO(creis, fsamuel): Remove this once the concept of swapped out | 645 // TODO(creis, fsamuel): Remove this once the concept of swapped out |
| 646 // RenderFrames goes away. | 646 // RenderFrames goes away. |
| 647 if (document_url == GURL(content::kSwappedOutURL)) | 647 if (document_url == GURL(content::kSwappedOutURL)) |
| 648 return true; | 648 return true; |
| 649 | 649 |
| 650 // If the scheme is file:, an empty file name indicates a directory listing, | 650 // If the scheme is file:, an empty file name indicates a directory listing, |
| 651 // which requires JavaScript to function properly. | 651 // which requires JavaScript to function properly. |
| 652 if (EqualsASCII(origin.protocol(), content::kFileScheme)) { | 652 if (EqualsASCII(origin.protocol(), content::kFileScheme)) { |
| 653 return document_url.SchemeIs(content::kFileScheme) && | 653 return document_url.SchemeIs(content::kFileScheme) && |
| 654 document_url.ExtractFileName().empty(); | 654 document_url.ExtractFileName().empty(); |
| 655 } | 655 } |
| 656 | 656 |
| 657 return false; | 657 return false; |
| 658 } | 658 } |
| OLD | NEW |