OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/tab_contents/navigation_controller.h" | 5 #include "chrome/browser/tab_contents/navigation_controller.h" |
6 | 6 |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "chrome/browser/browser_about_handler.h" | 12 #include "chrome/browser/browser_about_handler.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/browser_url_handler.h" | 14 #include "chrome/browser/browser_url_handler.h" |
| 15 #include "chrome/browser/in_process_webkit/dom_storage_context.h" |
| 16 #include "chrome/browser/in_process_webkit/webkit_context.h" |
15 #include "chrome/browser/profile.h" | 17 #include "chrome/browser/profile.h" |
16 #include "chrome/browser/renderer_host/site_instance.h" | 18 #include "chrome/browser/renderer_host/site_instance.h" |
17 #include "chrome/browser/sessions/session_types.h" | 19 #include "chrome/browser/sessions/session_types.h" |
18 #include "chrome/browser/tab_contents/navigation_entry.h" | 20 #include "chrome/browser/tab_contents/navigation_entry.h" |
19 #include "chrome/browser/tab_contents/tab_contents.h" | 21 #include "chrome/browser/tab_contents/tab_contents.h" |
20 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 22 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
21 #include "chrome/common/navigation_types.h" | 23 #include "chrome/common/navigation_types.h" |
22 #include "chrome/common/notification_service.h" | 24 #include "chrome/common/notification_service.h" |
23 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
24 #include "chrome/common/pref_service.h" | 26 #include "chrome/common/pref_service.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 Profile* profile) | 128 Profile* profile) |
127 : profile_(profile), | 129 : profile_(profile), |
128 pending_entry_(NULL), | 130 pending_entry_(NULL), |
129 last_committed_entry_index_(-1), | 131 last_committed_entry_index_(-1), |
130 pending_entry_index_(-1), | 132 pending_entry_index_(-1), |
131 transient_entry_index_(-1), | 133 transient_entry_index_(-1), |
132 tab_contents_(contents), | 134 tab_contents_(contents), |
133 max_restored_page_id_(-1), | 135 max_restored_page_id_(-1), |
134 ALLOW_THIS_IN_INITIALIZER_LIST(ssl_manager_(this)), | 136 ALLOW_THIS_IN_INITIALIZER_LIST(ssl_manager_(this)), |
135 needs_reload_(false), | 137 needs_reload_(false), |
136 user_gesture_observed_(false) { | 138 user_gesture_observed_(false), |
| 139 session_storage_namespace_id_(profile->GetWebKitContext()-> |
| 140 dom_storage_context()->AllocateSessionStorageNamespaceId()) { |
137 DCHECK(profile_); | 141 DCHECK(profile_); |
138 } | 142 } |
139 | 143 |
140 NavigationController::~NavigationController() { | 144 NavigationController::~NavigationController() { |
141 DiscardNonCommittedEntriesInternal(); | 145 DiscardNonCommittedEntriesInternal(); |
142 | 146 |
143 NotificationService::current()->Notify( | 147 NotificationService::current()->Notify( |
144 NotificationType::TAB_CLOSED, | 148 NotificationType::TAB_CLOSED, |
145 Source<NavigationController>(this), | 149 Source<NavigationController>(this), |
146 NotificationService::NoDetails()); | 150 NotificationService::NoDetails()); |
| 151 |
| 152 // When we go away, the session storage namespace will no longer be reachable. |
| 153 profile_->GetWebKitContext()->DeleteSessionStorageNamespace( |
| 154 session_storage_namespace_id_); |
147 } | 155 } |
148 | 156 |
149 void NavigationController::RestoreFromState( | 157 void NavigationController::RestoreFromState( |
150 const std::vector<TabNavigation>& navigations, | 158 const std::vector<TabNavigation>& navigations, |
151 int selected_navigation, | 159 int selected_navigation, |
152 bool from_last_session) { | 160 bool from_last_session) { |
153 // Verify that this controller is unused and that the input is valid. | 161 // Verify that this controller is unused and that the input is valid. |
154 DCHECK(entry_count() == 0 && !pending_entry()); | 162 DCHECK(entry_count() == 0 && !pending_entry()); |
155 DCHECK(selected_navigation >= 0 && | 163 DCHECK(selected_navigation >= 0 && |
156 selected_navigation < static_cast<int>(navigations.size())); | 164 selected_navigation < static_cast<int>(navigations.size())); |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 | 857 |
850 if (source.entry_count() == 0) | 858 if (source.entry_count() == 0) |
851 return; // Nothing new to do. | 859 return; // Nothing new to do. |
852 | 860 |
853 needs_reload_ = true; | 861 needs_reload_ = true; |
854 for (int i = 0; i < source.entry_count(); i++) { | 862 for (int i = 0; i < source.entry_count(); i++) { |
855 entries_.push_back(linked_ptr<NavigationEntry>( | 863 entries_.push_back(linked_ptr<NavigationEntry>( |
856 new NavigationEntry(*source.entries_[i]))); | 864 new NavigationEntry(*source.entries_[i]))); |
857 } | 865 } |
858 | 866 |
| 867 session_storage_namespace_id_ = |
| 868 profile_->GetWebKitContext()->dom_storage_context()->CloneSessionStorage( |
| 869 source.session_storage_namespace_id_); |
| 870 |
859 FinishRestore(source.last_committed_entry_index_, false); | 871 FinishRestore(source.last_committed_entry_index_, false); |
860 } | 872 } |
861 | 873 |
862 void NavigationController::DiscardNonCommittedEntries() { | 874 void NavigationController::DiscardNonCommittedEntries() { |
863 bool transient = transient_entry_index_ != -1; | 875 bool transient = transient_entry_index_ != -1; |
864 DiscardNonCommittedEntriesInternal(); | 876 DiscardNonCommittedEntriesInternal(); |
865 | 877 |
866 // If there was a transient entry, invalidate everything so the new active | 878 // If there was a transient entry, invalidate everything so the new active |
867 // entry state is shown. | 879 // entry state is shown. |
868 if (transient) { | 880 if (transient) { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 return i; | 1034 return i; |
1023 } | 1035 } |
1024 return -1; | 1036 return -1; |
1025 } | 1037 } |
1026 | 1038 |
1027 NavigationEntry* NavigationController::GetTransientEntry() const { | 1039 NavigationEntry* NavigationController::GetTransientEntry() const { |
1028 if (transient_entry_index_ == -1) | 1040 if (transient_entry_index_ == -1) |
1029 return NULL; | 1041 return NULL; |
1030 return entries_[transient_entry_index_].get(); | 1042 return entries_[transient_entry_index_].get(); |
1031 } | 1043 } |
OLD | NEW |