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 "content/browser/tab_contents/navigation_controller.h" | 5 #include "content/browser/tab_contents/navigation_controller.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 // Invoked when entries have been pruned, or removed. For example, if the | 35 // Invoked when entries have been pruned, or removed. For example, if the |
36 // current entries are [google, digg, yahoo], with the current entry google, | 36 // current entries are [google, digg, yahoo], with the current entry google, |
37 // and the user types in cnet, then digg and yahoo are pruned. | 37 // and the user types in cnet, then digg and yahoo are pruned. |
38 void NotifyPrunedEntries(NavigationController* nav_controller, | 38 void NotifyPrunedEntries(NavigationController* nav_controller, |
39 bool from_front, | 39 bool from_front, |
40 int count) { | 40 int count) { |
41 content::PrunedDetails details; | 41 content::PrunedDetails details; |
42 details.from_front = from_front; | 42 details.from_front = from_front; |
43 details.count = count; | 43 details.count = count; |
44 NotificationService::current()->Notify( | 44 NotificationService::current()->Notify( |
45 NotificationType::NAV_LIST_PRUNED, | 45 content::NOTIFICATION_NAV_LIST_PRUNED, |
46 Source<NavigationController>(nav_controller), | 46 Source<NavigationController>(nav_controller), |
47 Details<content::PrunedDetails>(&details)); | 47 Details<content::PrunedDetails>(&details)); |
48 } | 48 } |
49 | 49 |
50 // Ensure the given NavigationEntry has a valid state, so that WebKit does not | 50 // Ensure the given NavigationEntry has a valid state, so that WebKit does not |
51 // get confused if we navigate back to it. | 51 // get confused if we navigate back to it. |
52 // | 52 // |
53 // An empty state is treated as a new navigation by WebKit, which would mean | 53 // An empty state is treated as a new navigation by WebKit, which would mean |
54 // losing the navigation entries and generating a new navigation entry after | 54 // losing the navigation entries and generating a new navigation entry after |
55 // this one. We don't want that. To avoid this we create a valid state which | 55 // this one. We don't want that. To avoid this we create a valid state which |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 if (!session_storage_namespace_) { | 126 if (!session_storage_namespace_) { |
127 session_storage_namespace_ = new SessionStorageNamespace( | 127 session_storage_namespace_ = new SessionStorageNamespace( |
128 profile_->GetWebKitContext()); | 128 profile_->GetWebKitContext()); |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 NavigationController::~NavigationController() { | 132 NavigationController::~NavigationController() { |
133 DiscardNonCommittedEntriesInternal(); | 133 DiscardNonCommittedEntriesInternal(); |
134 | 134 |
135 NotificationService::current()->Notify( | 135 NotificationService::current()->Notify( |
136 NotificationType::TAB_CLOSED, | 136 content::NOTIFICATION_TAB_CLOSED, |
137 Source<NavigationController>(this), | 137 Source<NavigationController>(this), |
138 NotificationService::NoDetails()); | 138 NotificationService::NoDetails()); |
139 } | 139 } |
140 | 140 |
141 void NavigationController::Restore( | 141 void NavigationController::Restore( |
142 int selected_navigation, | 142 int selected_navigation, |
143 bool from_last_session, | 143 bool from_last_session, |
144 std::vector<NavigationEntry*>* entries) { | 144 std::vector<NavigationEntry*>* entries) { |
145 // Verify that this controller is unused and that the input is valid. | 145 // Verify that this controller is unused and that the input is valid. |
146 DCHECK(entry_count() == 0 && !pending_entry()); | 146 DCHECK(entry_count() == 0 && !pending_entry()); |
(...skipping 29 matching lines...) Expand all Loading... |
176 if (current_index == -1) { | 176 if (current_index == -1) { |
177 return; | 177 return; |
178 } | 178 } |
179 | 179 |
180 if (check_for_repost_ && check_for_repost && | 180 if (check_for_repost_ && check_for_repost && |
181 GetEntryAtIndex(current_index)->has_post_data()) { | 181 GetEntryAtIndex(current_index)->has_post_data()) { |
182 // The user is asking to reload a page with POST data. Prompt to make sure | 182 // The user is asking to reload a page with POST data. Prompt to make sure |
183 // they really want to do this. If they do, the dialog will call us back | 183 // they really want to do this. If they do, the dialog will call us back |
184 // with check_for_repost = false. | 184 // with check_for_repost = false. |
185 NotificationService::current()->Notify( | 185 NotificationService::current()->Notify( |
186 NotificationType::REPOST_WARNING_SHOWN, | 186 content::NOTIFICATION_REPOST_WARNING_SHOWN, |
187 Source<NavigationController>(this), | 187 Source<NavigationController>(this), |
188 NotificationService::NoDetails()); | 188 NotificationService::NoDetails()); |
189 | 189 |
190 pending_reload_ = reload_type; | 190 pending_reload_ = reload_type; |
191 tab_contents_->Activate(); | 191 tab_contents_->Activate(); |
192 tab_contents_->delegate()->ShowRepostFormWarningDialog(tab_contents_); | 192 tab_contents_->delegate()->ShowRepostFormWarningDialog(tab_contents_); |
193 } else { | 193 } else { |
194 DiscardNonCommittedEntriesInternal(); | 194 DiscardNonCommittedEntriesInternal(); |
195 | 195 |
196 pending_entry_index_ = current_index; | 196 pending_entry_index_ = current_index; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 delete entry; | 263 delete entry; |
264 return; | 264 return; |
265 } | 265 } |
266 | 266 |
267 // When navigating to a new page, we don't know for sure if we will actually | 267 // When navigating to a new page, we don't know for sure if we will actually |
268 // end up leaving the current page. The new page load could for example | 268 // end up leaving the current page. The new page load could for example |
269 // result in a download or a 'no content' response (e.g., a mailto: URL). | 269 // result in a download or a 'no content' response (e.g., a mailto: URL). |
270 DiscardNonCommittedEntriesInternal(); | 270 DiscardNonCommittedEntriesInternal(); |
271 pending_entry_ = entry; | 271 pending_entry_ = entry; |
272 NotificationService::current()->Notify( | 272 NotificationService::current()->Notify( |
273 NotificationType::NAV_ENTRY_PENDING, | 273 content::NOTIFICATION_NAV_ENTRY_PENDING, |
274 Source<NavigationController>(this), | 274 Source<NavigationController>(this), |
275 NotificationService::NoDetails()); | 275 NotificationService::NoDetails()); |
276 NavigateToPendingEntry(NO_RELOAD); | 276 NavigateToPendingEntry(NO_RELOAD); |
277 } | 277 } |
278 | 278 |
279 NavigationEntry* NavigationController::GetActiveEntry() const { | 279 NavigationEntry* NavigationController::GetActiveEntry() const { |
280 if (transient_entry_index_ != -1) | 280 if (transient_entry_index_ != -1) |
281 return entries_[transient_entry_index_].get(); | 281 return entries_[transient_entry_index_].get(); |
282 if (pending_entry_) | 282 if (pending_entry_) |
283 return pending_entry_; | 283 return pending_entry_; |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 // location bar will have up-to-date information about the security style | 1054 // location bar will have up-to-date information about the security style |
1055 // when it wants to draw. See http://crbug.com/11157 | 1055 // when it wants to draw. See http://crbug.com/11157 |
1056 ssl_manager_.DidCommitProvisionalLoad(notification_details); | 1056 ssl_manager_.DidCommitProvisionalLoad(notification_details); |
1057 | 1057 |
1058 // TODO(pkasting): http://b/1113079 Probably these explicit notification paths | 1058 // TODO(pkasting): http://b/1113079 Probably these explicit notification paths |
1059 // should be removed, and interested parties should just listen for the | 1059 // should be removed, and interested parties should just listen for the |
1060 // notification below instead. | 1060 // notification below instead. |
1061 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); | 1061 tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); |
1062 | 1062 |
1063 NotificationService::current()->Notify( | 1063 NotificationService::current()->Notify( |
1064 NotificationType::NAV_ENTRY_COMMITTED, | 1064 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
1065 Source<NavigationController>(this), | 1065 Source<NavigationController>(this), |
1066 notification_details); | 1066 notification_details); |
1067 } | 1067 } |
1068 | 1068 |
1069 // static | 1069 // static |
1070 void NavigationController::DisablePromptOnRepost() { | 1070 void NavigationController::DisablePromptOnRepost() { |
1071 check_for_repost_ = false; | 1071 check_for_repost_ = false; |
1072 } | 1072 } |
1073 | 1073 |
1074 void NavigationController::SetActive(bool is_active) { | 1074 void NavigationController::SetActive(bool is_active) { |
(...skipping 10 matching lines...) Expand all Loading... |
1085 // cached state. | 1085 // cached state. |
1086 pending_entry_index_ = last_committed_entry_index_; | 1086 pending_entry_index_ = last_committed_entry_index_; |
1087 NavigateToPendingEntry(NO_RELOAD); | 1087 NavigateToPendingEntry(NO_RELOAD); |
1088 } | 1088 } |
1089 | 1089 |
1090 void NavigationController::NotifyEntryChanged(const NavigationEntry* entry, | 1090 void NavigationController::NotifyEntryChanged(const NavigationEntry* entry, |
1091 int index) { | 1091 int index) { |
1092 content::EntryChangedDetails det; | 1092 content::EntryChangedDetails det; |
1093 det.changed_entry = entry; | 1093 det.changed_entry = entry; |
1094 det.index = index; | 1094 det.index = index; |
1095 NotificationService::current()->Notify(NotificationType::NAV_ENTRY_CHANGED, | 1095 NotificationService::current()->Notify( |
| 1096 content::NOTIFICATION_NAV_ENTRY_CHANGED, |
1096 Source<NavigationController>(this), | 1097 Source<NavigationController>(this), |
1097 Details<content::EntryChangedDetails>(&det)); | 1098 Details<content::EntryChangedDetails>(&det)); |
1098 } | 1099 } |
1099 | 1100 |
1100 void NavigationController::FinishRestore(int selected_index, | 1101 void NavigationController::FinishRestore(int selected_index, |
1101 bool from_last_session) { | 1102 bool from_last_session) { |
1102 DCHECK(selected_index >= 0 && selected_index < entry_count()); | 1103 DCHECK(selected_index >= 0 && selected_index < entry_count()); |
1103 ConfigureEntriesForRestore(&entries_, from_last_session); | 1104 ConfigureEntriesForRestore(&entries_, from_last_session); |
1104 | 1105 |
1105 set_max_restored_page_id(static_cast<int32>(entry_count())); | 1106 set_max_restored_page_id(static_cast<int32>(entry_count())); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 size_t insert_index = 0; | 1149 size_t insert_index = 0; |
1149 for (int i = 0; i < max_index; i++) { | 1150 for (int i = 0; i < max_index; i++) { |
1150 // When cloning a tab, copy all entries except interstitial pages | 1151 // When cloning a tab, copy all entries except interstitial pages |
1151 if (source.entries_[i].get()->page_type() != INTERSTITIAL_PAGE) { | 1152 if (source.entries_[i].get()->page_type() != INTERSTITIAL_PAGE) { |
1152 entries_.insert(entries_.begin() + insert_index++, | 1153 entries_.insert(entries_.begin() + insert_index++, |
1153 linked_ptr<NavigationEntry>( | 1154 linked_ptr<NavigationEntry>( |
1154 new NavigationEntry(*source.entries_[i]))); | 1155 new NavigationEntry(*source.entries_[i]))); |
1155 } | 1156 } |
1156 } | 1157 } |
1157 } | 1158 } |
OLD | NEW |