Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: chrome/browser/sessions/tab_restore_service_helper.cc

Issue 1336823003: Move chrome::HostDesktopType to ui::HostDesktopType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@base_session_service_delegate_impl
Patch Set: Fix build on Mac and CrOS Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/sessions/tab_restore_service_helper.h" 5 #include "chrome/browser/sessions/tab_restore_service_helper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 NotifyTabsChanged(); 145 NotifyTabsChanged();
146 } 146 }
147 147
148 const TabRestoreService::Entries& TabRestoreServiceHelper::entries() const { 148 const TabRestoreService::Entries& TabRestoreServiceHelper::entries() const {
149 return entries_; 149 return entries_;
150 } 150 }
151 151
152 std::vector<content::WebContents*> 152 std::vector<content::WebContents*>
153 TabRestoreServiceHelper::RestoreMostRecentEntry( 153 TabRestoreServiceHelper::RestoreMostRecentEntry(
154 TabRestoreServiceDelegate* delegate, 154 TabRestoreServiceDelegate* delegate,
155 chrome::HostDesktopType host_desktop_type) { 155 ui::HostDesktopType host_desktop_type) {
156 if (entries_.empty()) 156 if (entries_.empty())
157 return std::vector<WebContents*>(); 157 return std::vector<WebContents*>();
158 158
159 return RestoreEntryById(delegate, entries_.front()->id, host_desktop_type, 159 return RestoreEntryById(delegate, entries_.front()->id, host_desktop_type,
160 UNKNOWN); 160 UNKNOWN);
161 } 161 }
162 162
163 TabRestoreService::Tab* TabRestoreServiceHelper::RemoveTabEntryById( 163 TabRestoreService::Tab* TabRestoreServiceHelper::RemoveTabEntryById(
164 SessionID::id_type id) { 164 SessionID::id_type id) {
165 Entries::iterator i = GetEntryIteratorById(id); 165 Entries::iterator i = GetEntryIteratorById(id);
166 if (i == entries_.end()) 166 if (i == entries_.end())
167 return NULL; 167 return NULL;
168 168
169 Entry* entry = *i; 169 Entry* entry = *i;
170 if (entry->type != TabRestoreService::TAB) 170 if (entry->type != TabRestoreService::TAB)
171 return NULL; 171 return NULL;
172 172
173 Tab* tab = static_cast<Tab*>(entry); 173 Tab* tab = static_cast<Tab*>(entry);
174 entries_.erase(i); 174 entries_.erase(i);
175 return tab; 175 return tab;
176 } 176 }
177 177
178 std::vector<content::WebContents*> TabRestoreServiceHelper::RestoreEntryById( 178 std::vector<content::WebContents*> TabRestoreServiceHelper::RestoreEntryById(
179 TabRestoreServiceDelegate* delegate, 179 TabRestoreServiceDelegate* delegate,
180 SessionID::id_type id, 180 SessionID::id_type id,
181 chrome::HostDesktopType host_desktop_type, 181 ui::HostDesktopType host_desktop_type,
182 WindowOpenDisposition disposition) { 182 WindowOpenDisposition disposition) {
183 Entries::iterator entry_iterator = GetEntryIteratorById(id); 183 Entries::iterator entry_iterator = GetEntryIteratorById(id);
184 if (entry_iterator == entries_.end()) 184 if (entry_iterator == entries_.end())
185 // Don't hoark here, we allow an invalid id. 185 // Don't hoark here, we allow an invalid id.
186 return std::vector<WebContents*>(); 186 return std::vector<WebContents*>();
187 187
188 if (observer_) 188 if (observer_)
189 observer_->OnRestoreEntryById(id, entry_iterator); 189 observer_->OnRestoreEntryById(id, entry_iterator);
190 restoring_ = true; 190 restoring_ = true;
191 Entry* entry = *entry_iterator; 191 Entry* entry = *entry_iterator;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 // Delegate may be NULL during unit tests. 423 // Delegate may be NULL during unit tests.
424 if (delegate) { 424 if (delegate) {
425 tab->browser_id = delegate->GetSessionID().id(); 425 tab->browser_id = delegate->GetSessionID().id();
426 tab->pinned = delegate->IsTabPinned(tab->tabstrip_index); 426 tab->pinned = delegate->IsTabPinned(tab->tabstrip_index);
427 } 427 }
428 } 428 }
429 429
430 TabRestoreServiceDelegate* TabRestoreServiceHelper::RestoreTab( 430 TabRestoreServiceDelegate* TabRestoreServiceHelper::RestoreTab(
431 const Tab& tab, 431 const Tab& tab,
432 TabRestoreServiceDelegate* delegate, 432 TabRestoreServiceDelegate* delegate,
433 chrome::HostDesktopType host_desktop_type, 433 ui::HostDesktopType host_desktop_type,
434 WindowOpenDisposition disposition, 434 WindowOpenDisposition disposition,
435 WebContents** contents) { 435 WebContents** contents) {
436 WebContents* web_contents; 436 WebContents* web_contents;
437 if (disposition == CURRENT_TAB && delegate) { 437 if (disposition == CURRENT_TAB && delegate) {
438 web_contents = delegate->ReplaceRestoredTab( 438 web_contents = delegate->ReplaceRestoredTab(
439 tab.navigations, 439 tab.navigations,
440 tab.current_navigation_index, 440 tab.current_navigation_index,
441 tab.from_last_session, 441 tab.from_last_session,
442 tab.extension_app_id, 442 tab.extension_app_id,
443 tab.session_storage_namespace.get(), 443 tab.session_storage_namespace.get(),
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 Tab* tab = static_cast<Tab*>(entry); 569 Tab* tab = static_cast<Tab*>(entry);
570 if (tab->browser_id == old_id) 570 if (tab->browser_id == old_id)
571 tab->browser_id = new_id; 571 tab->browser_id = new_id;
572 } 572 }
573 } 573 }
574 } 574 }
575 575
576 base::Time TabRestoreServiceHelper::TimeNow() const { 576 base::Time TabRestoreServiceHelper::TimeNow() const {
577 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now(); 577 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now();
578 } 578 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698