OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/navigation_state.h" | 10 #include "content/public/renderer/navigation_state.h" |
10 #include "content/public/renderer/render_view.h" | 11 #include "content/public/renderer/render_view.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
18 | 19 |
19 using WebKit::WebDataSource; | 20 using WebKit::WebDataSource; |
20 using WebKit::WebFrame; | 21 using WebKit::WebFrame; |
21 using WebKit::WebFrameClient; | 22 using WebKit::WebFrameClient; |
22 using WebKit::WebSecurityOrigin; | 23 using WebKit::WebSecurityOrigin; |
23 using WebKit::WebString; | 24 using WebKit::WebString; |
24 using WebKit::WebURL; | 25 using WebKit::WebURL; |
25 using WebKit::WebView; | 26 using WebKit::WebView; |
| 27 using content::DocumentState; |
26 using content::NavigationState; | 28 using content::NavigationState; |
27 | 29 |
28 namespace { | 30 namespace { |
29 | 31 |
30 // True if |frame| contains content that is white-listed for content settings. | 32 // True if |frame| contains content that is white-listed for content settings. |
31 static bool IsWhitelistedForContentSettings(WebFrame* frame) { | 33 static bool IsWhitelistedForContentSettings(WebFrame* frame) { |
32 WebSecurityOrigin origin = frame->document().securityOrigin(); | 34 WebSecurityOrigin origin = frame->document().securityOrigin(); |
33 if (origin.isEmpty()) | 35 if (origin.isEmpty()) |
34 return false; // Uninitialized document? | 36 return false; // Uninitialized document? |
35 | 37 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 IPC_MESSAGE_UNHANDLED(handled = false) | 130 IPC_MESSAGE_UNHANDLED(handled = false) |
129 IPC_END_MESSAGE_MAP() | 131 IPC_END_MESSAGE_MAP() |
130 return handled; | 132 return handled; |
131 } | 133 } |
132 | 134 |
133 void ContentSettingsObserver::DidCommitProvisionalLoad( | 135 void ContentSettingsObserver::DidCommitProvisionalLoad( |
134 WebFrame* frame, bool is_new_navigation) { | 136 WebFrame* frame, bool is_new_navigation) { |
135 if (frame->parent()) | 137 if (frame->parent()) |
136 return; // Not a top-level navigation. | 138 return; // Not a top-level navigation. |
137 | 139 |
138 NavigationState* state = NavigationState::FromDataSource(frame->dataSource()); | 140 DocumentState* document_state = DocumentState::FromDataSource( |
139 if (!state->was_within_same_page()) { | 141 frame->dataSource()); |
| 142 NavigationState* navigation_state = document_state->navigation_state(); |
| 143 if (!navigation_state->was_within_same_page()) { |
140 // Clear "block" flags for the new page. This needs to happen before any of | 144 // Clear "block" flags for the new page. This needs to happen before any of |
141 // |AllowScript()|, |AllowScriptFromSource()|, |AllowImage()|, or | 145 // |AllowScript()|, |AllowScriptFromSource()|, |AllowImage()|, or |
142 // |AllowPlugins()| is called for the new page so that these functions can | 146 // |AllowPlugins()| is called for the new page so that these functions can |
143 // correctly detect that a piece of content flipped from "not blocked" to | 147 // correctly detect that a piece of content flipped from "not blocked" to |
144 // "blocked". | 148 // "blocked". |
145 ClearBlockedContentSettings(); | 149 ClearBlockedContentSettings(); |
146 plugins_temporarily_allowed_ = false; | 150 plugins_temporarily_allowed_ = false; |
147 } | 151 } |
148 | 152 |
149 GURL url = frame->document().url(); | 153 GURL url = frame->document().url(); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 void ContentSettingsObserver::OnLoadBlockedPlugins() { | 302 void ContentSettingsObserver::OnLoadBlockedPlugins() { |
299 plugins_temporarily_allowed_ = true; | 303 plugins_temporarily_allowed_ = true; |
300 } | 304 } |
301 | 305 |
302 void ContentSettingsObserver::ClearBlockedContentSettings() { | 306 void ContentSettingsObserver::ClearBlockedContentSettings() { |
303 for (size_t i = 0; i < arraysize(content_blocked_); ++i) | 307 for (size_t i = 0; i < arraysize(content_blocked_); ++i) |
304 content_blocked_[i] = false; | 308 content_blocked_[i] = false; |
305 cached_storage_permissions_.clear(); | 309 cached_storage_permissions_.clear(); |
306 cached_script_permissions_.clear(); | 310 cached_script_permissions_.clear(); |
307 } | 311 } |
OLD | NEW |