| 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/ssl_insecure_content.h" | 8 #include "chrome/common/ssl_insecure_content.h" |
| 9 #include "content/public/common/url_constants.h" | 9 #include "content/public/common/url_constants.h" |
| 10 #include "content/public/renderer/document_state.h" | 10 #include "content/public/renderer/document_state.h" |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 return true; | 514 return true; |
| 515 | 515 |
| 516 WebFrame* web_frame = render_frame()->GetWebFrame(); | 516 WebFrame* web_frame = render_frame()->GetWebFrame(); |
| 517 return IsWhitelistedForContentSettings( | 517 return IsWhitelistedForContentSettings( |
| 518 web_frame->document().getSecurityOrigin(), web_frame->document().url()); | 518 web_frame->document().getSecurityOrigin(), web_frame->document().url()); |
| 519 } | 519 } |
| 520 | 520 |
| 521 bool ContentSettingsObserver::IsWhitelistedForContentSettings( | 521 bool ContentSettingsObserver::IsWhitelistedForContentSettings( |
| 522 const WebSecurityOrigin& origin, | 522 const WebSecurityOrigin& origin, |
| 523 const GURL& document_url) { | 523 const GURL& document_url) { |
| 524 if (document_url == GURL(content::kUnreachableWebDataURL)) | 524 if (document_url == content::kUnreachableWebDataURL) |
| 525 return true; | 525 return true; |
| 526 | 526 |
| 527 if (origin.isUnique()) | 527 if (origin.isUnique()) |
| 528 return false; // Uninitialized document? | 528 return false; // Uninitialized document? |
| 529 | 529 |
| 530 base::string16 protocol = origin.protocol(); | 530 base::string16 protocol = origin.protocol(); |
| 531 if (base::EqualsASCII(protocol, content::kChromeUIScheme)) | 531 if (base::EqualsASCII(protocol, content::kChromeUIScheme)) |
| 532 return true; // Browser UI elements should still work. | 532 return true; // Browser UI elements should still work. |
| 533 | 533 |
| 534 if (base::EqualsASCII(protocol, content::kChromeDevToolsScheme)) | 534 if (base::EqualsASCII(protocol, content::kChromeDevToolsScheme)) |
| 535 return true; // DevTools UI elements should still work. | 535 return true; // DevTools UI elements should still work. |
| 536 | 536 |
| 537 #if defined(ENABLE_EXTENSIONS) | 537 #if defined(ENABLE_EXTENSIONS) |
| 538 if (base::EqualsASCII(protocol, extensions::kExtensionScheme)) | 538 if (base::EqualsASCII(protocol, extensions::kExtensionScheme)) |
| 539 return true; | 539 return true; |
| 540 #endif | 540 #endif |
| 541 | 541 |
| 542 // If the scheme is file:, an empty file name indicates a directory listing, | 542 // If the scheme is file:, an empty file name indicates a directory listing, |
| 543 // which requires JavaScript to function properly. | 543 // which requires JavaScript to function properly. |
| 544 if (base::EqualsASCII(protocol, url::kFileScheme)) { | 544 if (base::EqualsASCII(protocol, url::kFileScheme)) { |
| 545 return document_url.SchemeIs(url::kFileScheme) && | 545 return document_url.SchemeIs(url::kFileScheme) && |
| 546 document_url.ExtractFileName().empty(); | 546 document_url.ExtractFileName().empty(); |
| 547 } | 547 } |
| 548 | 548 |
| 549 return false; | 549 return false; |
| 550 } | 550 } |
| OLD | NEW |