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

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

Issue 10917026: Switch Extensions::TabHelper to use WebContents, WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 8 years, 3 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
« no previous file with comments | « chrome/browser/extensions/tab_helper.cc ('k') | chrome/browser/sessions/tab_restore_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 605
606 case chrome::NOTIFICATION_TAB_PARENTED: { 606 case chrome::NOTIFICATION_TAB_PARENTED: {
607 TabContents* tab = content::Source<TabContents>(source).ptr(); 607 TabContents* tab = content::Source<TabContents>(source).ptr();
608 if (tab->profile() != profile()) 608 if (tab->profile() != profile())
609 return; 609 return;
610 WebContents* web_contents = tab->web_contents(); 610 WebContents* web_contents = tab->web_contents();
611 SessionTabHelper* session_tab_helper = 611 SessionTabHelper* session_tab_helper =
612 SessionTabHelper::FromWebContents(web_contents); 612 SessionTabHelper::FromWebContents(web_contents);
613 SetTabWindow(session_tab_helper->window_id(), 613 SetTabWindow(session_tab_helper->window_id(),
614 session_tab_helper->session_id()); 614 session_tab_helper->session_id());
615 if (tab->extension_tab_helper()->extension_app()) { 615 extensions::TabHelper* extensions_tab_helper =
616 extensions::TabHelper::FromWebContents(web_contents);
617 if (extensions_tab_helper &&
618 extensions_tab_helper->extension_app()) {
616 SetTabExtensionAppID( 619 SetTabExtensionAppID(
617 session_tab_helper->window_id(), 620 session_tab_helper->window_id(),
618 session_tab_helper->session_id(), 621 session_tab_helper->session_id(),
619 tab->extension_tab_helper()->extension_app()->id()); 622 extensions_tab_helper->extension_app()->id());
620 } 623 }
621 624
622 // Record the association between the SessionStorageNamespace and the 625 // Record the association between the SessionStorageNamespace and the
623 // tab. 626 // tab.
624 // 627 //
625 // TODO(ajwong): This should be processing the whole map rather than 628 // TODO(ajwong): This should be processing the whole map rather than
626 // just the default. This in particular will not work for tabs with only 629 // just the default. This in particular will not work for tabs with only
627 // isolated apps which won't have a default partition. 630 // isolated apps which won't have a default partition.
628 content::SessionStorageNamespace* session_storage_namespace = 631 content::SessionStorageNamespace* session_storage_namespace =
629 web_contents->GetController().GetDefaultSessionStorageNamespace(); 632 web_contents->GetController().GetDefaultSessionStorageNamespace();
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 changed->type == content::NAVIGATION_TYPE_EXISTING_PAGE) { 720 changed->type == content::NAVIGATION_TYPE_EXISTING_PAGE) {
718 RecordSessionUpdateHistogramData(type, 721 RecordSessionUpdateHistogramData(type,
719 &last_updated_nav_entry_commit_time_); 722 &last_updated_nav_entry_commit_time_);
720 } 723 }
721 break; 724 break;
722 } 725 }
723 726
724 case chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED: { 727 case chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED: {
725 extensions::TabHelper* extension_tab_helper = 728 extensions::TabHelper* extension_tab_helper =
726 content::Source<extensions::TabHelper>(source).ptr(); 729 content::Source<extensions::TabHelper>(source).ptr();
727 if (extension_tab_helper->tab_contents()->profile() != profile()) 730 if (extension_tab_helper->web_contents()->GetBrowserContext() !=
731 profile()) {
728 return; 732 return;
733 }
729 if (extension_tab_helper->extension_app()) { 734 if (extension_tab_helper->extension_app()) {
730 SessionTabHelper* session_tab_helper = 735 SessionTabHelper* session_tab_helper =
731 SessionTabHelper::FromWebContents( 736 SessionTabHelper::FromWebContents(
732 extension_tab_helper->web_contents()); 737 extension_tab_helper->web_contents());
733 SetTabExtensionAppID(session_tab_helper->window_id(), 738 SetTabExtensionAppID(session_tab_helper->window_id(),
734 session_tab_helper->session_id(), 739 session_tab_helper->session_id(),
735 extension_tab_helper->extension_app()->id()); 740 extension_tab_helper->extension_app()->id());
736 } 741 }
737 break; 742 break;
738 } 743 }
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 tab->web_contents()->GetController().GetPendingEntryIndex(); 1324 tab->web_contents()->GetController().GetPendingEntryIndex();
1320 if (tab_to_available_range) { 1325 if (tab_to_available_range) {
1321 (*tab_to_available_range)[session_id.id()] = 1326 (*tab_to_available_range)[session_id.id()] =
1322 std::pair<int, int>(min_index, max_index); 1327 std::pair<int, int>(min_index, max_index);
1323 } 1328 }
1324 1329
1325 if (is_pinned) { 1330 if (is_pinned) {
1326 commands->push_back(CreatePinnedStateCommand(session_id, true)); 1331 commands->push_back(CreatePinnedStateCommand(session_id, true));
1327 } 1332 }
1328 1333
1329 if (tab->extension_tab_helper()->extension_app()) { 1334 extensions::TabHelper* extensions_tab_helper =
1335 extensions::TabHelper::FromWebContents(tab->web_contents());
1336 if (extensions_tab_helper->extension_app()) {
1330 commands->push_back( 1337 commands->push_back(
1331 CreateSetTabExtensionAppIDCommand( 1338 CreateSetTabExtensionAppIDCommand(
1332 kCommandSetExtensionAppID, session_id.id(), 1339 kCommandSetExtensionAppID, session_id.id(),
1333 tab->extension_tab_helper()->extension_app()->id())); 1340 extensions_tab_helper->extension_app()->id()));
1334 } 1341 }
1335 1342
1336 const std::string& ua_override = tab->web_contents()->GetUserAgentOverride(); 1343 const std::string& ua_override = tab->web_contents()->GetUserAgentOverride();
1337 if (!ua_override.empty()) { 1344 if (!ua_override.empty()) {
1338 commands->push_back( 1345 commands->push_back(
1339 CreateSetTabUserAgentOverrideCommand( 1346 CreateSetTabUserAgentOverrideCommand(
1340 kCommandSetTabUserAgentOverride, session_id.id(), ua_override)); 1347 kCommandSetTabUserAgentOverride, session_id.id(), ua_override));
1341 } 1348 }
1342 1349
1343 for (int i = min_index; i < max_index; ++i) { 1350 for (int i = min_index; i < max_index; ++i) {
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1740 50); 1747 50);
1741 if (use_long_period) { 1748 if (use_long_period) {
1742 std::string long_name_("SessionRestore.SaveLongPeriod"); 1749 std::string long_name_("SessionRestore.SaveLongPeriod");
1743 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, 1750 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_,
1744 delta, 1751 delta,
1745 save_delay_in_mins_, 1752 save_delay_in_mins_,
1746 save_delay_in_hrs_, 1753 save_delay_in_hrs_,
1747 50); 1754 50);
1748 } 1755 }
1749 } 1756 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/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