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

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

Issue 10832080: Upstream session_backend_android. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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
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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 return; 442 return;
443 443
444 #if !defined(ENABLE_SESSION_SERVICE) 444 #if !defined(ENABLE_SESSION_SERVICE)
445 // If sessions are not stored in the SessionService, default to 445 // If sessions are not stored in the SessionService, default to
446 // |LOADED_LAST_SESSION| state. 446 // |LOADED_LAST_SESSION| state.
447 load_state_ = LOADING | LOADED_LAST_SESSION; 447 load_state_ = LOADING | LOADED_LAST_SESSION;
448 #else 448 #else
449 load_state_ = LOADING; 449 load_state_ = LOADING;
450 450
451 SessionService* session_service = 451 SessionService* session_service =
452 #if defined(OS_ANDROID)
453 // For Android we do not store sessions in the SessionService.
454 NULL;
455 #else
452 SessionServiceFactory::GetForProfile(profile()); 456 SessionServiceFactory::GetForProfile(profile());
sky 2012/07/31 15:26:09 CAn you instead make GetForPRofile return NULL alw
felipeg 2012/08/01 16:00:58 Done.
457 #endif
453 if (!profile()->restored_last_session() && 458 if (!profile()->restored_last_session() &&
454 !profile()->DidLastSessionExitCleanly() && 459 !profile()->DidLastSessionExitCleanly() &&
455 session_service) { 460 session_service) {
456 // The previous session crashed and wasn't restored. Load the tabs/windows 461 // The previous session crashed and wasn't restored. Load the tabs/windows
457 // that were open at the point of crash from the session service. 462 // that were open at the point of crash from the session service.
458 session_service->GetLastSession( 463 session_service->GetLastSession(
459 &crash_consumer_, 464 &crash_consumer_,
460 base::Bind(&TabRestoreService::OnGotPreviousSession, 465 base::Bind(&TabRestoreService::OnGotPreviousSession,
461 base::Unretained(this))); 466 base::Unretained(this)));
462 } else { 467 } else {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 NavigationEntry* entry = (i == pending_index) ? 534 NavigationEntry* entry = (i == pending_index) ?
530 controller->GetPendingEntry() : controller->GetEntryAtIndex(i); 535 controller->GetPendingEntry() : controller->GetEntryAtIndex(i);
531 tab->navigations[i].SetFromNavigationEntry(*entry); 536 tab->navigations[i].SetFromNavigationEntry(*entry);
532 } 537 }
533 tab->timestamp = TimeNow(); 538 tab->timestamp = TimeNow();
534 tab->current_navigation_index = controller->GetCurrentEntryIndex(); 539 tab->current_navigation_index = controller->GetCurrentEntryIndex();
535 if (tab->current_navigation_index == -1 && entry_count > 0) 540 if (tab->current_navigation_index == -1 && entry_count > 0)
536 tab->current_navigation_index = 0; 541 tab->current_navigation_index = 0;
537 tab->tabstrip_index = index; 542 tab->tabstrip_index = index;
538 543
544 #if !defined(OS_ANDROID)
sky 2012/07/31 15:26:09 Isn't there a more specific ifdef for extensions?
felipeg 2012/08/01 16:00:58 Yaron is taking care of extensions (adding him to
539 TabContents* tab_contents = 545 TabContents* tab_contents =
540 TabContents::FromWebContents(controller->GetWebContents()); 546 TabContents::FromWebContents(controller->GetWebContents());
541 // tab_contents is NULL in some browser tests. 547 // tab_contents is NULL in some browser tests.
542 if (tab_contents) { 548 if (tab_contents) {
543 const extensions::Extension* extension = 549 const extensions::Extension* extension =
544 tab_contents->extension_tab_helper()->extension_app(); 550 tab_contents->extension_tab_helper()->extension_app();
545 if (extension) 551 if (extension)
546 tab->extension_app_id = extension->id(); 552 tab->extension_app_id = extension->id();
547 } 553 }
554 #endif
548 555
549 tab->session_storage_namespace = controller->GetSessionStorageNamespace(); 556 tab->session_storage_namespace = controller->GetSessionStorageNamespace();
550 557
551 // Delegate may be NULL during unit tests. 558 // Delegate may be NULL during unit tests.
552 if (delegate) { 559 if (delegate) {
553 tab->browser_id = delegate->GetSessionID().id(); 560 tab->browser_id = delegate->GetSessionID().id();
554 tab->pinned = delegate->IsTabPinned(tab->tabstrip_index); 561 tab->pinned = delegate->IsTabPinned(tab->tabstrip_index);
555 } 562 }
556 } 563 }
557 564
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 // the front, not the end and we just added the entries to the end). 1251 // the front, not the end and we just added the entries to the end).
1245 entries_to_write_ = staging_entries_.size(); 1252 entries_to_write_ = staging_entries_.size();
1246 1253
1247 PruneEntries(); 1254 PruneEntries();
1248 NotifyTabsChanged(); 1255 NotifyTabsChanged();
1249 } 1256 }
1250 1257
1251 Time TabRestoreService::TimeNow() const { 1258 Time TabRestoreService::TimeNow() const {
1252 return time_factory_ ? time_factory_->TimeNow() : Time::Now(); 1259 return time_factory_ ? time_factory_->TimeNow() : Time::Now();
1253 } 1260 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698