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