Chromium Code Reviews| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 bool FrameNavigationState::CanSendEvents( | 55 bool FrameNavigationState::CanSendEvents( |
| 56 content::RenderFrameHost* frame_host) const { | 56 content::RenderFrameHost* frame_host) const { |
| 57 FrameHostToStateMap::const_iterator it = | 57 FrameHostToStateMap::const_iterator it = |
| 58 frame_host_state_map_.find(frame_host); | 58 frame_host_state_map_.find(frame_host); |
| 59 if (it == frame_host_state_map_.end() || it->second.error_occurred) { | 59 if (it == frame_host_state_map_.end() || it->second.error_occurred) { |
| 60 return false; | 60 return false; |
| 61 } | 61 } |
| 62 return IsValidUrl(it->second.url); | 62 return IsValidUrl(it->second.url); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void FrameNavigationState::StartTrackingNavigation( | 65 void FrameNavigationState::StartTrackingDocumentLoad( |
| 66 content::RenderFrameHost* frame_host, | 66 content::RenderFrameHost* frame_host, |
| 67 const GURL& url, | 67 const GURL& url, |
| 68 bool is_same_page, | |
| 68 bool is_error_page, | 69 bool is_error_page, |
| 69 bool is_iframe_srcdoc) { | 70 bool is_iframe_srcdoc) { |
| 70 FrameState& frame_state = frame_host_state_map_[frame_host]; | 71 FrameState& frame_state = frame_host_state_map_[frame_host]; |
| 71 frame_state.error_occurred = is_error_page; | 72 frame_state.error_occurred = is_error_page; |
| 72 frame_state.url = url; | 73 frame_state.url = url; |
| 73 frame_state.is_iframe_srcdoc = is_iframe_srcdoc; | 74 frame_state.is_iframe_srcdoc = is_iframe_srcdoc; |
| 74 DCHECK(!is_iframe_srcdoc || url == GURL(url::kAboutBlankURL)); | 75 DCHECK(!is_iframe_srcdoc || url == GURL(url::kAboutBlankURL)); |
| 75 frame_state.is_navigating = true; | 76 if (!is_same_page) { |
| 76 frame_state.is_committed = false; | 77 frame_state.is_loading = true; |
| 77 frame_state.is_server_redirected = false; | 78 frame_state.is_parsing = true; |
| 78 frame_state.is_parsing = true; | 79 } |
| 79 } | 80 } |
| 80 | 81 |
| 81 void FrameNavigationState::FrameHostCreated( | 82 void FrameNavigationState::FrameHostCreated( |
| 82 content::RenderFrameHost* frame_host) { | 83 content::RenderFrameHost* frame_host) { |
| 83 frame_hosts_.insert(frame_host); | 84 frame_hosts_.insert(frame_host); |
| 84 } | 85 } |
| 85 | 86 |
| 86 void FrameNavigationState::FrameHostDeleted( | 87 void FrameNavigationState::FrameHostDeleted( |
| 87 content::RenderFrameHost* frame_host) { | 88 content::RenderFrameHost* frame_host) { |
| 88 frame_host_state_map_.erase(frame_host); | 89 frame_host_state_map_.erase(frame_host); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 101 | 102 |
| 102 bool FrameNavigationState::IsValidFrame( | 103 bool FrameNavigationState::IsValidFrame( |
| 103 content::RenderFrameHost* frame_host) const { | 104 content::RenderFrameHost* frame_host) const { |
| 104 return frame_host_state_map_.find(frame_host) != frame_host_state_map_.end(); | 105 return frame_host_state_map_.find(frame_host) != frame_host_state_map_.end(); |
| 105 } | 106 } |
| 106 | 107 |
| 107 GURL FrameNavigationState::GetUrl(content::RenderFrameHost* frame_host) const { | 108 GURL FrameNavigationState::GetUrl(content::RenderFrameHost* frame_host) const { |
| 108 FrameHostToStateMap::const_iterator it = | 109 FrameHostToStateMap::const_iterator it = |
| 109 frame_host_state_map_.find(frame_host); | 110 frame_host_state_map_.find(frame_host); |
| 110 if (it == frame_host_state_map_.end()) { | 111 if (it == frame_host_state_map_.end()) { |
| 111 NOTREACHED(); | |
|
Devlin
2016/02/05 18:30:28
Why is this okay now?
nasko
2016/02/05 23:41:22
I am no longer tracking anything until the commit
| |
| 112 return GURL(); | 112 return GURL(); |
| 113 } | 113 } |
| 114 if (it->second.is_iframe_srcdoc) | 114 if (it->second.is_iframe_srcdoc) |
| 115 return GURL(content::kAboutSrcDocURL); | 115 return GURL(content::kAboutSrcDocURL); |
| 116 return it->second.url; | 116 return it->second.url; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void FrameNavigationState::SetErrorOccurredInFrame( | 119 void FrameNavigationState::SetErrorOccurredInFrame( |
| 120 content::RenderFrameHost* frame_host) { | 120 content::RenderFrameHost* frame_host) { |
| 121 FrameHostToStateMap::iterator it = frame_host_state_map_.find(frame_host); | 121 FrameHostToStateMap::iterator it = frame_host_state_map_.find(frame_host); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 134 return it == frame_host_state_map_.end() || it->second.error_occurred; | 134 return it == frame_host_state_map_.end() || it->second.error_occurred; |
| 135 } | 135 } |
| 136 | 136 |
| 137 void FrameNavigationState::SetNavigationCompleted( | 137 void FrameNavigationState::SetNavigationCompleted( |
| 138 content::RenderFrameHost* frame_host) { | 138 content::RenderFrameHost* frame_host) { |
| 139 FrameHostToStateMap::iterator it = frame_host_state_map_.find(frame_host); | 139 FrameHostToStateMap::iterator it = frame_host_state_map_.find(frame_host); |
| 140 if (it == frame_host_state_map_.end()) { | 140 if (it == frame_host_state_map_.end()) { |
| 141 NOTREACHED(); | 141 NOTREACHED(); |
| 142 return; | 142 return; |
| 143 } | 143 } |
| 144 it->second.is_navigating = false; | 144 it->second.is_loading = false; |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool FrameNavigationState::GetNavigationCompleted( | 147 bool FrameNavigationState::GetNavigationCompleted( |
| 148 content::RenderFrameHost* frame_host) const { | 148 content::RenderFrameHost* frame_host) const { |
| 149 FrameHostToStateMap::const_iterator it = | 149 FrameHostToStateMap::const_iterator it = |
| 150 frame_host_state_map_.find(frame_host); | 150 frame_host_state_map_.find(frame_host); |
| 151 DCHECK(it != frame_host_state_map_.end()); | 151 DCHECK(it != frame_host_state_map_.end()); |
|
Devlin
2016/02/05 18:30:28
We typically don't encourage coding like
if (unexp
nasko
2016/02/05 23:41:22
Unsure. It was written long ago, so probably remna
| |
| 152 return it == frame_host_state_map_.end() || !it->second.is_navigating; | 152 return it == frame_host_state_map_.end() || !it->second.is_loading; |
| 153 } | 153 } |
| 154 | 154 |
| 155 void FrameNavigationState::SetParsingFinished( | 155 void FrameNavigationState::SetParsingFinished( |
| 156 content::RenderFrameHost* frame_host) { | 156 content::RenderFrameHost* frame_host) { |
| 157 FrameHostToStateMap::iterator it = frame_host_state_map_.find(frame_host); | 157 FrameHostToStateMap::iterator it = frame_host_state_map_.find(frame_host); |
| 158 if (it == frame_host_state_map_.end()) { | 158 if (it == frame_host_state_map_.end()) { |
| 159 NOTREACHED(); | 159 NOTREACHED(); |
| 160 return; | 160 return; |
| 161 } | 161 } |
| 162 it->second.is_parsing = false; | 162 it->second.is_parsing = false; |
| 163 } | 163 } |
| 164 | 164 |
| 165 bool FrameNavigationState::GetParsingFinished( | 165 bool FrameNavigationState::GetParsingFinished( |
| 166 content::RenderFrameHost* frame_host) const { | 166 content::RenderFrameHost* frame_host) const { |
| 167 FrameHostToStateMap::const_iterator it = | 167 FrameHostToStateMap::const_iterator it = |
| 168 frame_host_state_map_.find(frame_host); | 168 frame_host_state_map_.find(frame_host); |
| 169 DCHECK(it != frame_host_state_map_.end()); | 169 DCHECK(it != frame_host_state_map_.end()); |
| 170 return it == frame_host_state_map_.end() || !it->second.is_parsing; | 170 return it == frame_host_state_map_.end() || !it->second.is_parsing; |
| 171 } | 171 } |
| 172 | 172 |
| 173 void FrameNavigationState::SetNavigationCommitted( | |
| 174 content::RenderFrameHost* frame_host) { | |
| 175 FrameHostToStateMap::iterator it = frame_host_state_map_.find(frame_host); | |
| 176 if (it == frame_host_state_map_.end()) { | |
| 177 NOTREACHED(); | |
| 178 return; | |
| 179 } | |
| 180 it->second.is_committed = true; | |
| 181 } | |
| 182 | |
| 183 bool FrameNavigationState::GetNavigationCommitted( | |
| 184 content::RenderFrameHost* frame_host) const { | |
| 185 FrameHostToStateMap::const_iterator it = | |
| 186 frame_host_state_map_.find(frame_host); | |
| 187 DCHECK(it != frame_host_state_map_.end()); | |
| 188 return it != frame_host_state_map_.end() && it->second.is_committed; | |
| 189 } | |
| 190 | |
| 191 void FrameNavigationState::SetIsServerRedirected( | |
| 192 content::RenderFrameHost* frame_host) { | |
| 193 FrameHostToStateMap::iterator it = frame_host_state_map_.find(frame_host); | |
| 194 if (it == frame_host_state_map_.end()) { | |
| 195 NOTREACHED(); | |
| 196 return; | |
| 197 } | |
| 198 it->second.is_server_redirected = true; | |
| 199 } | |
| 200 | |
| 201 bool FrameNavigationState::GetIsServerRedirected( | |
| 202 content::RenderFrameHost* frame_host) const { | |
| 203 FrameHostToStateMap::const_iterator it = | |
| 204 frame_host_state_map_.find(frame_host); | |
| 205 DCHECK(it != frame_host_state_map_.end()); | |
| 206 return it != frame_host_state_map_.end() && it->second.is_server_redirected; | |
| 207 } | |
| 208 | |
| 209 } // namespace extensions | 173 } // namespace extensions |
| OLD | NEW |