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_service.h" | 5 #include "chrome/browser/sessions/session_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 &last_updated_save_time_); | 496 &last_updated_save_time_); |
497 content::NotificationService::current()->Notify( | 497 content::NotificationService::current()->Notify( |
498 chrome::NOTIFICATION_SESSION_SERVICE_SAVED, | 498 chrome::NOTIFICATION_SESSION_SERVICE_SAVED, |
499 content::Source<Profile>(profile()), | 499 content::Source<Profile>(profile()), |
500 content::NotificationService::NoDetails()); | 500 content::NotificationService::NoDetails()); |
501 } | 501 } |
502 } | 502 } |
503 | 503 |
504 void SessionService::Init() { | 504 void SessionService::Init() { |
505 // Register for the notifications we're interested in. | 505 // Register for the notifications we're interested in. |
506 registrar_.Add(this, content::NOTIFICATION_TAB_PARENTED, | 506 registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED, |
507 content::NotificationService::AllSources()); | 507 content::NotificationService::AllSources()); |
508 registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, | 508 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
509 content::NotificationService::AllSources()); | 509 content::NotificationService::AllSources()); |
510 registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED, | 510 registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED, |
511 content::NotificationService::AllSources()); | 511 content::NotificationService::AllSources()); |
512 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_CHANGED, | 512 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_CHANGED, |
513 content::NotificationService::AllSources()); | 513 content::NotificationService::AllSources()); |
514 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 514 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
515 content::NotificationService::AllSources()); | 515 content::NotificationService::AllSources()); |
516 // Wait for NOTIFICATION_BROWSER_WINDOW_READY so that is_app() is set. | 516 // Wait for NOTIFICATION_BROWSER_WINDOW_READY so that is_app() is set. |
517 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 517 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
518 content::NotificationService::AllBrowserContextsAndSources()); | 518 content::NotificationService::AllBrowserContextsAndSources()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 if (browser->profile() != profile() || | 575 if (browser->profile() != profile() || |
576 !should_track_changes_for_browser_type(browser->type(), app_type)) | 576 !should_track_changes_for_browser_type(browser->type(), app_type)) |
577 return; | 577 return; |
578 | 578 |
579 RestoreIfNecessary(std::vector<GURL>(), browser); | 579 RestoreIfNecessary(std::vector<GURL>(), browser); |
580 SetWindowType(browser->session_id(), browser->type(), app_type); | 580 SetWindowType(browser->session_id(), browser->type(), app_type); |
581 SetWindowAppName(browser->session_id(), browser->app_name()); | 581 SetWindowAppName(browser->session_id(), browser->app_name()); |
582 break; | 582 break; |
583 } | 583 } |
584 | 584 |
585 case content::NOTIFICATION_TAB_PARENTED: { | 585 case chrome::NOTIFICATION_TAB_PARENTED: { |
586 TabContentsWrapper* tab = | 586 TabContentsWrapper* tab = |
587 content::Source<TabContentsWrapper>(source).ptr(); | 587 content::Source<TabContentsWrapper>(source).ptr(); |
588 if (tab->profile() != profile()) | 588 if (tab->profile() != profile()) |
589 return; | 589 return; |
590 SetTabWindow(tab->restore_tab_helper()->window_id(), | 590 SetTabWindow(tab->restore_tab_helper()->window_id(), |
591 tab->restore_tab_helper()->session_id()); | 591 tab->restore_tab_helper()->session_id()); |
592 if (tab->extension_tab_helper()->extension_app()) { | 592 if (tab->extension_tab_helper()->extension_app()) { |
593 SetTabExtensionAppID( | 593 SetTabExtensionAppID( |
594 tab->restore_tab_helper()->window_id(), | 594 tab->restore_tab_helper()->window_id(), |
595 tab->restore_tab_helper()->session_id(), | 595 tab->restore_tab_helper()->session_id(), |
596 tab->extension_tab_helper()->extension_app()->id()); | 596 tab->extension_tab_helper()->extension_app()->id()); |
597 } | 597 } |
598 break; | 598 break; |
599 } | 599 } |
600 | 600 |
601 case content::NOTIFICATION_TAB_CLOSED: { | 601 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: { |
602 TabContentsWrapper* tab = | 602 TabContentsWrapper* tab = |
603 TabContentsWrapper::GetCurrentWrapperForContents( | 603 TabContentsWrapper::GetCurrentWrapperForContents( |
604 content::Source<content::NavigationController>( | 604 content::Source<content::WebContents>(source).ptr()); |
605 source).ptr()->GetWebContents()); | |
606 if (!tab || tab->profile() != profile()) | 605 if (!tab || tab->profile() != profile()) |
607 return; | 606 return; |
608 TabClosed(tab->restore_tab_helper()->window_id(), | 607 TabClosed(tab->restore_tab_helper()->window_id(), |
609 tab->restore_tab_helper()->session_id(), | 608 tab->restore_tab_helper()->session_id(), |
610 tab->web_contents()->GetClosedByUserGesture()); | 609 tab->web_contents()->GetClosedByUserGesture()); |
611 RecordSessionUpdateHistogramData(content::NOTIFICATION_TAB_CLOSED, | 610 RecordSessionUpdateHistogramData( |
| 611 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
612 &last_updated_tab_closed_time_); | 612 &last_updated_tab_closed_time_); |
613 break; | 613 break; |
614 } | 614 } |
615 | 615 |
616 case content::NOTIFICATION_NAV_LIST_PRUNED: { | 616 case content::NOTIFICATION_NAV_LIST_PRUNED: { |
617 TabContentsWrapper* tab = | 617 TabContentsWrapper* tab = |
618 TabContentsWrapper::GetCurrentWrapperForContents( | 618 TabContentsWrapper::GetCurrentWrapperForContents( |
619 content::Source<content::NavigationController>( | 619 content::Source<content::NavigationController>( |
620 source).ptr()->GetWebContents()); | 620 source).ptr()->GetWebContents()); |
621 if (!tab || tab->profile() != profile()) | 621 if (!tab || tab->profile() != profile()) |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 // 10 minutes. | 1504 // 10 minutes. |
1505 bool use_long_period = false; | 1505 bool use_long_period = false; |
1506 if (delta >= save_delay_in_mins_) { | 1506 if (delta >= save_delay_in_mins_) { |
1507 use_long_period = true; | 1507 use_long_period = true; |
1508 } | 1508 } |
1509 switch (type) { | 1509 switch (type) { |
1510 case chrome::NOTIFICATION_SESSION_SERVICE_SAVED : | 1510 case chrome::NOTIFICATION_SESSION_SERVICE_SAVED : |
1511 RecordUpdatedSaveTime(delta, use_long_period); | 1511 RecordUpdatedSaveTime(delta, use_long_period); |
1512 RecordUpdatedSessionNavigationOrTab(delta, use_long_period); | 1512 RecordUpdatedSessionNavigationOrTab(delta, use_long_period); |
1513 break; | 1513 break; |
1514 case content::NOTIFICATION_TAB_CLOSED: | 1514 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: |
1515 RecordUpdatedTabClosed(delta, use_long_period); | 1515 RecordUpdatedTabClosed(delta, use_long_period); |
1516 RecordUpdatedSessionNavigationOrTab(delta, use_long_period); | 1516 RecordUpdatedSessionNavigationOrTab(delta, use_long_period); |
1517 break; | 1517 break; |
1518 case content::NOTIFICATION_NAV_LIST_PRUNED: | 1518 case content::NOTIFICATION_NAV_LIST_PRUNED: |
1519 RecordUpdatedNavListPruned(delta, use_long_period); | 1519 RecordUpdatedNavListPruned(delta, use_long_period); |
1520 RecordUpdatedSessionNavigationOrTab(delta, use_long_period); | 1520 RecordUpdatedSessionNavigationOrTab(delta, use_long_period); |
1521 break; | 1521 break; |
1522 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: | 1522 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: |
1523 RecordUpdatedNavEntryCommit(delta, use_long_period); | 1523 RecordUpdatedNavEntryCommit(delta, use_long_period); |
1524 RecordUpdatedSessionNavigationOrTab(delta, use_long_period); | 1524 RecordUpdatedSessionNavigationOrTab(delta, use_long_period); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 50); | 1618 50); |
1619 if (use_long_period) { | 1619 if (use_long_period) { |
1620 std::string long_name_("SessionRestore.SaveLongPeriod"); | 1620 std::string long_name_("SessionRestore.SaveLongPeriod"); |
1621 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, | 1621 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, |
1622 delta, | 1622 delta, |
1623 save_delay_in_mins_, | 1623 save_delay_in_mins_, |
1624 save_delay_in_hrs_, | 1624 save_delay_in_hrs_, |
1625 50); | 1625 50); |
1626 } | 1626 } |
1627 } | 1627 } |
OLD | NEW |