OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/sessions/core/tab_restore_service_helper.h" | 5 #include "components/sessions/core/tab_restore_service_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <iterator> | 10 #include <iterator> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 void TabRestoreServiceHelper::CreateHistoricalTab(LiveTab* live_tab, | 68 void TabRestoreServiceHelper::CreateHistoricalTab(LiveTab* live_tab, |
69 int index) { | 69 int index) { |
70 if (restoring_) | 70 if (restoring_) |
71 return; | 71 return; |
72 | 72 |
73 LiveTabContext* context = client_->FindLiveTabContextForTab(live_tab); | 73 LiveTabContext* context = client_->FindLiveTabContextForTab(live_tab); |
74 if (closing_contexts_.find(context) != closing_contexts_.end()) | 74 if (closing_contexts_.find(context) != closing_contexts_.end()) |
75 return; | 75 return; |
76 | 76 |
77 scoped_ptr<Tab> local_tab(new Tab()); | 77 std::unique_ptr<Tab> local_tab(new Tab()); |
78 PopulateTab(local_tab.get(), index, context, live_tab); | 78 PopulateTab(local_tab.get(), index, context, live_tab); |
79 if (local_tab->navigations.empty()) | 79 if (local_tab->navigations.empty()) |
80 return; | 80 return; |
81 | 81 |
82 AddEntry(local_tab.release(), true, true); | 82 AddEntry(local_tab.release(), true, true); |
83 } | 83 } |
84 | 84 |
85 void TabRestoreServiceHelper::BrowserClosing(LiveTabContext* context) { | 85 void TabRestoreServiceHelper::BrowserClosing(LiveTabContext* context) { |
86 closing_contexts_.insert(context); | 86 closing_contexts_.insert(context); |
87 | 87 |
88 scoped_ptr<Window> window(new Window()); | 88 std::unique_ptr<Window> window(new Window()); |
89 window->selected_tab_index = context->GetSelectedIndex(); | 89 window->selected_tab_index = context->GetSelectedIndex(); |
90 window->timestamp = TimeNow(); | 90 window->timestamp = TimeNow(); |
91 window->app_name = context->GetAppName(); | 91 window->app_name = context->GetAppName(); |
92 | 92 |
93 // Don't use std::vector::resize() because it will push copies of an empty tab | 93 // Don't use std::vector::resize() because it will push copies of an empty tab |
94 // into the vector, which will give all tabs in a window the same ID. | 94 // into the vector, which will give all tabs in a window the same ID. |
95 for (int i = 0; i < context->GetTabCount(); ++i) { | 95 for (int i = 0; i < context->GetTabCount(); ++i) { |
96 window->tabs.push_back(Tab()); | 96 window->tabs.push_back(Tab()); |
97 } | 97 } |
98 size_t entry_index = 0; | 98 size_t entry_index = 0; |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 tab->browser_id = new_id; | 519 tab->browser_id = new_id; |
520 } | 520 } |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 base::Time TabRestoreServiceHelper::TimeNow() const { | 524 base::Time TabRestoreServiceHelper::TimeNow() const { |
525 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now(); | 525 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now(); |
526 } | 526 } |
527 | 527 |
528 } // namespace sessions | 528 } // namespace sessions |
OLD | NEW |