Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/session_restore.h" | 5 #include "chrome/browser/sessions/session_restore.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <list> | 8 #include <list> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/sessions/session_service.h" | 23 #include "chrome/browser/sessions/session_service.h" |
| 24 #include "chrome/browser/sessions/session_service_factory.h" | 24 #include "chrome/browser/sessions/session_service_factory.h" |
| 25 #include "chrome/browser/sessions/session_types.h" | 25 #include "chrome/browser/sessions/session_types.h" |
| 26 #include "chrome/browser/tabs/tab_strip_model.h" | 26 #include "chrome/browser/tabs/tab_strip_model.h" |
| 27 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
| 28 #include "chrome/browser/ui/browser_list.h" | 28 #include "chrome/browser/ui/browser_list.h" |
| 29 #include "chrome/browser/ui/browser_navigator.h" | 29 #include "chrome/browser/ui/browser_navigator.h" |
| 30 #include "chrome/browser/ui/browser_window.h" | 30 #include "chrome/browser/ui/browser_window.h" |
| 31 #include "chrome/common/chrome_notification_types.h" | 31 #include "chrome/common/chrome_notification_types.h" |
| 32 #include "content/browser/in_process_webkit/dom_storage_namespace.h" | |
| 33 #include "content/browser/in_process_webkit/session_storage_namespace.h" | |
| 34 #include "content/browser/in_process_webkit/webkit_context.h" | |
| 32 #include "content/browser/renderer_host/render_widget_host.h" | 35 #include "content/browser/renderer_host/render_widget_host.h" |
| 33 #include "content/browser/renderer_host/render_widget_host_view.h" | 36 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 34 #include "content/browser/tab_contents/navigation_controller.h" | 37 #include "content/browser/tab_contents/navigation_controller.h" |
| 35 #include "content/browser/tab_contents/tab_contents.h" | 38 #include "content/browser/tab_contents/tab_contents.h" |
| 36 #include "content/browser/tab_contents/tab_contents_view.h" | 39 #include "content/browser/tab_contents/tab_contents_view.h" |
| 37 #include "content/public/browser/notification_registrar.h" | 40 #include "content/public/browser/notification_registrar.h" |
| 38 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
| 39 #include "net/base/network_change_notifier.h" | 42 #include "net/base/network_change_notifier.h" |
| 40 | 43 |
| 41 #if defined(OS_CHROMEOS) | 44 #if defined(OS_CHROMEOS) |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 void RestoreTabsToBrowser(const SessionWindow& window, | 686 void RestoreTabsToBrowser(const SessionWindow& window, |
| 684 Browser* browser, | 687 Browser* browser, |
| 685 int selected_tab_index) { | 688 int selected_tab_index) { |
| 686 DCHECK(!window.tabs.empty()); | 689 DCHECK(!window.tabs.empty()); |
| 687 int initial_tab_count = browser->tab_count(); | 690 int initial_tab_count = browser->tab_count(); |
| 688 for (std::vector<SessionTab*>::const_iterator i = window.tabs.begin(); | 691 for (std::vector<SessionTab*>::const_iterator i = window.tabs.begin(); |
| 689 i != window.tabs.end(); ++i) { | 692 i != window.tabs.end(); ++i) { |
| 690 const SessionTab& tab = *(*i); | 693 const SessionTab& tab = *(*i); |
| 691 const int tab_index = static_cast<int>(i - window.tabs.begin()) + | 694 const int tab_index = static_cast<int>(i - window.tabs.begin()) + |
| 692 initial_tab_count; | 695 initial_tab_count; |
| 693 // Don't schedule a load for the selected tab, as ShowBrowser() will | 696 // Don't schedule a load for the selected tab, as ShowBrowser() will |
|
michaeln
2011/12/13 20:40:03
Does this mean the navigation to the top most url
marja
2012/01/17 16:21:49
Afaics, both callers of this func, SessionRestoreI
| |
| 694 // already have done that. | 697 // already have done that. |
| 695 RestoreTab(tab, tab_index, browser, | 698 RestoreTab(tab, tab_index, browser, |
| 696 tab_index != (selected_tab_index + initial_tab_count)); | 699 tab_index != (selected_tab_index + initial_tab_count)); |
| 697 } | 700 } |
| 698 } | 701 } |
| 699 | 702 |
| 700 void RestoreTab(const SessionTab& tab, | 703 void RestoreTab(const SessionTab& tab, |
| 701 const int tab_index, | 704 const int tab_index, |
| 702 Browser* browser, | 705 Browser* browser, |
| 703 bool schedule_load) { | 706 bool schedule_load) { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 722 | 725 |
| 723 TabContents* tab_contents = | 726 TabContents* tab_contents = |
| 724 browser->AddRestoredTab(tab.navigations, | 727 browser->AddRestoredTab(tab.navigations, |
| 725 tab_index, | 728 tab_index, |
| 726 selected_index, | 729 selected_index, |
| 727 tab.extension_app_id, | 730 tab.extension_app_id, |
| 728 false, | 731 false, |
| 729 tab.pinned, | 732 tab.pinned, |
| 730 true, | 733 true, |
| 731 NULL); | 734 NULL); |
| 735 int64 namespace_id = | |
| 736 tab_contents->controller().session_storage_namespace()->id(); | |
| 737 | |
| 738 DOMStorageContext* dom_storage_context = | |
| 739 tab_contents->browser_context()->GetWebKitContext()-> | |
| 740 dom_storage_context(); | |
| 741 | |
| 742 content::BrowserThread::PostTask( | |
| 743 content::BrowserThread::WEBKIT, FROM_HERE, | |
| 744 base::Bind(&SessionRestoreImpl::RestoreSessionStorage, | |
| 745 base::Unretained(this), dom_storage_context, namespace_id, | |
|
michaeln
2011/12/13 20:40:03
what ensures 'this' is still valid when the task e
marja
2012/01/17 16:21:49
This is fixed now; WebKitContext is refcounted.
| |
| 746 tab.session_storage_directory)); | |
| 747 | |
| 732 if (schedule_load) | 748 if (schedule_load) |
| 733 tab_loader_->ScheduleLoad(&tab_contents->controller()); | 749 tab_loader_->ScheduleLoad(&tab_contents->controller()); |
| 734 } | 750 } |
| 735 | 751 |
| 752 void RestoreSessionStorage(DOMStorageContext* dom_storage_context, | |
| 753 int64 namespace_id, | |
| 754 const FilePath& session_storage_directory) { | |
| 755 dom_storage_context->RecreateSessionStorageNamespace( | |
| 756 namespace_id, session_storage_directory); | |
| 757 } | |
| 758 | |
| 736 Browser* CreateRestoredBrowser(Browser::Type type, | 759 Browser* CreateRestoredBrowser(Browser::Type type, |
| 737 gfx::Rect bounds, | 760 gfx::Rect bounds, |
| 738 ui::WindowShowState show_state) { | 761 ui::WindowShowState show_state) { |
| 739 Browser* browser = new Browser(type, profile_); | 762 Browser* browser = new Browser(type, profile_); |
| 740 browser->set_override_bounds(bounds); | 763 browser->set_override_bounds(bounds); |
| 741 browser->set_show_state(show_state); | 764 browser->set_show_state(show_state); |
| 742 browser->set_is_session_restore(true); | 765 browser->set_is_session_restore(true); |
| 743 browser->InitBrowserWindow(); | 766 browser->InitBrowserWindow(); |
| 744 return browser; | 767 return browser; |
| 745 } | 768 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 897 std::vector<GURL> gurls; | 920 std::vector<GURL> gurls; |
| 898 SessionRestoreImpl restorer(profile, | 921 SessionRestoreImpl restorer(profile, |
| 899 static_cast<Browser*>(NULL), true, false, true, gurls); | 922 static_cast<Browser*>(NULL), true, false, true, gurls); |
| 900 restorer.RestoreForeignTab(tab); | 923 restorer.RestoreForeignTab(tab); |
| 901 } | 924 } |
| 902 | 925 |
| 903 // static | 926 // static |
| 904 bool SessionRestore::IsRestoring() { | 927 bool SessionRestore::IsRestoring() { |
| 905 return restoring; | 928 return restoring; |
| 906 } | 929 } |
| OLD | NEW |