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

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

Issue 16290004: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
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 "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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 Window* window = static_cast<Window*>(entry); 227 Window* window = static_cast<Window*>(entry);
228 228
229 // When restoring a window, either the entire window can be restored, or a 229 // When restoring a window, either the entire window can be restored, or a
230 // single tab within it. If the entry's ID matches the one to restore, then 230 // single tab within it. If the entry's ID matches the one to restore, then
231 // the entire window will be restored. 231 // the entire window will be restored.
232 if (!restoring_tab_in_window) { 232 if (!restoring_tab_in_window) {
233 delegate = TabRestoreServiceDelegate::Create(profile_, host_desktop_type, 233 delegate = TabRestoreServiceDelegate::Create(profile_, host_desktop_type,
234 window->app_name); 234 window->app_name);
235 for (size_t tab_i = 0; tab_i < window->tabs.size(); ++tab_i) { 235 for (size_t tab_i = 0; tab_i < window->tabs.size(); ++tab_i) {
236 const Tab& tab = window->tabs[tab_i]; 236 const Tab& tab = window->tabs[tab_i];
237 WebContents* restored_tab = 237 WebContents* restored_tab = delegate->AddRestoredTab(
238 delegate->AddRestoredTab(tab.navigations, delegate->GetTabCount(), 238 tab.navigations,
239 tab.current_navigation_index, 239 delegate->GetTabCount(),
240 tab.extension_app_id, 240 tab.current_navigation_index,
241 static_cast<int>(tab_i) == 241 tab.extension_app_id,
242 window->selected_tab_index, 242 static_cast<int>(tab_i) == window->selected_tab_index,
243 tab.pinned, tab.from_last_session, 243 tab.pinned,
244 tab.session_storage_namespace, 244 tab.from_last_session,
245 tab.user_agent_override); 245 tab.session_storage_namespace.get(),
246 tab.user_agent_override);
246 if (restored_tab) { 247 if (restored_tab) {
247 restored_tab->GetController().LoadIfNecessary(); 248 restored_tab->GetController().LoadIfNecessary();
248 RecordAppLaunch(profile_, tab); 249 RecordAppLaunch(profile_, tab);
249 } 250 }
250 } 251 }
251 // All the window's tabs had the same former browser_id. 252 // All the window's tabs had the same former browser_id.
252 if (window->tabs[0].has_browser()) { 253 if (window->tabs[0].has_browser()) {
253 UpdateTabBrowserIDs(window->tabs[0].browser_id, 254 UpdateTabBrowserIDs(window->tabs[0].browser_id,
254 delegate->GetSessionID().id()); 255 delegate->GetSessionID().id());
255 } 256 }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 TabRestoreServiceDelegate* TabRestoreServiceHelper::RestoreTab( 433 TabRestoreServiceDelegate* TabRestoreServiceHelper::RestoreTab(
433 const Tab& tab, 434 const Tab& tab,
434 TabRestoreServiceDelegate* delegate, 435 TabRestoreServiceDelegate* delegate,
435 chrome::HostDesktopType host_desktop_type, 436 chrome::HostDesktopType host_desktop_type,
436 WindowOpenDisposition disposition) { 437 WindowOpenDisposition disposition) {
437 if (disposition == CURRENT_TAB && delegate) { 438 if (disposition == CURRENT_TAB && delegate) {
438 delegate->ReplaceRestoredTab(tab.navigations, 439 delegate->ReplaceRestoredTab(tab.navigations,
439 tab.current_navigation_index, 440 tab.current_navigation_index,
440 tab.from_last_session, 441 tab.from_last_session,
441 tab.extension_app_id, 442 tab.extension_app_id,
442 tab.session_storage_namespace, 443 tab.session_storage_namespace.get(),
443 tab.user_agent_override); 444 tab.user_agent_override);
444 } else { 445 } else {
445 // We only respsect the tab's original browser if there's no disposition. 446 // We only respsect the tab's original browser if there's no disposition.
446 if (disposition == UNKNOWN && tab.has_browser()) { 447 if (disposition == UNKNOWN && tab.has_browser()) {
447 delegate = TabRestoreServiceDelegate::FindDelegateWithID( 448 delegate = TabRestoreServiceDelegate::FindDelegateWithID(
448 tab.browser_id, host_desktop_type); 449 tab.browser_id, host_desktop_type);
449 } 450 }
450 451
451 int tab_index = -1; 452 int tab_index = -1;
452 453
453 // |delegate| will be NULL in cases where one isn't already available (eg, 454 // |delegate| will be NULL in cases where one isn't already available (eg,
454 // when invoked on Mac OS X with no windows open). In this case, create a 455 // when invoked on Mac OS X with no windows open). In this case, create a
455 // new browser into which we restore the tabs. 456 // new browser into which we restore the tabs.
456 if (delegate && disposition != NEW_WINDOW) { 457 if (delegate && disposition != NEW_WINDOW) {
457 tab_index = tab.tabstrip_index; 458 tab_index = tab.tabstrip_index;
458 } else { 459 } else {
459 delegate = TabRestoreServiceDelegate::Create(profile_, host_desktop_type, 460 delegate = TabRestoreServiceDelegate::Create(profile_, host_desktop_type,
460 std::string()); 461 std::string());
461 if (tab.has_browser()) 462 if (tab.has_browser())
462 UpdateTabBrowserIDs(tab.browser_id, delegate->GetSessionID().id()); 463 UpdateTabBrowserIDs(tab.browser_id, delegate->GetSessionID().id());
463 } 464 }
464 465
465 // Place the tab at the end if the tab index is no longer valid or 466 // Place the tab at the end if the tab index is no longer valid or
466 // we were passed a specific disposition. 467 // we were passed a specific disposition.
467 if (tab_index < 0 || tab_index > delegate->GetTabCount() || 468 if (tab_index < 0 || tab_index > delegate->GetTabCount() ||
468 disposition != UNKNOWN) { 469 disposition != UNKNOWN) {
469 tab_index = delegate->GetTabCount(); 470 tab_index = delegate->GetTabCount();
470 } 471 }
471 472
472 WebContents* web_contents = delegate->AddRestoredTab( 473 WebContents* web_contents =
473 tab.navigations, 474 delegate->AddRestoredTab(tab.navigations,
474 tab_index, 475 tab_index,
475 tab.current_navigation_index, 476 tab.current_navigation_index,
476 tab.extension_app_id, 477 tab.extension_app_id,
477 disposition != NEW_BACKGROUND_TAB, 478 disposition != NEW_BACKGROUND_TAB,
478 tab.pinned, 479 tab.pinned,
479 tab.from_last_session, 480 tab.from_last_session,
480 tab.session_storage_namespace, 481 tab.session_storage_namespace.get(),
481 tab.user_agent_override); 482 tab.user_agent_override);
482 web_contents->GetController().LoadIfNecessary(); 483 web_contents->GetController().LoadIfNecessary();
483 } 484 }
484 RecordAppLaunch(profile_, tab); 485 RecordAppLaunch(profile_, tab);
485 return delegate; 486 return delegate;
486 } 487 }
487 488
488 489
489 bool TabRestoreServiceHelper::ValidateTab(Tab* tab) { 490 bool TabRestoreServiceHelper::ValidateTab(Tab* tab) {
490 if (tab->navigations.empty()) 491 if (tab->navigations.empty())
491 return false; 492 return false;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 Tab* tab = static_cast<Tab*>(entry); 567 Tab* tab = static_cast<Tab*>(entry);
567 if (tab->browser_id == old_id) 568 if (tab->browser_id == old_id)
568 tab->browser_id = new_id; 569 tab->browser_id = new_id;
569 } 570 }
570 } 571 }
571 } 572 }
572 573
573 base::Time TabRestoreServiceHelper::TimeNow() const { 574 base::Time TabRestoreServiceHelper::TimeNow() const {
574 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now(); 575 return time_factory_ ? time_factory_->TimeNow() : base::Time::Now();
575 } 576 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/base_session_service.h ('k') | chrome/browser/signin/oauth2_token_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698