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/browser/extensions/api/web_navigation/frame_navigation_state.h" | 5 #include "chrome/browser/extensions/api/web_navigation/frame_navigation_state.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
10 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 url::kFtpScheme, | 23 url::kFtpScheme, |
24 url::kJavaScriptScheme, | 24 url::kJavaScriptScheme, |
25 url::kDataScheme, | 25 url::kDataScheme, |
26 url::kFileSystemScheme, | 26 url::kFileSystemScheme, |
27 }; | 27 }; |
28 | 28 |
29 } // namespace | 29 } // namespace |
30 | 30 |
31 FrameNavigationState::FrameState::FrameState() { | 31 FrameNavigationState::FrameState::FrameState() { |
32 error_occurred = false; | 32 error_occurred = false; |
| 33 is_iframe_srcdoc = false; |
33 is_loading = false; | 34 is_loading = false; |
34 is_parsing = false; | 35 is_parsing = false; |
35 } | 36 } |
36 | 37 |
37 // static | 38 // static |
38 bool FrameNavigationState::allow_extension_scheme_ = false; | 39 bool FrameNavigationState::allow_extension_scheme_ = false; |
39 | 40 |
40 FrameNavigationState::FrameNavigationState() { | 41 FrameNavigationState::FrameNavigationState() { |
41 } | 42 } |
42 | 43 |
(...skipping 20 matching lines...) Expand all Loading... |
63 if (it == frame_host_state_map_.end() || it->second.error_occurred) { | 64 if (it == frame_host_state_map_.end() || it->second.error_occurred) { |
64 return false; | 65 return false; |
65 } | 66 } |
66 return IsValidUrl(it->second.url); | 67 return IsValidUrl(it->second.url); |
67 } | 68 } |
68 | 69 |
69 void FrameNavigationState::StartTrackingDocumentLoad( | 70 void FrameNavigationState::StartTrackingDocumentLoad( |
70 content::RenderFrameHost* frame_host, | 71 content::RenderFrameHost* frame_host, |
71 const GURL& url, | 72 const GURL& url, |
72 bool is_same_page, | 73 bool is_same_page, |
73 bool is_error_page) { | 74 bool is_error_page, |
| 75 bool is_iframe_srcdoc) { |
74 FrameState& frame_state = frame_host_state_map_[frame_host]; | 76 FrameState& frame_state = frame_host_state_map_[frame_host]; |
75 frame_state.error_occurred = is_error_page; | 77 frame_state.error_occurred = is_error_page; |
76 frame_state.url = url; | 78 frame_state.url = url; |
| 79 frame_state.is_iframe_srcdoc = is_iframe_srcdoc; |
| 80 DCHECK(!is_iframe_srcdoc || url == url::kAboutBlankURL); |
77 if (!is_same_page) { | 81 if (!is_same_page) { |
78 frame_state.is_loading = true; | 82 frame_state.is_loading = true; |
79 frame_state.is_parsing = true; | 83 frame_state.is_parsing = true; |
80 } | 84 } |
81 } | 85 } |
82 | 86 |
83 void FrameNavigationState::FrameHostCreated( | 87 void FrameNavigationState::FrameHostCreated( |
84 content::RenderFrameHost* frame_host) { | 88 content::RenderFrameHost* frame_host) { |
85 frame_hosts_.insert(frame_host); | 89 frame_hosts_.insert(frame_host); |
86 } | 90 } |
(...skipping 18 matching lines...) Expand all Loading... |
105 content::RenderFrameHost* frame_host) const { | 109 content::RenderFrameHost* frame_host) const { |
106 return frame_host_state_map_.find(frame_host) != frame_host_state_map_.end(); | 110 return frame_host_state_map_.find(frame_host) != frame_host_state_map_.end(); |
107 } | 111 } |
108 | 112 |
109 GURL FrameNavigationState::GetUrl(content::RenderFrameHost* frame_host) const { | 113 GURL FrameNavigationState::GetUrl(content::RenderFrameHost* frame_host) const { |
110 FrameHostToStateMap::const_iterator it = | 114 FrameHostToStateMap::const_iterator it = |
111 frame_host_state_map_.find(frame_host); | 115 frame_host_state_map_.find(frame_host); |
112 if (it == frame_host_state_map_.end()) | 116 if (it == frame_host_state_map_.end()) |
113 return GURL(); | 117 return GURL(); |
114 | 118 |
| 119 if (it->second.is_iframe_srcdoc) |
| 120 return GURL(content::kAboutSrcDocURL); |
115 return it->second.url; | 121 return it->second.url; |
116 } | 122 } |
117 | 123 |
118 void FrameNavigationState::SetErrorOccurredInFrame( | 124 void FrameNavigationState::SetErrorOccurredInFrame( |
119 content::RenderFrameHost* frame_host) { | 125 content::RenderFrameHost* frame_host) { |
120 FrameHostToStateMap::iterator it = frame_host_state_map_.find(frame_host); | 126 FrameHostToStateMap::iterator it = frame_host_state_map_.find(frame_host); |
121 if (it == frame_host_state_map_.end()) { | 127 if (it == frame_host_state_map_.end()) { |
122 NOTREACHED(); | 128 NOTREACHED(); |
123 return; | 129 return; |
124 } | 130 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 169 |
164 bool FrameNavigationState::GetParsingFinished( | 170 bool FrameNavigationState::GetParsingFinished( |
165 content::RenderFrameHost* frame_host) const { | 171 content::RenderFrameHost* frame_host) const { |
166 FrameHostToStateMap::const_iterator it = | 172 FrameHostToStateMap::const_iterator it = |
167 frame_host_state_map_.find(frame_host); | 173 frame_host_state_map_.find(frame_host); |
168 DCHECK(it != frame_host_state_map_.end()); | 174 DCHECK(it != frame_host_state_map_.end()); |
169 return it == frame_host_state_map_.end() || !it->second.is_parsing; | 175 return it == frame_host_state_map_.end() || !it->second.is_parsing; |
170 } | 176 } |
171 | 177 |
172 } // namespace extensions | 178 } // namespace extensions |
OLD | NEW |