| 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 "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
| 9 #include "extensions/common/constants.h" | 9 #include "extensions/common/constants.h" |
| 10 | 10 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 bool is_iframe_srcdoc) { | 98 bool is_iframe_srcdoc) { |
| 99 FrameState& frame_state = frame_state_map_[frame_id]; | 99 FrameState& frame_state = frame_state_map_[frame_id]; |
| 100 frame_state.error_occurred = is_error_page; | 100 frame_state.error_occurred = is_error_page; |
| 101 frame_state.url = url; | 101 frame_state.url = url; |
| 102 frame_state.is_main_frame = is_main_frame; | 102 frame_state.is_main_frame = is_main_frame; |
| 103 frame_state.is_iframe_srcdoc = is_iframe_srcdoc; | 103 frame_state.is_iframe_srcdoc = is_iframe_srcdoc; |
| 104 DCHECK(!is_iframe_srcdoc || url == GURL(chrome::kAboutBlankURL)); | 104 DCHECK(!is_iframe_srcdoc || url == GURL(chrome::kAboutBlankURL)); |
| 105 frame_state.is_navigating = true; | 105 frame_state.is_navigating = true; |
| 106 frame_state.is_committed = false; | 106 frame_state.is_committed = false; |
| 107 frame_state.is_server_redirected = false; | 107 frame_state.is_server_redirected = false; |
| 108 frame_state.is_parsing = true; |
| 108 if (!is_main_frame) { | 109 if (!is_main_frame) { |
| 109 frame_state.parent_frame_num = parent_frame_id.frame_num; | 110 frame_state.parent_frame_num = parent_frame_id.frame_num; |
| 110 } else { | 111 } else { |
| 111 DCHECK(parent_frame_id.frame_num == -1); | 112 DCHECK(parent_frame_id.frame_num == -1); |
| 112 frame_state.parent_frame_num = -1; | 113 frame_state.parent_frame_num = -1; |
| 113 } | 114 } |
| 114 frame_ids_.insert(frame_id); | 115 frame_ids_.insert(frame_id); |
| 115 } | 116 } |
| 116 | 117 |
| 117 void FrameNavigationState::FrameDetached(FrameID frame_id) { | 118 void FrameNavigationState::FrameDetached(FrameID frame_id) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 frame_state_map_[frame_id].is_navigating = false; | 223 frame_state_map_[frame_id].is_navigating = false; |
| 223 } | 224 } |
| 224 | 225 |
| 225 bool FrameNavigationState::GetNavigationCompleted(FrameID frame_id) const { | 226 bool FrameNavigationState::GetNavigationCompleted(FrameID frame_id) const { |
| 226 FrameIdToStateMap::const_iterator frame_state = | 227 FrameIdToStateMap::const_iterator frame_state = |
| 227 frame_state_map_.find(frame_id); | 228 frame_state_map_.find(frame_id); |
| 228 return (frame_state == frame_state_map_.end() || | 229 return (frame_state == frame_state_map_.end() || |
| 229 !frame_state->second.is_navigating); | 230 !frame_state->second.is_navigating); |
| 230 } | 231 } |
| 231 | 232 |
| 233 void FrameNavigationState::SetParsingFinished(FrameID frame_id) { |
| 234 DCHECK(frame_state_map_.find(frame_id) != frame_state_map_.end()); |
| 235 frame_state_map_[frame_id].is_parsing = false; |
| 236 } |
| 237 |
| 238 bool FrameNavigationState::GetParsingFinished(FrameID frame_id) const { |
| 239 FrameIdToStateMap::const_iterator frame_state = |
| 240 frame_state_map_.find(frame_id); |
| 241 return (frame_state == frame_state_map_.end() || |
| 242 !frame_state->second.is_parsing); |
| 243 } |
| 244 |
| 232 void FrameNavigationState::SetNavigationCommitted(FrameID frame_id) { | 245 void FrameNavigationState::SetNavigationCommitted(FrameID frame_id) { |
| 233 DCHECK(frame_state_map_.find(frame_id) != frame_state_map_.end()); | 246 DCHECK(frame_state_map_.find(frame_id) != frame_state_map_.end()); |
| 234 frame_state_map_[frame_id].is_committed = true; | 247 frame_state_map_[frame_id].is_committed = true; |
| 235 if (frame_state_map_[frame_id].is_main_frame) | 248 if (frame_state_map_[frame_id].is_main_frame) |
| 236 main_frame_id_ = frame_id; | 249 main_frame_id_ = frame_id; |
| 237 } | 250 } |
| 238 | 251 |
| 239 bool FrameNavigationState::GetNavigationCommitted(FrameID frame_id) const { | 252 bool FrameNavigationState::GetNavigationCommitted(FrameID frame_id) const { |
| 240 FrameIdToStateMap::const_iterator frame_state = | 253 FrameIdToStateMap::const_iterator frame_state = |
| 241 frame_state_map_.find(frame_id); | 254 frame_state_map_.find(frame_id); |
| 242 return (frame_state != frame_state_map_.end() && | 255 return (frame_state != frame_state_map_.end() && |
| 243 frame_state->second.is_committed); | 256 frame_state->second.is_committed); |
| 244 } | 257 } |
| 245 | 258 |
| 246 void FrameNavigationState::SetIsServerRedirected(FrameID frame_id) { | 259 void FrameNavigationState::SetIsServerRedirected(FrameID frame_id) { |
| 247 DCHECK(frame_state_map_.find(frame_id) != frame_state_map_.end()); | 260 DCHECK(frame_state_map_.find(frame_id) != frame_state_map_.end()); |
| 248 frame_state_map_[frame_id].is_server_redirected = true; | 261 frame_state_map_[frame_id].is_server_redirected = true; |
| 249 } | 262 } |
| 250 | 263 |
| 251 bool FrameNavigationState::GetIsServerRedirected(FrameID frame_id) const { | 264 bool FrameNavigationState::GetIsServerRedirected(FrameID frame_id) const { |
| 252 FrameIdToStateMap::const_iterator frame_state = | 265 FrameIdToStateMap::const_iterator frame_state = |
| 253 frame_state_map_.find(frame_id); | 266 frame_state_map_.find(frame_id); |
| 254 return (frame_state != frame_state_map_.end() && | 267 return (frame_state != frame_state_map_.end() && |
| 255 frame_state->second.is_server_redirected); | 268 frame_state->second.is_server_redirected); |
| 256 } | 269 } |
| 257 | 270 |
| 258 } // namespace extensions | 271 } // namespace extensions |
| OLD | NEW |