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

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

Issue 6693054: Get rid of extensions dependency from content\browser. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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>
11 11
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/pickle.h" 16 #include "base/pickle.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "chrome/browser/browser_list.h" 18 #include "chrome/browser/browser_list.h"
19 #include "chrome/browser/browser_window.h" 19 #include "chrome/browser/browser_window.h"
20 #include "chrome/browser/extensions/extension_tab_helper.h"
20 #include "chrome/browser/prefs/session_startup_pref.h" 21 #include "chrome/browser/prefs/session_startup_pref.h"
21 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/sessions/session_backend.h" 23 #include "chrome/browser/sessions/session_backend.h"
23 #include "chrome/browser/sessions/session_command.h" 24 #include "chrome/browser/sessions/session_command.h"
24 #include "chrome/browser/sessions/session_restore.h" 25 #include "chrome/browser/sessions/session_restore.h"
25 #include "chrome/browser/sessions/session_types.h" 26 #include "chrome/browser/sessions/session_types.h"
26 #include "chrome/browser/tabs/tab_strip_model.h" 27 #include "chrome/browser/tabs/tab_strip_model.h"
27 #include "chrome/browser/ui/browser_init.h" 28 #include "chrome/browser/ui/browser_init.h"
29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
28 #include "chrome/common/extensions/extension.h" 30 #include "chrome/common/extensions/extension.h"
29 #include "content/browser/tab_contents/navigation_controller.h" 31 #include "content/browser/tab_contents/navigation_controller.h"
30 #include "content/browser/tab_contents/navigation_entry.h" 32 #include "content/browser/tab_contents/navigation_entry.h"
31 #include "content/browser/tab_contents/tab_contents.h" 33 #include "content/browser/tab_contents/tab_contents.h"
32 #include "content/common/notification_details.h" 34 #include "content/common/notification_details.h"
33 #include "content/common/notification_service.h" 35 #include "content/common/notification_service.h"
34 36
35 #if defined(OS_MACOSX) 37 #if defined(OS_MACOSX)
36 #include "chrome/browser/app_controller_cppsafe_mac.h" 38 #include "chrome/browser/app_controller_cppsafe_mac.h"
37 #endif 39 #endif
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 513
512 RestoreIfNecessary(std::vector<GURL>(), browser); 514 RestoreIfNecessary(std::vector<GURL>(), browser);
513 SetWindowType(browser->session_id(), browser->type()); 515 SetWindowType(browser->session_id(), browser->type());
514 break; 516 break;
515 } 517 }
516 518
517 case NotificationType::TAB_PARENTED: { 519 case NotificationType::TAB_PARENTED: {
518 NavigationController* controller = 520 NavigationController* controller =
519 Source<NavigationController>(source).ptr(); 521 Source<NavigationController>(source).ptr();
520 SetTabWindow(controller->window_id(), controller->session_id()); 522 SetTabWindow(controller->window_id(), controller->session_id());
521 if (controller->tab_contents()->extension_app()) { 523 TabContentsWrapper* wrapper =
524 TabContentsWrapper::GetCurrentWrapperForContents(
525 controller->tab_contents());
526 if (wrapper->extension_tab_helper()->extension_app()) {
522 SetTabExtensionAppID( 527 SetTabExtensionAppID(
523 controller->window_id(), 528 controller->window_id(),
524 controller->session_id(), 529 controller->session_id(),
525 controller->tab_contents()->extension_app()->id()); 530 wrapper->extension_tab_helper()->extension_app()->id());
526 } 531 }
527 break; 532 break;
528 } 533 }
529 534
530 case NotificationType::TAB_CLOSED: { 535 case NotificationType::TAB_CLOSED: {
531 NavigationController* controller = 536 NavigationController* controller =
532 Source<NavigationController>(source).ptr(); 537 Source<NavigationController>(source).ptr();
533 TabClosed(controller->window_id(), controller->session_id(), 538 TabClosed(controller->window_id(), controller->session_id(),
534 controller->tab_contents()->closed_by_user_gesture()); 539 controller->tab_contents()->closed_by_user_gesture());
535 RecordSessionUpdateHistogramData(NotificationType::TAB_CLOSED, 540 RecordSessionUpdateHistogramData(NotificationType::TAB_CLOSED,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 Details<NavigationController::LoadCommittedDetails> changed(details); 582 Details<NavigationController::LoadCommittedDetails> changed(details);
578 if (changed->type == NavigationType::NEW_PAGE || 583 if (changed->type == NavigationType::NEW_PAGE ||
579 changed->type == NavigationType::EXISTING_PAGE) { 584 changed->type == NavigationType::EXISTING_PAGE) {
580 RecordSessionUpdateHistogramData(NotificationType::NAV_ENTRY_COMMITTED, 585 RecordSessionUpdateHistogramData(NotificationType::NAV_ENTRY_COMMITTED,
581 &last_updated_nav_entry_commit_time_); 586 &last_updated_nav_entry_commit_time_);
582 } 587 }
583 break; 588 break;
584 } 589 }
585 590
586 case NotificationType::TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED: { 591 case NotificationType::TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED: {
587 TabContents* tab_contents = Source<TabContents>(source).ptr(); 592 ExtensionTabHelper* extension_tab_helper =
588 DCHECK(tab_contents); 593 Source<ExtensionTabHelper>(source).ptr();
589 if (tab_contents->extension_app()) { 594 if (extension_tab_helper->extension_app()) {
590 SetTabExtensionAppID(tab_contents->controller().window_id(), 595 SetTabExtensionAppID(
591 tab_contents->controller().session_id(), 596 extension_tab_helper->tab_contents()->controller().window_id(),
592 tab_contents->extension_app()->id()); 597 extension_tab_helper->tab_contents()->controller().session_id(),
598 extension_tab_helper->extension_app()->id());
593 } 599 }
594 break; 600 break;
595 } 601 }
596 602
597 default: 603 default:
598 NOTREACHED(); 604 NOTREACHED();
599 } 605 }
600 } 606 }
601 607
602 void SessionService::SetTabExtensionAppID( 608 void SessionService::SetTabExtensionAppID(
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 controller->entry_count()); 1071 controller->entry_count());
1066 const int pending_index = controller->pending_entry_index(); 1072 const int pending_index = controller->pending_entry_index();
1067 if (tab_to_available_range) { 1073 if (tab_to_available_range) {
1068 (*tab_to_available_range)[controller->session_id().id()] = 1074 (*tab_to_available_range)[controller->session_id().id()] =
1069 std::pair<int, int>(min_index, max_index); 1075 std::pair<int, int>(min_index, max_index);
1070 } 1076 }
1071 if (is_pinned) { 1077 if (is_pinned) {
1072 commands->push_back( 1078 commands->push_back(
1073 CreatePinnedStateCommand(controller->session_id(), true)); 1079 CreatePinnedStateCommand(controller->session_id(), true));
1074 } 1080 }
1075 if (controller->tab_contents()->extension_app()) { 1081 TabContentsWrapper* wrapper =
1082 TabContentsWrapper::GetCurrentWrapperForContents(
1083 controller->tab_contents());
1084 if (wrapper->extension_tab_helper()->extension_app()) {
1076 commands->push_back( 1085 commands->push_back(
1077 CreateSetTabExtensionAppIDCommand( 1086 CreateSetTabExtensionAppIDCommand(
1078 kCommandSetExtensionAppID, 1087 kCommandSetExtensionAppID,
1079 controller->session_id().id(), 1088 controller->session_id().id(),
1080 controller->tab_contents()->extension_app()->id())); 1089 wrapper->extension_tab_helper()->extension_app()->id()));
1081 } 1090 }
1082 for (int i = min_index; i < max_index; ++i) { 1091 for (int i = min_index; i < max_index; ++i) {
1083 const NavigationEntry* entry = (i == pending_index) ? 1092 const NavigationEntry* entry = (i == pending_index) ?
1084 controller->pending_entry() : controller->GetEntryAtIndex(i); 1093 controller->pending_entry() : controller->GetEntryAtIndex(i);
1085 DCHECK(entry); 1094 DCHECK(entry);
1086 if (ShouldTrackEntry(*entry)) { 1095 if (ShouldTrackEntry(*entry)) {
1087 commands->push_back( 1096 commands->push_back(
1088 CreateUpdateTabNavigationCommand(kCommandUpdateTabNavigation, 1097 CreateUpdateTabNavigationCommand(kCommandUpdateTabNavigation,
1089 controller->session_id().id(), 1098 controller->session_id().id(),
1090 i, 1099 i,
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 50); 1473 50);
1465 if (use_long_period) { 1474 if (use_long_period) {
1466 std::string long_name_("SessionRestore.SaveLongPeriod"); 1475 std::string long_name_("SessionRestore.SaveLongPeriod");
1467 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, 1476 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_,
1468 delta, 1477 delta,
1469 save_delay_in_mins_, 1478 save_delay_in_mins_,
1470 save_delay_in_hrs_, 1479 save_delay_in_hrs_,
1471 50); 1480 50);
1472 } 1481 }
1473 } 1482 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tab_helper.cc ('k') | chrome/browser/sessions/tab_restore_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698