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 "chrome/browser/sessions/session_types.h" | 5 #include "chrome/browser/sessions/session_types.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "content/public/browser/navigation_controller.h" | 10 #include "content/public/browser/navigation_controller.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 const content::Referrer& referrer, | 25 const content::Referrer& referrer, |
26 const string16& title, | 26 const string16& title, |
27 const std::string& state, | 27 const std::string& state, |
28 content::PageTransition transition) | 28 content::PageTransition transition) |
29 : virtual_url_(virtual_url), | 29 : virtual_url_(virtual_url), |
30 referrer_(referrer), | 30 referrer_(referrer), |
31 title_(title), | 31 title_(title), |
32 state_(state), | 32 state_(state), |
33 transition_(transition), | 33 transition_(transition), |
34 type_mask_(0), | 34 type_mask_(0), |
35 post_id_(-1), | |
35 index_(index) { | 36 index_(index) { |
36 } | 37 } |
37 | 38 |
38 TabNavigation::TabNavigation(const TabNavigation& tab) | 39 TabNavigation::TabNavigation(const TabNavigation& tab) |
39 : virtual_url_(tab.virtual_url_), | 40 : virtual_url_(tab.virtual_url_), |
40 referrer_(tab.referrer_), | 41 referrer_(tab.referrer_), |
41 title_(tab.title_), | 42 title_(tab.title_), |
42 state_(tab.state_), | 43 state_(tab.state_), |
43 transition_(tab.transition_), | 44 transition_(tab.transition_), |
44 type_mask_(tab.type_mask_), | 45 type_mask_(tab.type_mask_), |
46 post_id_(-1), | |
45 index_(tab.index_) { | 47 index_(tab.index_) { |
46 } | 48 } |
47 | 49 |
48 TabNavigation::~TabNavigation() { | 50 TabNavigation::~TabNavigation() { |
49 } | 51 } |
50 | 52 |
51 TabNavigation& TabNavigation::operator=(const TabNavigation& tab) { | 53 TabNavigation& TabNavigation::operator=(const TabNavigation& tab) { |
52 virtual_url_ = tab.virtual_url_; | 54 virtual_url_ = tab.virtual_url_; |
53 referrer_ = tab.referrer_; | 55 referrer_ = tab.referrer_; |
54 title_ = tab.title_; | 56 title_ = tab.title_; |
55 state_ = tab.state_; | 57 state_ = tab.state_; |
56 transition_ = tab.transition_; | 58 transition_ = tab.transition_; |
57 type_mask_ = tab.type_mask_; | 59 type_mask_ = tab.type_mask_; |
60 post_id_ = tab.post_id_; | |
58 index_ = tab.index_; | 61 index_ = tab.index_; |
59 return *this; | 62 return *this; |
60 } | 63 } |
61 | 64 |
62 // static | 65 // static |
63 NavigationEntry* TabNavigation::ToNavigationEntry( | 66 NavigationEntry* TabNavigation::ToNavigationEntry( |
64 int page_id, Profile *profile) const { | 67 int page_id, Profile *profile) const { |
65 NavigationEntry* entry = content::NavigationController::CreateNavigationEntry( | 68 NavigationEntry* entry = content::NavigationController::CreateNavigationEntry( |
66 virtual_url_, | 69 virtual_url_, |
67 referrer_, | 70 referrer_, |
68 // Use a transition type of reload so that we don't incorrectly | 71 // Use a transition type of reload so that we don't incorrectly |
69 // increase the typed count. | 72 // increase the typed count. |
70 content::PAGE_TRANSITION_RELOAD, | 73 content::PAGE_TRANSITION_RELOAD, |
71 false, | 74 false, |
72 // The extra headers are not sync'ed across sessions. | 75 // The extra headers are not sync'ed across sessions. |
73 std::string(), | 76 std::string(), |
74 profile); | 77 profile); |
75 | 78 |
76 entry->SetPageID(page_id); | 79 entry->SetPageID(page_id); |
77 entry->SetTitle(title_); | 80 entry->SetTitle(title_); |
78 entry->SetContentState(state_); | 81 entry->SetContentState(state_); |
79 entry->SetHasPostData(type_mask_ & TabNavigation::HAS_POST_DATA); | 82 entry->SetHasPostData(type_mask_ & TabNavigation::HAS_POST_DATA); |
83 entry->SetPostID(post_id_); | |
80 | 84 |
81 return entry; | 85 return entry; |
82 } | 86 } |
83 | 87 |
84 void TabNavigation::SetFromNavigationEntry(const NavigationEntry& entry) { | 88 void TabNavigation::SetFromNavigationEntry(const NavigationEntry& entry) { |
85 virtual_url_ = entry.GetVirtualURL(); | 89 virtual_url_ = entry.GetVirtualURL(); |
86 referrer_ = entry.GetReferrer(); | 90 referrer_ = entry.GetReferrer(); |
87 title_ = entry.GetTitle(); | 91 title_ = entry.GetTitle(); |
88 state_ = entry.GetContentState(); | 92 state_ = entry.GetContentState(); |
89 transition_ = entry.GetTransitionType(); | 93 transition_ = entry.GetTransitionType(); |
90 type_mask_ = entry.GetHasPostData() ? TabNavigation::HAS_POST_DATA : 0; | 94 type_mask_ = entry.GetHasPostData() ? TabNavigation::HAS_POST_DATA : 0; |
95 post_id_ = entry.GetPostID(); | |
cbentzel
2012/02/01 22:02:13
post_id_ is explicitly not being persisted or rest
| |
91 } | 96 } |
92 | 97 |
93 // static | 98 // static |
94 void TabNavigation::CreateNavigationEntriesFromTabNavigations( | 99 void TabNavigation::CreateNavigationEntriesFromTabNavigations( |
95 Profile* profile, | 100 Profile* profile, |
96 const std::vector<TabNavigation>& navigations, | 101 const std::vector<TabNavigation>& navigations, |
97 std::vector<NavigationEntry*>* entries) { | 102 std::vector<NavigationEntry*>* entries) { |
98 int page_id = 0; | 103 int page_id = 0; |
99 for (std::vector<TabNavigation>::const_iterator i = | 104 for (std::vector<TabNavigation>::const_iterator i = |
100 navigations.begin(); i != navigations.end(); ++i, ++page_id) { | 105 navigations.begin(); i != navigations.end(); ++i, ++page_id) { |
(...skipping 17 matching lines...) Expand all Loading... | |
118 SessionWindow::SessionWindow() | 123 SessionWindow::SessionWindow() |
119 : selected_tab_index(-1), | 124 : selected_tab_index(-1), |
120 type(Browser::TYPE_TABBED), | 125 type(Browser::TYPE_TABBED), |
121 is_constrained(true), | 126 is_constrained(true), |
122 show_state(ui::SHOW_STATE_DEFAULT) { | 127 show_state(ui::SHOW_STATE_DEFAULT) { |
123 } | 128 } |
124 | 129 |
125 SessionWindow::~SessionWindow() { | 130 SessionWindow::~SessionWindow() { |
126 STLDeleteElements(&tabs); | 131 STLDeleteElements(&tabs); |
127 } | 132 } |
OLD | NEW |