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

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

Issue 9030032: Get rid of a bunch of tab_contents.h includes from chrome. These are all trivial changes to use W... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
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 14 matching lines...) Expand all
25 #include "chrome/browser/sessions/session_command.h" 25 #include "chrome/browser/sessions/session_command.h"
26 #include "chrome/browser/sessions/session_restore.h" 26 #include "chrome/browser/sessions/session_restore.h"
27 #include "chrome/browser/sessions/session_types.h" 27 #include "chrome/browser/sessions/session_types.h"
28 #include "chrome/browser/tabs/tab_strip_model.h" 28 #include "chrome/browser/tabs/tab_strip_model.h"
29 #include "chrome/browser/ui/browser_init.h" 29 #include "chrome/browser/ui/browser_init.h"
30 #include "chrome/browser/ui/browser_list.h" 30 #include "chrome/browser/ui/browser_list.h"
31 #include "chrome/browser/ui/browser_window.h" 31 #include "chrome/browser/ui/browser_window.h"
32 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 32 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
33 #include "chrome/common/chrome_notification_types.h" 33 #include "chrome/common/chrome_notification_types.h"
34 #include "chrome/common/extensions/extension.h" 34 #include "chrome/common/extensions/extension.h"
35 #include "content/browser/tab_contents/tab_contents.h"
36 #include "content/public/browser/navigation_details.h" 35 #include "content/public/browser/navigation_details.h"
37 #include "content/public/browser/navigation_entry.h" 36 #include "content/public/browser/navigation_entry.h"
38 #include "content/public/browser/notification_service.h" 37 #include "content/public/browser/notification_service.h"
39 #include "content/public/browser/notification_details.h" 38 #include "content/public/browser/notification_details.h"
39 #include "content/public/browser/web_contents.h"
40 40
41 #if defined(OS_MACOSX) 41 #if defined(OS_MACOSX)
42 #include "chrome/browser/app_controller_cppsafe_mac.h" 42 #include "chrome/browser/app_controller_cppsafe_mac.h"
43 #endif 43 #endif
44 44
45 using base::Time; 45 using base::Time;
46 using content::NavigationEntry; 46 using content::NavigationEntry;
47 47
48 // Identifier for commands written to file. 48 // Identifier for commands written to file.
49 static const SessionCommand::id_type kCommandSetTabWindow = 0; 49 static const SessionCommand::id_type kCommandSetTabWindow = 0;
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 532
533 case content::NOTIFICATION_TAB_CLOSED: { 533 case content::NOTIFICATION_TAB_CLOSED: {
534 TabContentsWrapper* tab = 534 TabContentsWrapper* tab =
535 TabContentsWrapper::GetCurrentWrapperForContents( 535 TabContentsWrapper::GetCurrentWrapperForContents(
536 content::Source<content::NavigationController>( 536 content::Source<content::NavigationController>(
537 source).ptr()->GetWebContents()); 537 source).ptr()->GetWebContents());
538 if (!tab || tab->profile() != profile()) 538 if (!tab || tab->profile() != profile())
539 return; 539 return;
540 TabClosed(tab->restore_tab_helper()->window_id(), 540 TabClosed(tab->restore_tab_helper()->window_id(),
541 tab->restore_tab_helper()->session_id(), 541 tab->restore_tab_helper()->session_id(),
542 tab->tab_contents()->GetClosedByUserGesture()); 542 tab->web_contents()->GetClosedByUserGesture());
543 RecordSessionUpdateHistogramData(content::NOTIFICATION_TAB_CLOSED, 543 RecordSessionUpdateHistogramData(content::NOTIFICATION_TAB_CLOSED,
544 &last_updated_tab_closed_time_); 544 &last_updated_tab_closed_time_);
545 break; 545 break;
546 } 546 }
547 547
548 case content::NOTIFICATION_NAV_LIST_PRUNED: { 548 case content::NOTIFICATION_NAV_LIST_PRUNED: {
549 TabContentsWrapper* tab = 549 TabContentsWrapper* tab =
550 TabContentsWrapper::GetCurrentWrapperForContents( 550 TabContentsWrapper::GetCurrentWrapperForContents(
551 content::Source<content::NavigationController>( 551 content::Source<content::NavigationController>(
552 source).ptr()->GetWebContents()); 552 source).ptr()->GetWebContents());
553 if (!tab || tab->profile() != profile()) 553 if (!tab || tab->profile() != profile())
554 return; 554 return;
555 content::Details<content::PrunedDetails> pruned_details(details); 555 content::Details<content::PrunedDetails> pruned_details(details);
556 if (pruned_details->from_front) { 556 if (pruned_details->from_front) {
557 TabNavigationPathPrunedFromFront( 557 TabNavigationPathPrunedFromFront(
558 tab->restore_tab_helper()->window_id(), 558 tab->restore_tab_helper()->window_id(),
559 tab->restore_tab_helper()->session_id(), 559 tab->restore_tab_helper()->session_id(),
560 pruned_details->count); 560 pruned_details->count);
561 } else { 561 } else {
562 TabNavigationPathPrunedFromBack( 562 TabNavigationPathPrunedFromBack(
563 tab->restore_tab_helper()->window_id(), 563 tab->restore_tab_helper()->window_id(),
564 tab->restore_tab_helper()->session_id(), 564 tab->restore_tab_helper()->session_id(),
565 tab->tab_contents()->GetController().GetEntryCount()); 565 tab->web_contents()->GetController().GetEntryCount());
566 } 566 }
567 RecordSessionUpdateHistogramData(content::NOTIFICATION_NAV_LIST_PRUNED, 567 RecordSessionUpdateHistogramData(content::NOTIFICATION_NAV_LIST_PRUNED,
568 &last_updated_nav_list_pruned_time_); 568 &last_updated_nav_list_pruned_time_);
569 break; 569 break;
570 } 570 }
571 571
572 case content::NOTIFICATION_NAV_ENTRY_CHANGED: { 572 case content::NOTIFICATION_NAV_ENTRY_CHANGED: {
573 TabContentsWrapper* tab = 573 TabContentsWrapper* tab =
574 TabContentsWrapper::GetCurrentWrapperForContents( 574 TabContentsWrapper::GetCurrentWrapperForContents(
575 content::Source<content::NavigationController>( 575 content::Source<content::NavigationController>(
576 source).ptr()->GetWebContents()); 576 source).ptr()->GetWebContents());
577 if (!tab || tab->profile() != profile()) 577 if (!tab || tab->profile() != profile())
578 return; 578 return;
579 content::Details<content::EntryChangedDetails> changed(details); 579 content::Details<content::EntryChangedDetails> changed(details);
580 UpdateTabNavigation( 580 UpdateTabNavigation(
581 tab->restore_tab_helper()->window_id(), 581 tab->restore_tab_helper()->window_id(),
582 tab->restore_tab_helper()->session_id(), 582 tab->restore_tab_helper()->session_id(),
583 changed->index, *changed->changed_entry); 583 changed->index, *changed->changed_entry);
584 break; 584 break;
585 } 585 }
586 586
587 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: { 587 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: {
588 TabContentsWrapper* tab = 588 TabContentsWrapper* tab =
589 TabContentsWrapper::GetCurrentWrapperForContents( 589 TabContentsWrapper::GetCurrentWrapperForContents(
590 content::Source<content::NavigationController>( 590 content::Source<content::NavigationController>(
591 source).ptr()->GetWebContents()); 591 source).ptr()->GetWebContents());
592 if (!tab || tab->profile() != profile()) 592 if (!tab || tab->profile() != profile())
593 return; 593 return;
594 int current_entry_index = 594 int current_entry_index =
595 tab->tab_contents()->GetController().GetCurrentEntryIndex(); 595 tab->web_contents()->GetController().GetCurrentEntryIndex();
596 SetSelectedNavigationIndex(tab->restore_tab_helper()->window_id(), 596 SetSelectedNavigationIndex(tab->restore_tab_helper()->window_id(),
597 tab->restore_tab_helper()->session_id(), 597 tab->restore_tab_helper()->session_id(),
598 current_entry_index); 598 current_entry_index);
599 UpdateTabNavigation( 599 UpdateTabNavigation(
600 tab->restore_tab_helper()->window_id(), 600 tab->restore_tab_helper()->window_id(),
601 tab->restore_tab_helper()->session_id(), 601 tab->restore_tab_helper()->session_id(),
602 current_entry_index, 602 current_entry_index,
603 *tab->tab_contents()->GetController().GetEntryAtIndex( 603 *tab->web_contents()->GetController().GetEntryAtIndex(
604 current_entry_index)); 604 current_entry_index));
605 content::Details<content::LoadCommittedDetails> changed(details); 605 content::Details<content::LoadCommittedDetails> changed(details);
606 if (changed->type == content::NAVIGATION_TYPE_NEW_PAGE || 606 if (changed->type == content::NAVIGATION_TYPE_NEW_PAGE ||
607 changed->type == content::NAVIGATION_TYPE_EXISTING_PAGE) { 607 changed->type == content::NAVIGATION_TYPE_EXISTING_PAGE) {
608 RecordSessionUpdateHistogramData( 608 RecordSessionUpdateHistogramData(
609 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 609 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
610 &last_updated_nav_entry_commit_time_); 610 &last_updated_nav_entry_commit_time_);
611 } 611 }
612 break; 612 break;
613 } 613 }
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 const SessionID& window_id, 1109 const SessionID& window_id,
1110 TabContentsWrapper* tab, 1110 TabContentsWrapper* tab,
1111 int index_in_window, 1111 int index_in_window,
1112 bool is_pinned, 1112 bool is_pinned,
1113 std::vector<SessionCommand*>* commands, 1113 std::vector<SessionCommand*>* commands,
1114 IdToRange* tab_to_available_range) { 1114 IdToRange* tab_to_available_range) {
1115 DCHECK(tab && commands && window_id.id()); 1115 DCHECK(tab && commands && window_id.id());
1116 const SessionID& session_id(tab->restore_tab_helper()->session_id()); 1116 const SessionID& session_id(tab->restore_tab_helper()->session_id());
1117 commands->push_back(CreateSetTabWindowCommand(window_id, session_id)); 1117 commands->push_back(CreateSetTabWindowCommand(window_id, session_id));
1118 const int current_index = 1118 const int current_index =
1119 tab->tab_contents()->GetController().GetCurrentEntryIndex(); 1119 tab->web_contents()->GetController().GetCurrentEntryIndex();
1120 const int min_index = std::max(0, 1120 const int min_index = std::max(0,
1121 current_index - max_persist_navigation_count); 1121 current_index - max_persist_navigation_count);
1122 const int max_index = 1122 const int max_index =
1123 std::min(current_index + max_persist_navigation_count, 1123 std::min(current_index + max_persist_navigation_count,
1124 tab->tab_contents()->GetController().GetEntryCount()); 1124 tab->web_contents()->GetController().GetEntryCount());
1125 const int pending_index = 1125 const int pending_index =
1126 tab->tab_contents()->GetController().GetPendingEntryIndex(); 1126 tab->web_contents()->GetController().GetPendingEntryIndex();
1127 if (tab_to_available_range) { 1127 if (tab_to_available_range) {
1128 (*tab_to_available_range)[session_id.id()] = 1128 (*tab_to_available_range)[session_id.id()] =
1129 std::pair<int, int>(min_index, max_index); 1129 std::pair<int, int>(min_index, max_index);
1130 } 1130 }
1131 if (is_pinned) { 1131 if (is_pinned) {
1132 commands->push_back(CreatePinnedStateCommand(session_id, true)); 1132 commands->push_back(CreatePinnedStateCommand(session_id, true));
1133 } 1133 }
1134 TabContentsWrapper* wrapper = 1134 TabContentsWrapper* wrapper =
1135 TabContentsWrapper::GetCurrentWrapperForContents(tab->tab_contents()); 1135 TabContentsWrapper::GetCurrentWrapperForContents(tab->web_contents());
1136 if (wrapper->extension_tab_helper()->extension_app()) { 1136 if (wrapper->extension_tab_helper()->extension_app()) {
1137 commands->push_back( 1137 commands->push_back(
1138 CreateSetTabExtensionAppIDCommand( 1138 CreateSetTabExtensionAppIDCommand(
1139 kCommandSetExtensionAppID, session_id.id(), 1139 kCommandSetExtensionAppID, session_id.id(),
1140 wrapper->extension_tab_helper()->extension_app()->id())); 1140 wrapper->extension_tab_helper()->extension_app()->id()));
1141 } 1141 }
1142 for (int i = min_index; i < max_index; ++i) { 1142 for (int i = min_index; i < max_index; ++i) {
1143 const NavigationEntry* entry = (i == pending_index) ? 1143 const NavigationEntry* entry = (i == pending_index) ?
1144 tab->tab_contents()->GetController().GetPendingEntry() : 1144 tab->web_contents()->GetController().GetPendingEntry() :
1145 tab->tab_contents()->GetController().GetEntryAtIndex(i); 1145 tab->web_contents()->GetController().GetEntryAtIndex(i);
1146 DCHECK(entry); 1146 DCHECK(entry);
1147 if (ShouldTrackEntry(entry->GetVirtualURL())) { 1147 if (ShouldTrackEntry(entry->GetVirtualURL())) {
1148 commands->push_back( 1148 commands->push_back(
1149 CreateUpdateTabNavigationCommand( 1149 CreateUpdateTabNavigationCommand(
1150 kCommandUpdateTabNavigation, session_id.id(), i, *entry)); 1150 kCommandUpdateTabNavigation, session_id.id(), i, *entry));
1151 } 1151 }
1152 } 1152 }
1153 commands->push_back( 1153 commands->push_back(
1154 CreateSetSelectedNavigationIndexCommand(session_id, current_index)); 1154 CreateSetSelectedNavigationIndexCommand(session_id, current_index));
1155 1155
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 50); 1512 50);
1513 if (use_long_period) { 1513 if (use_long_period) {
1514 std::string long_name_("SessionRestore.SaveLongPeriod"); 1514 std::string long_name_("SessionRestore.SaveLongPeriod");
1515 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, 1515 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_,
1516 delta, 1516 delta,
1517 save_delay_in_mins_, 1517 save_delay_in_mins_,
1518 save_delay_in_hrs_, 1518 save_delay_in_hrs_,
1519 50); 1519 50);
1520 } 1520 }
1521 } 1521 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore.cc ('k') | chrome/browser/speech/speech_input_bubble_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698