| OLD | NEW |
| 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/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/public/browser/navigation_controller.h" | 37 #include "content/public/browser/navigation_controller.h" |
| 35 #include "content/public/browser/notification_registrar.h" | 38 #include "content/public/browser/notification_registrar.h" |
| 36 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
| 37 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
| 38 #include "content/public/browser/web_contents_view.h" | 41 #include "content/public/browser/web_contents_view.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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 base::Histogram::FactoryTimeGet( | 395 base::Histogram::FactoryTimeGet( |
| 393 time_for_count, | 396 time_for_count, |
| 394 base::TimeDelta::FromMilliseconds(10), | 397 base::TimeDelta::FromMilliseconds(10), |
| 395 base::TimeDelta::FromSeconds(100), | 398 base::TimeDelta::FromSeconds(100), |
| 396 100, | 399 100, |
| 397 base::Histogram::kUmaTargetedHistogramFlag); | 400 base::Histogram::kUmaTargetedHistogramFlag); |
| 398 counter_for_count->AddTime(time_to_load); | 401 counter_for_count->AddTime(time_to_load); |
| 399 } | 402 } |
| 400 } | 403 } |
| 401 | 404 |
| 405 void RestoreSessionStorage(WebKitContext* webkit_context, |
| 406 int64 namespace_id, |
| 407 const FilePath& session_storage_directory) { |
| 408 webkit_context->dom_storage_context()->RecreateSessionStorageNamespace( |
| 409 namespace_id, session_storage_directory); |
| 410 } |
| 411 |
| 402 // SessionRestoreImpl --------------------------------------------------------- | 412 // SessionRestoreImpl --------------------------------------------------------- |
| 403 | 413 |
| 404 // SessionRestoreImpl is responsible for fetching the set of tabs to create | 414 // SessionRestoreImpl is responsible for fetching the set of tabs to create |
| 405 // from SessionService. SessionRestoreImpl deletes itself when done. | 415 // from SessionService. SessionRestoreImpl deletes itself when done. |
| 406 | 416 |
| 407 class SessionRestoreImpl : public content::NotificationObserver { | 417 class SessionRestoreImpl : public content::NotificationObserver { |
| 408 public: | 418 public: |
| 409 SessionRestoreImpl(Profile* profile, | 419 SessionRestoreImpl(Profile* profile, |
| 410 Browser* browser, | 420 Browser* browser, |
| 411 bool synchronous, | 421 bool synchronous, |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 | 735 |
| 726 WebContents* web_contents = | 736 WebContents* web_contents = |
| 727 browser->AddRestoredTab(tab.navigations, | 737 browser->AddRestoredTab(tab.navigations, |
| 728 tab_index, | 738 tab_index, |
| 729 selected_index, | 739 selected_index, |
| 730 tab.extension_app_id, | 740 tab.extension_app_id, |
| 731 false, | 741 false, |
| 732 tab.pinned, | 742 tab.pinned, |
| 733 true, | 743 true, |
| 734 NULL); | 744 NULL); |
| 745 int64 namespace_id = |
| 746 web_contents->GetController().GetSessionStorageNamespace()->id(); |
| 747 |
| 748 content::BrowserThread::PostTask( |
| 749 content::BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, |
| 750 base::Bind(&RestoreSessionStorage, |
| 751 make_scoped_refptr( |
| 752 web_contents->GetBrowserContext()->GetWebKitContext()), |
| 753 namespace_id, tab.session_storage_directory)); |
| 754 |
| 735 if (schedule_load) | 755 if (schedule_load) |
| 736 tab_loader_->ScheduleLoad(&web_contents->GetController()); | 756 tab_loader_->ScheduleLoad(&web_contents->GetController()); |
| 737 } | 757 } |
| 738 | 758 |
| 739 Browser* CreateRestoredBrowser(Browser::Type type, | 759 Browser* CreateRestoredBrowser(Browser::Type type, |
| 740 gfx::Rect bounds, | 760 gfx::Rect bounds, |
| 741 ui::WindowShowState show_state) { | 761 ui::WindowShowState show_state) { |
| 742 Browser* browser = new Browser(type, profile_); | 762 Browser* browser = new Browser(type, profile_); |
| 743 browser->set_override_bounds(bounds); | 763 browser->set_override_bounds(bounds); |
| 744 browser->set_show_state(show_state); | 764 browser->set_show_state(show_state); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 std::vector<GURL> gurls; | 920 std::vector<GURL> gurls; |
| 901 SessionRestoreImpl restorer(profile, | 921 SessionRestoreImpl restorer(profile, |
| 902 static_cast<Browser*>(NULL), true, false, true, gurls); | 922 static_cast<Browser*>(NULL), true, false, true, gurls); |
| 903 restorer.RestoreForeignTab(tab); | 923 restorer.RestoreForeignTab(tab); |
| 904 } | 924 } |
| 905 | 925 |
| 906 // static | 926 // static |
| 907 bool SessionRestore::IsRestoring() { | 927 bool SessionRestore::IsRestoring() { |
| 908 return restoring; | 928 return restoring; |
| 909 } | 929 } |
| OLD | NEW |