| 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 "android_webview/native/state_serializer.h" | 5 #include "android_webview/native/state_serializer.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/scoped_vector.h" | |
| 10 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 11 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 12 #include "content/public/browser/child_process_security_policy.h" | 11 #include "content/public/browser/child_process_security_policy.h" |
| 13 #include "content/public/browser/navigation_controller.h" | 12 #include "content/public/browser/navigation_controller.h" |
| 14 #include "content/public/browser/navigation_entry.h" | 13 #include "content/public/browser/navigation_entry.h" |
| 15 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
| 16 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/common/page_state.h" | 16 #include "content/public/common/page_state.h" |
| 18 | 17 |
| 19 // Reasons for not re-using TabNavigation under chrome/ as of 20121116: | 18 // Reasons for not re-using TabNavigation under chrome/ as of 20121116: |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 if (!iterator->ReadInt(&selected_entry)) | 87 if (!iterator->ReadInt(&selected_entry)) |
| 89 return false; | 88 return false; |
| 90 | 89 |
| 91 if (entry_count < 0) | 90 if (entry_count < 0) |
| 92 return false; | 91 return false; |
| 93 if (selected_entry < -1) | 92 if (selected_entry < -1) |
| 94 return false; | 93 return false; |
| 95 if (selected_entry >= entry_count) | 94 if (selected_entry >= entry_count) |
| 96 return false; | 95 return false; |
| 97 | 96 |
| 98 ScopedVector<content::NavigationEntry> restored_entries; | 97 std::vector<scoped_ptr<content::NavigationEntry>> entries; |
| 98 entries.reserve(entry_count); |
| 99 for (int i = 0; i < entry_count; ++i) { | 99 for (int i = 0; i < entry_count; ++i) { |
| 100 restored_entries.push_back(content::NavigationEntry::Create()); | 100 entries.push_back(content::NavigationEntry::Create()); |
| 101 if (!internal::RestoreNavigationEntryFromPickle(iterator, | 101 if (!internal::RestoreNavigationEntryFromPickle(iterator, entries[i].get())) |
| 102 restored_entries[i])) | |
| 103 return false; | 102 return false; |
| 104 | 103 |
| 105 restored_entries[i]->SetPageID(i); | 104 entries[i]->SetPageID(i); |
| 106 } | 105 } |
| 107 | 106 |
| 108 // |web_contents| takes ownership of these entries after this call. | 107 // |web_contents| takes ownership of these entries after this call. |
| 109 content::NavigationController& controller = web_contents->GetController(); | 108 content::NavigationController& controller = web_contents->GetController(); |
| 110 controller.Restore( | 109 controller.Restore( |
| 111 selected_entry, | 110 selected_entry, |
| 112 content::NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, | 111 content::NavigationController::RESTORE_LAST_SESSION_EXITED_CLEANLY, |
| 113 &restored_entries); | 112 &entries); |
| 114 DCHECK_EQ(0u, restored_entries.size()); | 113 DCHECK_EQ(0u, entries.size()); |
| 115 | 114 |
| 116 if (controller.GetLastCommittedEntry()) { | 115 if (controller.GetLastCommittedEntry()) { |
| 117 // Set up the file access rights for the selected navigation entry. | 116 // Set up the file access rights for the selected navigation entry. |
| 118 // TODO(joth): This is duplicated from chrome/.../session_restore.cc and | 117 // TODO(joth): This is duplicated from chrome/.../session_restore.cc and |
| 119 // should be shared e.g. in NavigationController. http://crbug.com/68222 | 118 // should be shared e.g. in NavigationController. http://crbug.com/68222 |
| 120 const int id = web_contents->GetRenderProcessHost()->GetID(); | 119 const int id = web_contents->GetRenderProcessHost()->GetID(); |
| 121 const content::PageState& page_state = | 120 const content::PageState& page_state = |
| 122 controller.GetLastCommittedEntry()->GetPageState(); | 121 controller.GetLastCommittedEntry()->GetPageState(); |
| 123 const std::vector<base::FilePath>& file_paths = | 122 const std::vector<base::FilePath>& file_paths = |
| 124 page_state.GetReferencedFiles(); | 123 page_state.GetReferencedFiles(); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 return false; | 280 return false; |
| 282 entry->SetHttpStatusCode(http_status_code); | 281 entry->SetHttpStatusCode(http_status_code); |
| 283 } | 282 } |
| 284 | 283 |
| 285 return true; | 284 return true; |
| 286 } | 285 } |
| 287 | 286 |
| 288 } // namespace internal | 287 } // namespace internal |
| 289 | 288 |
| 290 } // namespace android_webview | 289 } // namespace android_webview |
| OLD | NEW |