| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/persistent_tab_restore_service.h" | 5 #include "chrome/browser/sessions/persistent_tab_restore_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 window_id, tab_id, | 139 window_id, tab_id, |
| 140 SerializedNavigationEntryTestHelper::CreateNavigation( | 140 SerializedNavigationEntryTestHelper::CreateNavigation( |
| 141 url1_.spec(), "title")); | 141 url1_.spec(), "title")); |
| 142 } | 142 } |
| 143 | 143 |
| 144 // Creates a SessionService and assigns it to the Profile. The SessionService | 144 // Creates a SessionService and assigns it to the Profile. The SessionService |
| 145 // is configured with a single window with a single tab pointing at url1_ by | 145 // is configured with a single window with a single tab pointing at url1_ by |
| 146 // way of AddWindowWithOneTabToSessionService. If |pinned| is true, the | 146 // way of AddWindowWithOneTabToSessionService. If |pinned| is true, the |
| 147 // tab is marked as pinned in the session service. | 147 // tab is marked as pinned in the session service. |
| 148 void CreateSessionServiceWithOneWindow(bool pinned) { | 148 void CreateSessionServiceWithOneWindow(bool pinned) { |
| 149 // The profile takes ownership of this. | 149 scoped_ptr<SessionService> session_service(new SessionService(profile())); |
| 150 SessionService* session_service = new SessionService(profile()); | 150 SessionServiceFactory::SetForTestProfile(profile(), session_service.Pass()); |
| 151 SessionServiceFactory::SetForTestProfile(profile(), session_service); | |
| 152 | 151 |
| 153 AddWindowWithOneTabToSessionService(pinned); | 152 AddWindowWithOneTabToSessionService(pinned); |
| 154 | 153 |
| 155 // Set this, otherwise previous session won't be loaded. | 154 // Set this, otherwise previous session won't be loaded. |
| 156 profile()->set_last_session_exited_cleanly(false); | 155 profile()->set_last_session_exited_cleanly(false); |
| 157 } | 156 } |
| 158 | 157 |
| 159 void SynchronousLoadTabsFromLastSession() { | 158 void SynchronousLoadTabsFromLastSession() { |
| 160 // Ensures that the load is complete before continuing. | 159 // Ensures that the load is complete before continuing. |
| 161 service_->LoadTabsFromLastSession(); | 160 service_->LoadTabsFromLastSession(); |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 | 754 |
| 756 EXPECT_FALSE(service_->IsLoaded()); | 755 EXPECT_FALSE(service_->IsLoaded()); |
| 757 TestTabRestoreServiceObserver observer; | 756 TestTabRestoreServiceObserver observer; |
| 758 service_->AddObserver(&observer); | 757 service_->AddObserver(&observer); |
| 759 EXPECT_EQ(max_entries, service_->entries().size()); | 758 EXPECT_EQ(max_entries, service_->entries().size()); |
| 760 SynchronousLoadTabsFromLastSession(); | 759 SynchronousLoadTabsFromLastSession(); |
| 761 EXPECT_TRUE(observer.got_loaded()); | 760 EXPECT_TRUE(observer.got_loaded()); |
| 762 EXPECT_TRUE(service_->IsLoaded()); | 761 EXPECT_TRUE(service_->IsLoaded()); |
| 763 service_->RemoveObserver(&observer); | 762 service_->RemoveObserver(&observer); |
| 764 } | 763 } |
| OLD | NEW |