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_service.h" | 5 #include "chrome/browser/sessions/session_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "chrome/browser/tabs/tab_strip_model.h" | 26 #include "chrome/browser/tabs/tab_strip_model.h" |
27 #include "chrome/browser/ui/browser_init.h" | 27 #include "chrome/browser/ui/browser_init.h" |
28 #include "chrome/browser/ui/browser_list.h" | 28 #include "chrome/browser/ui/browser_list.h" |
29 #include "chrome/browser/ui/browser_window.h" | 29 #include "chrome/browser/ui/browser_window.h" |
30 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 30 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
31 #include "chrome/common/chrome_notification_types.h" | 31 #include "chrome/common/chrome_notification_types.h" |
32 #include "chrome/common/extensions/extension.h" | 32 #include "chrome/common/extensions/extension.h" |
33 #include "content/browser/tab_contents/navigation_details.h" | 33 #include "content/browser/tab_contents/navigation_details.h" |
34 #include "content/browser/tab_contents/navigation_entry.h" | 34 #include "content/browser/tab_contents/navigation_entry.h" |
35 #include "content/browser/tab_contents/tab_contents.h" | 35 #include "content/browser/tab_contents/tab_contents.h" |
36 #include "content/common/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
37 #include "content/public/browser/notification_details.h" | 37 #include "content/public/browser/notification_details.h" |
38 | 38 |
39 #if defined(OS_MACOSX) | 39 #if defined(OS_MACOSX) |
40 #include "chrome/browser/app_controller_cppsafe_mac.h" | 40 #include "chrome/browser/app_controller_cppsafe_mac.h" |
41 #endif | 41 #endif |
42 | 42 |
43 using base::Time; | 43 using base::Time; |
44 | 44 |
45 // Identifier for commands written to file. | 45 // Identifier for commands written to file. |
46 static const SessionCommand::id_type kCommandSetTabWindow = 0; | 46 static const SessionCommand::id_type kCommandSetTabWindow = 0; |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 } | 451 } |
452 } | 452 } |
453 | 453 |
454 void SessionService::Save() { | 454 void SessionService::Save() { |
455 bool had_commands = !pending_commands().empty(); | 455 bool had_commands = !pending_commands().empty(); |
456 BaseSessionService::Save(); | 456 BaseSessionService::Save(); |
457 if (had_commands) { | 457 if (had_commands) { |
458 RecordSessionUpdateHistogramData( | 458 RecordSessionUpdateHistogramData( |
459 chrome::NOTIFICATION_SESSION_SERVICE_SAVED, | 459 chrome::NOTIFICATION_SESSION_SERVICE_SAVED, |
460 &last_updated_save_time_); | 460 &last_updated_save_time_); |
461 NotificationService::current()->Notify( | 461 content::NotificationService::current()->Notify( |
462 chrome::NOTIFICATION_SESSION_SERVICE_SAVED, | 462 chrome::NOTIFICATION_SESSION_SERVICE_SAVED, |
463 content::Source<Profile>(profile()), | 463 content::Source<Profile>(profile()), |
464 NotificationService::NoDetails()); | 464 content::NotificationService::NoDetails()); |
465 } | 465 } |
466 } | 466 } |
467 | 467 |
468 void SessionService::Init() { | 468 void SessionService::Init() { |
469 // Register for the notifications we're interested in. | 469 // Register for the notifications we're interested in. |
470 registrar_.Add(this, content::NOTIFICATION_TAB_PARENTED, | 470 registrar_.Add(this, content::NOTIFICATION_TAB_PARENTED, |
471 NotificationService::AllSources()); | 471 content::NotificationService::AllSources()); |
472 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, | 472 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, |
473 NotificationService::AllSources()); | 473 content::NotificationService::AllSources()); |
474 registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED, | 474 registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED, |
475 NotificationService::AllSources()); | 475 content::NotificationService::AllSources()); |
476 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_CHANGED, | 476 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_CHANGED, |
477 NotificationService::AllSources()); | 477 content::NotificationService::AllSources()); |
478 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 478 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
479 NotificationService::AllSources()); | 479 content::NotificationService::AllSources()); |
480 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED, | 480 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED, |
481 NotificationService::AllBrowserContextsAndSources()); | 481 content::NotificationService::AllBrowserContextsAndSources()); |
482 registrar_.Add( | 482 registrar_.Add( |
483 this, chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED, | 483 this, chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED, |
484 NotificationService::AllSources()); | 484 content::NotificationService::AllSources()); |
485 } | 485 } |
486 | 486 |
487 bool SessionService::ShouldNewWindowStartSession() { | 487 bool SessionService::ShouldNewWindowStartSession() { |
488 if (!has_open_trackable_browsers_ && !BrowserInit::InProcessStartup() && | 488 if (!has_open_trackable_browsers_ && !BrowserInit::InProcessStartup() && |
489 !SessionRestore::IsRestoring() | 489 !SessionRestore::IsRestoring() |
490 #if defined(OS_MACOSX) | 490 #if defined(OS_MACOSX) |
491 // OSX has a fairly different idea of application lifetime than the | 491 // OSX has a fairly different idea of application lifetime than the |
492 // other platforms. We need to check that we aren't opening a window | 492 // other platforms. We need to check that we aren't opening a window |
493 // from the dock or the menubar. | 493 // from the dock or the menubar. |
494 && !app_controller_mac::IsOpeningNewWindow() | 494 && !app_controller_mac::IsOpeningNewWindow() |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 50); | 1533 50); |
1534 if (use_long_period) { | 1534 if (use_long_period) { |
1535 std::string long_name_("SessionRestore.SaveLongPeriod"); | 1535 std::string long_name_("SessionRestore.SaveLongPeriod"); |
1536 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, | 1536 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, |
1537 delta, | 1537 delta, |
1538 save_delay_in_mins_, | 1538 save_delay_in_mins_, |
1539 save_delay_in_hrs_, | 1539 save_delay_in_hrs_, |
1540 50); | 1540 50); |
1541 } | 1541 } |
1542 } | 1542 } |
OLD | NEW |