| 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 30 matching lines...) Expand all Loading... |
| 41 using blink::WebString; | 41 using blink::WebString; |
| 42 using blink::WebURL; | 42 using blink::WebURL; |
| 43 using blink::WebView; | 43 using blink::WebView; |
| 44 using content::DocumentState; | 44 using content::DocumentState; |
| 45 using content::NavigationState; | 45 using content::NavigationState; |
| 46 | 46 |
| 47 namespace { | 47 namespace { |
| 48 | 48 |
| 49 GURL GetOriginOrURL(const WebFrame* frame) { | 49 GURL GetOriginOrURL(const WebFrame* frame) { |
| 50 url::Origin top_origin = url::Origin(frame->top()->getSecurityOrigin()); | 50 url::Origin top_origin = url::Origin(frame->top()->getSecurityOrigin()); |
| 51 // The |top_origin| is unique ("null") e.g., for file:// URLs. Use the | 51 // The |top_origin| is opaque ("null") e.g., for file:// URLs. Use the |
| 52 // document URL as the primary URL in those cases. | 52 // document URL as the primary URL in those cases. |
| 53 // TODO(alexmos): This is broken for --site-per-process, since top() can be a | 53 // TODO(alexmos): This is broken for --site-per-process, since top() can be a |
| 54 // WebRemoteFrame which does not have a document(), and the WebRemoteFrame's | 54 // WebRemoteFrame which does not have a document(), and the WebRemoteFrame's |
| 55 // URL is not replicated. See https://crbug.com/628759. | 55 // URL is not replicated. See https://crbug.com/628759. |
| 56 if (top_origin.unique() && frame->top()->isWebLocalFrame()) | 56 if (top_origin.opaque() && frame->top()->isWebLocalFrame()) |
| 57 return frame->top()->document().url(); | 57 return frame->top()->document().url(); |
| 58 return top_origin.GetURL(); | 58 return top_origin.GetURL(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Allow passing both WebURL and GURL here, so that we can early return without | 61 // Allow passing both WebURL and GURL here, so that we can early return without |
| 62 // allocating a new backing string if only the default rule matches. | 62 // allocating a new backing string if only the default rule matches. |
| 63 template <typename URL> | 63 template <typename URL> |
| 64 ContentSetting GetContentSettingFromRules( | 64 ContentSetting GetContentSettingFromRules( |
| 65 const ContentSettingsForOneType& rules, | 65 const ContentSettingsForOneType& rules, |
| 66 const WebFrame* frame, | 66 const WebFrame* frame, |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 #endif | 539 #endif |
| 540 | 540 |
| 541 // If the scheme is file:, an empty file name indicates a directory listing, | 541 // If the scheme is file:, an empty file name indicates a directory listing, |
| 542 // which requires JavaScript to function properly. | 542 // which requires JavaScript to function properly. |
| 543 if (protocol == url::kFileScheme && | 543 if (protocol == url::kFileScheme && |
| 544 document_url.protocolIs(url::kFileScheme)) { | 544 document_url.protocolIs(url::kFileScheme)) { |
| 545 return GURL(document_url).ExtractFileName().empty(); | 545 return GURL(document_url).ExtractFileName().empty(); |
| 546 } | 546 } |
| 547 return false; | 547 return false; |
| 548 } | 548 } |
| OLD | NEW |