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