OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 /////////////////////////////////////////////////////////////////////////////// | 905 /////////////////////////////////////////////////////////////////////////////// |
906 // Browser, PageNavigator implementation: | 906 // Browser, PageNavigator implementation: |
907 | 907 |
908 WebContents* Browser::OpenURL(const OpenURLParams& params) { | 908 WebContents* Browser::OpenURL(const OpenURLParams& params) { |
909 return OpenURLFromTab(NULL, params); | 909 return OpenURLFromTab(NULL, params); |
910 } | 910 } |
911 | 911 |
912 /////////////////////////////////////////////////////////////////////////////// | 912 /////////////////////////////////////////////////////////////////////////////// |
913 // Browser, TabStripModelObserver implementation: | 913 // Browser, TabStripModelObserver implementation: |
914 | 914 |
915 void Browser::TabInsertedAt(WebContents* contents, | 915 void Browser::TabInsertedAt(TabStripModel* tab_strip_model, |
| 916 WebContents* contents, |
916 int index, | 917 int index, |
917 bool foreground) { | 918 bool foreground) { |
918 SetAsDelegate(contents, true); | 919 SetAsDelegate(contents, true); |
919 | 920 |
920 SessionTabHelper* session_tab_helper = | 921 SessionTabHelper* session_tab_helper = |
921 SessionTabHelper::FromWebContents(contents); | 922 SessionTabHelper::FromWebContents(contents); |
922 session_tab_helper->SetWindowID(session_id()); | 923 session_tab_helper->SetWindowID(session_id()); |
923 | 924 |
924 content::NotificationService::current()->Notify( | 925 content::NotificationService::current()->Notify( |
925 chrome::NOTIFICATION_TAB_PARENTED, | 926 chrome::NOTIFICATION_TAB_PARENTED, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 void Browser::TabReplacedAt(TabStripModel* tab_strip_model, | 1079 void Browser::TabReplacedAt(TabStripModel* tab_strip_model, |
1079 WebContents* old_contents, | 1080 WebContents* old_contents, |
1080 WebContents* new_contents, | 1081 WebContents* new_contents, |
1081 int index) { | 1082 int index) { |
1082 TabDetachedAtImpl(old_contents, index, DETACH_TYPE_REPLACE); | 1083 TabDetachedAtImpl(old_contents, index, DETACH_TYPE_REPLACE); |
1083 exclusive_access_manager_->OnTabClosing(old_contents); | 1084 exclusive_access_manager_->OnTabClosing(old_contents); |
1084 SessionService* session_service = | 1085 SessionService* session_service = |
1085 SessionServiceFactory::GetForProfile(profile_); | 1086 SessionServiceFactory::GetForProfile(profile_); |
1086 if (session_service) | 1087 if (session_service) |
1087 session_service->TabClosing(old_contents); | 1088 session_service->TabClosing(old_contents); |
1088 TabInsertedAt(new_contents, | 1089 TabInsertedAt(tab_strip_model, new_contents, index, |
1089 index, | |
1090 (index == tab_strip_model_->active_index())); | 1090 (index == tab_strip_model_->active_index())); |
1091 | 1091 |
1092 if (!new_contents->GetController().IsInitialBlankNavigation()) { | 1092 if (!new_contents->GetController().IsInitialBlankNavigation()) { |
1093 // Send out notification so that observers are updated appropriately. | 1093 // Send out notification so that observers are updated appropriately. |
1094 int entry_count = new_contents->GetController().GetEntryCount(); | 1094 int entry_count = new_contents->GetController().GetEntryCount(); |
1095 new_contents->GetController().NotifyEntryChanged( | 1095 new_contents->GetController().NotifyEntryChanged( |
1096 new_contents->GetController().GetEntryAtIndex(entry_count - 1)); | 1096 new_contents->GetController().GetEntryAtIndex(entry_count - 1)); |
1097 } | 1097 } |
1098 | 1098 |
1099 if (session_service) { | 1099 if (session_service) { |
1100 // The new_contents may end up with a different navigation stack. Force | 1100 // The new_contents may end up with a different navigation stack. Force |
1101 // the session service to update itself. | 1101 // the session service to update itself. |
1102 session_service->TabRestored(new_contents, | 1102 session_service->TabRestored(new_contents, |
1103 tab_strip_model_->IsTabPinned(index)); | 1103 tab_strip_model_->IsTabPinned(index)); |
1104 } | 1104 } |
1105 } | 1105 } |
1106 | 1106 |
1107 void Browser::TabPinnedStateChanged(WebContents* contents, int index) { | 1107 void Browser::TabPinnedStateChanged(TabStripModel* tab_strip_model, |
| 1108 WebContents* contents, |
| 1109 int index) { |
1108 SessionService* session_service = | 1110 SessionService* session_service = |
1109 SessionServiceFactory::GetForProfileIfExisting(profile()); | 1111 SessionServiceFactory::GetForProfileIfExisting(profile()); |
1110 if (session_service) { | 1112 if (session_service) { |
1111 SessionTabHelper* session_tab_helper = | 1113 SessionTabHelper* session_tab_helper = |
1112 SessionTabHelper::FromWebContents(contents); | 1114 SessionTabHelper::FromWebContents(contents); |
1113 session_service->SetPinnedState(session_id(), | 1115 session_service->SetPinnedState(session_id(), |
1114 session_tab_helper->session_id(), | 1116 session_tab_helper->session_id(), |
1115 tab_strip_model_->IsTabPinned(index)); | 1117 tab_strip_model_->IsTabPinned(index)); |
1116 } | 1118 } |
1117 } | 1119 } |
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2564 if (contents && !allow_js_access) { | 2566 if (contents && !allow_js_access) { |
2565 contents->web_contents()->GetController().LoadURL( | 2567 contents->web_contents()->GetController().LoadURL( |
2566 target_url, | 2568 target_url, |
2567 content::Referrer(), | 2569 content::Referrer(), |
2568 ui::PAGE_TRANSITION_LINK, | 2570 ui::PAGE_TRANSITION_LINK, |
2569 std::string()); // No extra headers. | 2571 std::string()); // No extra headers. |
2570 } | 2572 } |
2571 | 2573 |
2572 return contents != NULL; | 2574 return contents != NULL; |
2573 } | 2575 } |
OLD | NEW |