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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 bool select) { | 78 bool select) { |
79 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); | 79 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
80 entry->SetURL(navigation.virtual_url()); | 80 entry->SetURL(navigation.virtual_url()); |
81 entry->SetReferrer(navigation.referrer()); | 81 entry->SetReferrer(navigation.referrer()); |
82 entry->SetTitle(navigation.title()); | 82 entry->SetTitle(navigation.title()); |
83 entry->SetContentState(navigation.state()); | 83 entry->SetContentState(navigation.state()); |
84 entry->SetTransitionType(navigation.transition()); | 84 entry->SetTransitionType(navigation.transition()); |
85 entry->SetHasPostData( | 85 entry->SetHasPostData( |
86 navigation.type_mask() & TabNavigation::HAS_POST_DATA); | 86 navigation.type_mask() & TabNavigation::HAS_POST_DATA); |
87 entry->SetOriginalRequestURL(navigation.original_request_url()); | 87 entry->SetOriginalRequestURL(navigation.original_request_url()); |
| 88 entry->SetOverrideUserAgent(navigation.override_user_agent()); |
88 service()->UpdateTabNavigation(window_id, tab_id, index, *entry.get()); | 89 service()->UpdateTabNavigation(window_id, tab_id, index, *entry.get()); |
89 if (select) | 90 if (select) |
90 service()->SetSelectedNavigationIndex(window_id, tab_id, index); | 91 service()->SetSelectedNavigationIndex(window_id, tab_id, index); |
91 } | 92 } |
92 | 93 |
93 void ReadWindows(std::vector<SessionWindow*>* windows) { | 94 void ReadWindows(std::vector<SessionWindow*>* windows) { |
94 // Forces closing the file. | 95 // Forces closing the file. |
95 helper_.set_service(NULL); | 96 helper_.set_service(NULL); |
96 | 97 |
97 SessionService* session_service = new SessionService(path_); | 98 SessionService* session_service = new SessionService(path_); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 TEST_F(SessionServiceTest, Basic) { | 154 TEST_F(SessionServiceTest, Basic) { |
154 SessionID tab_id; | 155 SessionID tab_id; |
155 ASSERT_NE(window_id.id(), tab_id.id()); | 156 ASSERT_NE(window_id.id(), tab_id.id()); |
156 | 157 |
157 TabNavigation nav1(0, GURL("http://google.com"), | 158 TabNavigation nav1(0, GURL("http://google.com"), |
158 content::Referrer(GURL("http://www.referrer.com"), | 159 content::Referrer(GURL("http://www.referrer.com"), |
159 WebKit::WebReferrerPolicyDefault), | 160 WebKit::WebReferrerPolicyDefault), |
160 ASCIIToUTF16("abc"), "def", | 161 ASCIIToUTF16("abc"), "def", |
161 content::PAGE_TRANSITION_QUALIFIER_MASK); | 162 content::PAGE_TRANSITION_QUALIFIER_MASK); |
162 nav1.set_original_request_url(GURL("http://original.request.com")); | 163 nav1.set_original_request_url(GURL("http://original.request.com")); |
| 164 nav1.set_override_user_agent(true); |
163 | 165 |
164 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); | 166 helper_.PrepareTabInWindow(window_id, tab_id, 0, true); |
165 UpdateNavigation(window_id, tab_id, nav1, 0, true); | 167 UpdateNavigation(window_id, tab_id, nav1, 0, true); |
166 | 168 |
167 ScopedVector<SessionWindow> windows; | 169 ScopedVector<SessionWindow> windows; |
168 ReadWindows(&(windows.get())); | 170 ReadWindows(&(windows.get())); |
169 | 171 |
170 ASSERT_EQ(1U, windows->size()); | 172 ASSERT_EQ(1U, windows->size()); |
171 ASSERT_TRUE(window_bounds == windows[0]->bounds); | 173 ASSERT_TRUE(window_bounds == windows[0]->bounds); |
172 ASSERT_EQ(0, windows[0]->selected_tab_index); | 174 ASSERT_EQ(0, windows[0]->selected_tab_index); |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 ASSERT_TRUE(file_util::CopyFile(v1_file_path, dest_file_path)); | 878 ASSERT_TRUE(file_util::CopyFile(v1_file_path, dest_file_path)); |
877 | 879 |
878 SessionService* session_service = new SessionService(path_); | 880 SessionService* session_service = new SessionService(path_); |
879 helper_.set_service(session_service); | 881 helper_.set_service(session_service); |
880 ScopedVector<SessionWindow> windows; | 882 ScopedVector<SessionWindow> windows; |
881 helper_.ReadWindows(&(windows.get())); | 883 helper_.ReadWindows(&(windows.get())); |
882 ASSERT_EQ(1u, windows.size()); | 884 ASSERT_EQ(1u, windows.size()); |
883 EXPECT_EQ(1u, windows[0]->tabs.size()); | 885 EXPECT_EQ(1u, windows[0]->tabs.size()); |
884 } | 886 } |
885 #endif | 887 #endif |
OLD | NEW |