| 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/browser/tab_contents/navigation_controller.h" | 10 #include "content/browser/tab_contents/navigation_controller.h" |
| 11 #include "content/public/browser/navigation_entry.h" | 11 #include "content/public/browser/navigation_entry.h" |
| 12 | 12 |
| 13 using content::NavigationEntry; |
| 14 |
| 13 // TabNavigation -------------------------------------------------------------- | 15 // TabNavigation -------------------------------------------------------------- |
| 14 | 16 |
| 15 TabNavigation::TabNavigation() | 17 TabNavigation::TabNavigation() |
| 16 : transition_(content::PAGE_TRANSITION_TYPED), | 18 : transition_(content::PAGE_TRANSITION_TYPED), |
| 17 type_mask_(0), | 19 type_mask_(0), |
| 18 index_(-1) { | 20 index_(-1) { |
| 19 } | 21 } |
| 20 | 22 |
| 21 TabNavigation::TabNavigation(int index, | 23 TabNavigation::TabNavigation(int index, |
| 22 const GURL& virtual_url, | 24 const GURL& virtual_url, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 51 referrer_ = tab.referrer_; | 53 referrer_ = tab.referrer_; |
| 52 title_ = tab.title_; | 54 title_ = tab.title_; |
| 53 state_ = tab.state_; | 55 state_ = tab.state_; |
| 54 transition_ = tab.transition_; | 56 transition_ = tab.transition_; |
| 55 type_mask_ = tab.type_mask_; | 57 type_mask_ = tab.type_mask_; |
| 56 index_ = tab.index_; | 58 index_ = tab.index_; |
| 57 return *this; | 59 return *this; |
| 58 } | 60 } |
| 59 | 61 |
| 60 // static | 62 // static |
| 61 content::NavigationEntry* TabNavigation::ToNavigationEntry( | 63 NavigationEntry* TabNavigation::ToNavigationEntry( |
| 62 int page_id, Profile *profile) const { | 64 int page_id, Profile *profile) const { |
| 63 content::NavigationEntry* entry = NavigationController::CreateNavigationEntry( | 65 NavigationEntry* entry = NavigationController::CreateNavigationEntry( |
| 64 virtual_url_, | 66 virtual_url_, |
| 65 referrer_, | 67 referrer_, |
| 66 // Use a transition type of reload so that we don't incorrectly | 68 // Use a transition type of reload so that we don't incorrectly |
| 67 // increase the typed count. | 69 // increase the typed count. |
| 68 content::PAGE_TRANSITION_RELOAD, | 70 content::PAGE_TRANSITION_RELOAD, |
| 69 false, | 71 false, |
| 70 // The extra headers are not sync'ed across sessions. | 72 // The extra headers are not sync'ed across sessions. |
| 71 std::string(), | 73 std::string(), |
| 72 profile); | 74 profile); |
| 73 | 75 |
| 74 entry->SetPageID(page_id); | 76 entry->SetPageID(page_id); |
| 75 entry->SetTitle(title_); | 77 entry->SetTitle(title_); |
| 76 entry->SetContentState(state_); | 78 entry->SetContentState(state_); |
| 77 entry->SetHasPostData(type_mask_ & TabNavigation::HAS_POST_DATA); | 79 entry->SetHasPostData(type_mask_ & TabNavigation::HAS_POST_DATA); |
| 78 | 80 |
| 79 return entry; | 81 return entry; |
| 80 } | 82 } |
| 81 | 83 |
| 82 void TabNavigation::SetFromNavigationEntry( | 84 void TabNavigation::SetFromNavigationEntry(const NavigationEntry& entry) { |
| 83 const content::NavigationEntry& entry) { | |
| 84 virtual_url_ = entry.GetVirtualURL(); | 85 virtual_url_ = entry.GetVirtualURL(); |
| 85 referrer_ = entry.GetReferrer(); | 86 referrer_ = entry.GetReferrer(); |
| 86 title_ = entry.GetTitle(); | 87 title_ = entry.GetTitle(); |
| 87 state_ = entry.GetContentState(); | 88 state_ = entry.GetContentState(); |
| 88 transition_ = entry.GetTransitionType(); | 89 transition_ = entry.GetTransitionType(); |
| 89 type_mask_ = entry.GetHasPostData() ? TabNavigation::HAS_POST_DATA : 0; | 90 type_mask_ = entry.GetHasPostData() ? TabNavigation::HAS_POST_DATA : 0; |
| 90 } | 91 } |
| 91 | 92 |
| 92 // static | 93 // static |
| 93 void TabNavigation::CreateNavigationEntriesFromTabNavigations( | 94 void TabNavigation::CreateNavigationEntriesFromTabNavigations( |
| 94 Profile* profile, | 95 Profile* profile, |
| 95 const std::vector<TabNavigation>& navigations, | 96 const std::vector<TabNavigation>& navigations, |
| 96 std::vector<content::NavigationEntry*>* entries) { | 97 std::vector<NavigationEntry*>* entries) { |
| 97 int page_id = 0; | 98 int page_id = 0; |
| 98 for (std::vector<TabNavigation>::const_iterator i = | 99 for (std::vector<TabNavigation>::const_iterator i = |
| 99 navigations.begin(); i != navigations.end(); ++i, ++page_id) { | 100 navigations.begin(); i != navigations.end(); ++i, ++page_id) { |
| 100 entries->push_back(i->ToNavigationEntry(page_id, profile)); | 101 entries->push_back(i->ToNavigationEntry(page_id, profile)); |
| 101 } | 102 } |
| 102 } | 103 } |
| 103 | 104 |
| 104 // SessionTab ----------------------------------------------------------------- | 105 // SessionTab ----------------------------------------------------------------- |
| 105 | 106 |
| 106 SessionTab::SessionTab() | 107 SessionTab::SessionTab() |
| (...skipping 10 matching lines...) Expand all Loading... |
| 117 SessionWindow::SessionWindow() | 118 SessionWindow::SessionWindow() |
| 118 : selected_tab_index(-1), | 119 : selected_tab_index(-1), |
| 119 type(Browser::TYPE_TABBED), | 120 type(Browser::TYPE_TABBED), |
| 120 is_constrained(true), | 121 is_constrained(true), |
| 121 show_state(ui::SHOW_STATE_DEFAULT) { | 122 show_state(ui::SHOW_STATE_DEFAULT) { |
| 122 } | 123 } |
| 123 | 124 |
| 124 SessionWindow::~SessionWindow() { | 125 SessionWindow::~SessionWindow() { |
| 125 STLDeleteElements(&tabs); | 126 STLDeleteElements(&tabs); |
| 126 } | 127 } |
| OLD | NEW |