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

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

Issue 10850010: Make session restore understand that tabs have multiple SessionStorageNamespaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: attempt to fix unittsets. Created 8 years, 4 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.h" 5 #include "chrome/browser/sessions/tab_restore_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <map> 9 #include <map>
10 10
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 delegate = TabRestoreServiceDelegate::Create(profile(), window->app_name); 372 delegate = TabRestoreServiceDelegate::Create(profile(), window->app_name);
373 for (size_t tab_i = 0; tab_i < window->tabs.size(); ++tab_i) { 373 for (size_t tab_i = 0; tab_i < window->tabs.size(); ++tab_i) {
374 const Tab& tab = window->tabs[tab_i]; 374 const Tab& tab = window->tabs[tab_i];
375 WebContents* restored_tab = 375 WebContents* restored_tab =
376 delegate->AddRestoredTab(tab.navigations, delegate->GetTabCount(), 376 delegate->AddRestoredTab(tab.navigations, delegate->GetTabCount(),
377 tab.current_navigation_index, 377 tab.current_navigation_index,
378 tab.extension_app_id, 378 tab.extension_app_id,
379 static_cast<int>(tab_i) == 379 static_cast<int>(tab_i) ==
380 window->selected_tab_index, 380 window->selected_tab_index,
381 tab.pinned, tab.from_last_session, 381 tab.pinned, tab.from_last_session,
382 tab.session_storage_namespace, 382 tab.session_storage_namespace_map,
383 tab.user_agent_override); 383 tab.user_agent_override);
384 if (restored_tab) { 384 if (restored_tab) {
385 restored_tab->GetController().LoadIfNecessary(); 385 restored_tab->GetController().LoadIfNecessary();
386 RecordAppLaunch(profile(), tab); 386 RecordAppLaunch(profile(), tab);
387 } 387 }
388 } 388 }
389 // All the window's tabs had the same former browser_id. 389 // All the window's tabs had the same former browser_id.
390 if (window->tabs[0].has_browser()) { 390 if (window->tabs[0].has_browser()) {
391 UpdateTabBrowserIDs(window->tabs[0].browser_id, 391 UpdateTabBrowserIDs(window->tabs[0].browser_id,
392 delegate->GetSessionID().id()); 392 delegate->GetSessionID().id());
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 const extensions::Extension* extension = 544 const extensions::Extension* extension =
545 tab_contents->extension_tab_helper()->extension_app(); 545 tab_contents->extension_tab_helper()->extension_app();
546 if (extension) 546 if (extension)
547 tab->extension_app_id = extension->id(); 547 tab->extension_app_id = extension->id();
548 } 548 }
549 549
550 tab->user_agent_override = 550 tab->user_agent_override =
551 controller->GetWebContents()->GetUserAgentOverride(); 551 controller->GetWebContents()->GetUserAgentOverride();
552 552
553 // TODO(ajwong): This does not correctly handle storage for isolated apps. 553 // TODO(ajwong): This does not correctly handle storage for isolated apps.
554 tab->session_storage_namespace = 554 tab->session_storage_namespace_map =
555 controller->GetDefaultSessionStorageNamespace(); 555 controller->GetSessionStorageNamespaceMap();
556 556
557 // Delegate may be NULL during unit tests. 557 // Delegate may be NULL during unit tests.
558 if (delegate) { 558 if (delegate) {
559 tab->browser_id = delegate->GetSessionID().id(); 559 tab->browser_id = delegate->GetSessionID().id();
560 tab->pinned = delegate->IsTabPinned(tab->tabstrip_index); 560 tab->pinned = delegate->IsTabPinned(tab->tabstrip_index);
561 } 561 }
562 } 562 }
563 563
564 void TabRestoreService::NotifyTabsChanged() { 564 void TabRestoreService::NotifyTabsChanged() {
565 FOR_EACH_OBSERVER(TabRestoreServiceObserver, observer_list_, 565 FOR_EACH_OBSERVER(TabRestoreServiceObserver, observer_list_,
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 994
995 TabRestoreServiceDelegate* TabRestoreService::RestoreTab( 995 TabRestoreServiceDelegate* TabRestoreService::RestoreTab(
996 const Tab& tab, 996 const Tab& tab,
997 TabRestoreServiceDelegate* delegate, 997 TabRestoreServiceDelegate* delegate,
998 WindowOpenDisposition disposition) { 998 WindowOpenDisposition disposition) {
999 if (disposition == CURRENT_TAB && delegate) { 999 if (disposition == CURRENT_TAB && delegate) {
1000 delegate->ReplaceRestoredTab(tab.navigations, 1000 delegate->ReplaceRestoredTab(tab.navigations,
1001 tab.current_navigation_index, 1001 tab.current_navigation_index,
1002 tab.from_last_session, 1002 tab.from_last_session,
1003 tab.extension_app_id, 1003 tab.extension_app_id,
1004 tab.session_storage_namespace, 1004 tab.session_storage_namespace_map,
1005 tab.user_agent_override); 1005 tab.user_agent_override);
1006 } else { 1006 } else {
1007 // We only respsect the tab's original browser if there's no disposition. 1007 // We only respsect the tab's original browser if there's no disposition.
1008 if (disposition == UNKNOWN && tab.has_browser()) 1008 if (disposition == UNKNOWN && tab.has_browser())
1009 delegate = TabRestoreServiceDelegate::FindDelegateWithID(tab.browser_id); 1009 delegate = TabRestoreServiceDelegate::FindDelegateWithID(tab.browser_id);
1010 1010
1011 int tab_index = -1; 1011 int tab_index = -1;
1012 1012
1013 // |delegate| will be NULL in cases where one isn't already available (eg, 1013 // |delegate| will be NULL in cases where one isn't already available (eg,
1014 // when invoked on Mac OS X with no windows open). In this case, create a 1014 // when invoked on Mac OS X with no windows open). In this case, create a
(...skipping 14 matching lines...) Expand all
1029 } 1029 }
1030 1030
1031 WebContents* web_contents = delegate->AddRestoredTab( 1031 WebContents* web_contents = delegate->AddRestoredTab(
1032 tab.navigations, 1032 tab.navigations,
1033 tab_index, 1033 tab_index,
1034 tab.current_navigation_index, 1034 tab.current_navigation_index,
1035 tab.extension_app_id, 1035 tab.extension_app_id,
1036 disposition != NEW_BACKGROUND_TAB, 1036 disposition != NEW_BACKGROUND_TAB,
1037 tab.pinned, 1037 tab.pinned,
1038 tab.from_last_session, 1038 tab.from_last_session,
1039 tab.session_storage_namespace, 1039 tab.session_storage_namespace_map,
1040 tab.user_agent_override); 1040 tab.user_agent_override);
1041 web_contents->GetController().LoadIfNecessary(); 1041 web_contents->GetController().LoadIfNecessary();
1042 } 1042 }
1043 RecordAppLaunch(profile(), tab); 1043 RecordAppLaunch(profile(), tab);
1044 return delegate; 1044 return delegate;
1045 } 1045 }
1046 1046
1047 1047
1048 bool TabRestoreService::ValidateTab(Tab* tab) { 1048 bool TabRestoreService::ValidateTab(Tab* tab) {
1049 if (tab->navigations.empty()) 1049 if (tab->navigations.empty())
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 // the front, not the end and we just added the entries to the end). 1252 // the front, not the end and we just added the entries to the end).
1253 entries_to_write_ = staging_entries_.size(); 1253 entries_to_write_ = staging_entries_.size();
1254 1254
1255 PruneEntries(); 1255 PruneEntries();
1256 NotifyTabsChanged(); 1256 NotifyTabsChanged();
1257 } 1257 }
1258 1258
1259 Time TabRestoreService::TimeNow() const { 1259 Time TabRestoreService::TimeNow() const {
1260 return time_factory_ ? time_factory_->TimeNow() : Time::Now(); 1260 return time_factory_ ? time_factory_->TimeNow() : Time::Now();
1261 } 1261 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/tab_restore_service.h ('k') | chrome/browser/sessions/tab_restore_service_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698