OLD | NEW |
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/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 profile(), | 1298 profile(), |
1299 tab_util::GetSiteInstanceForNewTab(NULL, profile_, restore_url), | 1299 tab_util::GetSiteInstanceForNewTab(NULL, profile_, restore_url), |
1300 MSG_ROUTING_NONE, | 1300 MSG_ROUTING_NONE, |
1301 GetSelectedTabContents(), | 1301 GetSelectedTabContents(), |
1302 session_storage_namespace); | 1302 session_storage_namespace); |
1303 TabContents* new_tab = wrapper->tab_contents(); | 1303 TabContents* new_tab = wrapper->tab_contents(); |
1304 wrapper->extension_tab_helper()->SetExtensionAppById(extension_app_id); | 1304 wrapper->extension_tab_helper()->SetExtensionAppById(extension_app_id); |
1305 std::vector<NavigationEntry*> entries; | 1305 std::vector<NavigationEntry*> entries; |
1306 TabNavigation::CreateNavigationEntriesFromTabNavigations( | 1306 TabNavigation::CreateNavigationEntriesFromTabNavigations( |
1307 profile_, navigations, &entries); | 1307 profile_, navigations, &entries); |
1308 new_tab->GetController().Restore( | 1308 new_tab->controller().Restore( |
1309 selected_navigation, from_last_session, &entries); | 1309 selected_navigation, from_last_session, &entries); |
1310 DCHECK_EQ(0u, entries.size()); | 1310 DCHECK_EQ(0u, entries.size()); |
1311 | 1311 |
1312 int add_types = select ? TabStripModel::ADD_ACTIVE : | 1312 int add_types = select ? TabStripModel::ADD_ACTIVE : |
1313 TabStripModel::ADD_NONE; | 1313 TabStripModel::ADD_NONE; |
1314 if (pin) { | 1314 if (pin) { |
1315 tab_index = std::min(tab_index, tabstrip_model()->IndexOfFirstNonMiniTab()); | 1315 tab_index = std::min(tab_index, tabstrip_model()->IndexOfFirstNonMiniTab()); |
1316 add_types |= TabStripModel::ADD_PINNED; | 1316 add_types |= TabStripModel::ADD_PINNED; |
1317 } | 1317 } |
1318 tab_handler_->GetTabStripModel()->InsertTabContentsAt(tab_index, wrapper, | 1318 tab_handler_->GetTabStripModel()->InsertTabContentsAt(tab_index, wrapper, |
1319 add_types); | 1319 add_types); |
1320 if (select) { | 1320 if (select) { |
1321 window_->Activate(); | 1321 window_->Activate(); |
1322 } else { | 1322 } else { |
1323 // We set the size of the view here, before WebKit does its initial | 1323 // We set the size of the view here, before WebKit does its initial |
1324 // layout. If we don't, the initial layout of background tabs will be | 1324 // layout. If we don't, the initial layout of background tabs will be |
1325 // performed with a view width of 0, which may cause script outputs and | 1325 // performed with a view width of 0, which may cause script outputs and |
1326 // anchor link location calculations to be incorrect even after a new | 1326 // anchor link location calculations to be incorrect even after a new |
1327 // layout with proper view dimensions. TabStripModel::AddTabContents() | 1327 // layout with proper view dimensions. TabStripModel::AddTabContents() |
1328 // contains similar logic. | 1328 // contains similar logic. |
1329 new_tab->GetView()->SizeContents(window_->GetRestoredBounds().size()); | 1329 new_tab->GetView()->SizeContents(window_->GetRestoredBounds().size()); |
1330 new_tab->HideContents(); | 1330 new_tab->HideContents(); |
1331 new_tab->GetController().LoadIfNecessary(); | 1331 new_tab->controller().LoadIfNecessary(); |
1332 } | 1332 } |
1333 SessionService* session_service = | 1333 SessionService* session_service = |
1334 SessionServiceFactory::GetForProfileIfExisting(profile_); | 1334 SessionServiceFactory::GetForProfileIfExisting(profile_); |
1335 if (session_service) | 1335 if (session_service) |
1336 session_service->TabRestored(wrapper, pin); | 1336 session_service->TabRestored(wrapper, pin); |
1337 return new_tab; | 1337 return new_tab; |
1338 } | 1338 } |
1339 | 1339 |
1340 void Browser::ReplaceRestoredTab( | 1340 void Browser::ReplaceRestoredTab( |
1341 const std::vector<TabNavigation>& navigations, | 1341 const std::vector<TabNavigation>& navigations, |
1342 int selected_navigation, | 1342 int selected_navigation, |
1343 bool from_last_session, | 1343 bool from_last_session, |
1344 const std::string& extension_app_id, | 1344 const std::string& extension_app_id, |
1345 SessionStorageNamespace* session_storage_namespace) { | 1345 SessionStorageNamespace* session_storage_namespace) { |
1346 GURL restore_url = navigations.at(selected_navigation).virtual_url(); | 1346 GURL restore_url = navigations.at(selected_navigation).virtual_url(); |
1347 TabContentsWrapper* wrapper = TabContentsFactory( | 1347 TabContentsWrapper* wrapper = TabContentsFactory( |
1348 profile(), | 1348 profile(), |
1349 tab_util::GetSiteInstanceForNewTab(NULL, profile_, restore_url), | 1349 tab_util::GetSiteInstanceForNewTab(NULL, profile_, restore_url), |
1350 MSG_ROUTING_NONE, | 1350 MSG_ROUTING_NONE, |
1351 GetSelectedTabContents(), | 1351 GetSelectedTabContents(), |
1352 session_storage_namespace); | 1352 session_storage_namespace); |
1353 wrapper->extension_tab_helper()->SetExtensionAppById(extension_app_id); | 1353 wrapper->extension_tab_helper()->SetExtensionAppById(extension_app_id); |
1354 TabContents* replacement = wrapper->tab_contents(); | 1354 TabContents* replacement = wrapper->tab_contents(); |
1355 std::vector<NavigationEntry*> entries; | 1355 std::vector<NavigationEntry*> entries; |
1356 TabNavigation::CreateNavigationEntriesFromTabNavigations( | 1356 TabNavigation::CreateNavigationEntriesFromTabNavigations( |
1357 profile_, navigations, &entries); | 1357 profile_, navigations, &entries); |
1358 replacement->GetController().Restore( | 1358 replacement->controller().Restore( |
1359 selected_navigation, from_last_session, &entries); | 1359 selected_navigation, from_last_session, &entries); |
1360 DCHECK_EQ(0u, entries.size()); | 1360 DCHECK_EQ(0u, entries.size()); |
1361 | 1361 |
1362 tab_handler_->GetTabStripModel()->ReplaceNavigationControllerAt( | 1362 tab_handler_->GetTabStripModel()->ReplaceNavigationControllerAt( |
1363 tab_handler_->GetTabStripModel()->active_index(), | 1363 tab_handler_->GetTabStripModel()->active_index(), |
1364 wrapper); | 1364 wrapper); |
1365 } | 1365 } |
1366 | 1366 |
1367 bool Browser::CanRestoreTab() { | 1367 bool Browser::CanRestoreTab() { |
1368 return command_updater_.IsCommandEnabled(IDC_RESTORE_TAB); | 1368 return command_updater_.IsCommandEnabled(IDC_RESTORE_TAB); |
1369 } | 1369 } |
1370 | 1370 |
1371 bool Browser::NavigateToIndexWithDisposition(int index, | 1371 bool Browser::NavigateToIndexWithDisposition(int index, |
1372 WindowOpenDisposition disp) { | 1372 WindowOpenDisposition disp) { |
1373 NavigationController& controller = | 1373 NavigationController& controller = |
1374 GetOrCloneTabForDisposition(disp)->GetController(); | 1374 GetOrCloneTabForDisposition(disp)->controller(); |
1375 if (index < 0 || index >= controller.entry_count()) | 1375 if (index < 0 || index >= controller.entry_count()) |
1376 return false; | 1376 return false; |
1377 controller.GoToIndex(index); | 1377 controller.GoToIndex(index); |
1378 return true; | 1378 return true; |
1379 } | 1379 } |
1380 | 1380 |
1381 browser::NavigateParams Browser::GetSingletonTabNavigateParams( | 1381 browser::NavigateParams Browser::GetSingletonTabNavigateParams( |
1382 const GURL& url) { | 1382 const GURL& url) { |
1383 browser::NavigateParams params( | 1383 browser::NavigateParams params( |
1384 this, url, content::PAGE_TRANSITION_AUTO_BOOKMARK); | 1384 this, url, content::PAGE_TRANSITION_AUTO_BOOKMARK); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 TabCloseableStateWatcher* watcher = | 1493 TabCloseableStateWatcher* watcher = |
1494 g_browser_process->tab_closeable_state_watcher(); | 1494 g_browser_process->tab_closeable_state_watcher(); |
1495 bool can_close = !watcher || watcher->CanCloseBrowser(this); | 1495 bool can_close = !watcher || watcher->CanCloseBrowser(this); |
1496 if (!can_close && is_attempting_to_close_browser_) | 1496 if (!can_close && is_attempting_to_close_browser_) |
1497 CancelWindowClose(); | 1497 CancelWindowClose(); |
1498 return can_close; | 1498 return can_close; |
1499 } | 1499 } |
1500 | 1500 |
1501 bool Browser::CanGoBack() const { | 1501 bool Browser::CanGoBack() const { |
1502 return GetSelectedTabContentsWrapper()-> | 1502 return GetSelectedTabContentsWrapper()-> |
1503 tab_contents()->GetController().CanGoBack(); | 1503 tab_contents()->controller().CanGoBack(); |
1504 } | 1504 } |
1505 | 1505 |
1506 void Browser::GoBack(WindowOpenDisposition disposition) { | 1506 void Browser::GoBack(WindowOpenDisposition disposition) { |
1507 content::RecordAction(UserMetricsAction("Back")); | 1507 content::RecordAction(UserMetricsAction("Back")); |
1508 | 1508 |
1509 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); | 1509 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); |
1510 if (CanGoBack()) { | 1510 if (CanGoBack()) { |
1511 TabContents* new_tab = GetOrCloneTabForDisposition(disposition); | 1511 TabContents* new_tab = GetOrCloneTabForDisposition(disposition); |
1512 // If we are on an interstitial page and clone the tab, it won't be copied | 1512 // If we are on an interstitial page and clone the tab, it won't be copied |
1513 // to the new tab, so we don't need to go back. | 1513 // to the new tab, so we don't need to go back. |
1514 if (current_tab->tab_contents()->showing_interstitial_page() && | 1514 if (current_tab->tab_contents()->showing_interstitial_page() && |
1515 (new_tab != current_tab->tab_contents())) | 1515 (new_tab != current_tab->tab_contents())) |
1516 return; | 1516 return; |
1517 new_tab->GetController().GoBack(); | 1517 new_tab->controller().GoBack(); |
1518 } | 1518 } |
1519 } | 1519 } |
1520 | 1520 |
1521 bool Browser::CanGoForward() const { | 1521 bool Browser::CanGoForward() const { |
1522 return GetSelectedTabContentsWrapper()-> | 1522 return GetSelectedTabContentsWrapper()-> |
1523 tab_contents()->GetController().CanGoForward(); | 1523 tab_contents()->controller().CanGoForward(); |
1524 } | 1524 } |
1525 | 1525 |
1526 void Browser::GoForward(WindowOpenDisposition disposition) { | 1526 void Browser::GoForward(WindowOpenDisposition disposition) { |
1527 content::RecordAction(UserMetricsAction("Forward")); | 1527 content::RecordAction(UserMetricsAction("Forward")); |
1528 if (CanGoForward()) | 1528 if (CanGoForward()) |
1529 GetOrCloneTabForDisposition(disposition)->GetController().GoForward(); | 1529 GetOrCloneTabForDisposition(disposition)->controller().GoForward(); |
1530 } | 1530 } |
1531 | 1531 |
1532 void Browser::Reload(WindowOpenDisposition disposition) { | 1532 void Browser::Reload(WindowOpenDisposition disposition) { |
1533 content::RecordAction(UserMetricsAction("Reload")); | 1533 content::RecordAction(UserMetricsAction("Reload")); |
1534 ReloadInternal(disposition, false); | 1534 ReloadInternal(disposition, false); |
1535 } | 1535 } |
1536 | 1536 |
1537 void Browser::ReloadIgnoringCache(WindowOpenDisposition disposition) { | 1537 void Browser::ReloadIgnoringCache(WindowOpenDisposition disposition) { |
1538 content::RecordAction(UserMetricsAction("ReloadIgnoringCache")); | 1538 content::RecordAction(UserMetricsAction("ReloadIgnoringCache")); |
1539 ReloadInternal(disposition, true); | 1539 ReloadInternal(disposition, true); |
1540 } | 1540 } |
1541 | 1541 |
1542 void Browser::ReloadInternal(WindowOpenDisposition disposition, | 1542 void Browser::ReloadInternal(WindowOpenDisposition disposition, |
1543 bool ignore_cache) { | 1543 bool ignore_cache) { |
1544 // If we are showing an interstitial, treat this as an OpenURL. | 1544 // If we are showing an interstitial, treat this as an OpenURL. |
1545 TabContents* current_tab = GetSelectedTabContents(); | 1545 TabContents* current_tab = GetSelectedTabContents(); |
1546 if (current_tab && current_tab->showing_interstitial_page()) { | 1546 if (current_tab && current_tab->showing_interstitial_page()) { |
1547 NavigationEntry* entry = current_tab->GetController().GetActiveEntry(); | 1547 NavigationEntry* entry = current_tab->controller().GetActiveEntry(); |
1548 DCHECK(entry); // Should exist if interstitial is showing. | 1548 DCHECK(entry); // Should exist if interstitial is showing. |
1549 OpenURL(entry->url(), GURL(), disposition, content::PAGE_TRANSITION_RELOAD); | 1549 OpenURL(entry->url(), GURL(), disposition, content::PAGE_TRANSITION_RELOAD); |
1550 return; | 1550 return; |
1551 } | 1551 } |
1552 | 1552 |
1553 // As this is caused by a user action, give the focus to the page. | 1553 // As this is caused by a user action, give the focus to the page. |
1554 TabContents* tab = GetOrCloneTabForDisposition(disposition); | 1554 TabContents* tab = GetOrCloneTabForDisposition(disposition); |
1555 if (!tab->FocusLocationBarByDefault()) | 1555 if (!tab->FocusLocationBarByDefault()) |
1556 tab->Focus(); | 1556 tab->Focus(); |
1557 if (ignore_cache) | 1557 if (ignore_cache) |
1558 tab->GetController().ReloadIgnoringCache(true); | 1558 tab->controller().ReloadIgnoringCache(true); |
1559 else | 1559 else |
1560 tab->GetController().Reload(true); | 1560 tab->controller().Reload(true); |
1561 } | 1561 } |
1562 | 1562 |
1563 void Browser::Home(WindowOpenDisposition disposition) { | 1563 void Browser::Home(WindowOpenDisposition disposition) { |
1564 content::RecordAction(UserMetricsAction("Home")); | 1564 content::RecordAction(UserMetricsAction("Home")); |
1565 OpenURL( | 1565 OpenURL( |
1566 profile_->GetHomePage(), GURL(), disposition, | 1566 profile_->GetHomePage(), GURL(), disposition, |
1567 content::PageTransitionFromInt( | 1567 content::PageTransitionFromInt( |
1568 content::PAGE_TRANSITION_AUTO_BOOKMARK | | 1568 content::PAGE_TRANSITION_AUTO_BOOKMARK | |
1569 content::PAGE_TRANSITION_HOME_PAGE)); | 1569 content::PAGE_TRANSITION_HOME_PAGE)); |
1570 } | 1570 } |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 | 2054 |
2055 void Browser::OpenCreateShortcutsDialog() { | 2055 void Browser::OpenCreateShortcutsDialog() { |
2056 content::RecordAction(UserMetricsAction("CreateShortcut")); | 2056 content::RecordAction(UserMetricsAction("CreateShortcut")); |
2057 #if !defined(OS_MACOSX) | 2057 #if !defined(OS_MACOSX) |
2058 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); | 2058 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); |
2059 DCHECK(current_tab && | 2059 DCHECK(current_tab && |
2060 web_app::IsValidUrl(current_tab->tab_contents()->GetURL())) << | 2060 web_app::IsValidUrl(current_tab->tab_contents()->GetURL())) << |
2061 "Menu item should be disabled."; | 2061 "Menu item should be disabled."; |
2062 | 2062 |
2063 NavigationEntry* entry = | 2063 NavigationEntry* entry = |
2064 current_tab->tab_contents()->GetController().GetLastCommittedEntry(); | 2064 current_tab->tab_contents()->controller().GetLastCommittedEntry(); |
2065 if (!entry) | 2065 if (!entry) |
2066 return; | 2066 return; |
2067 | 2067 |
2068 // RVH's GetApplicationInfo should not be called before it returns. | 2068 // RVH's GetApplicationInfo should not be called before it returns. |
2069 DCHECK(pending_web_app_action_ == NONE); | 2069 DCHECK(pending_web_app_action_ == NONE); |
2070 pending_web_app_action_ = CREATE_SHORTCUT; | 2070 pending_web_app_action_ = CREATE_SHORTCUT; |
2071 | 2071 |
2072 // Start fetching web app info for CreateApplicationShortcut dialog and show | 2072 // Start fetching web app info for CreateApplicationShortcut dialog and show |
2073 // the dialog when the data is available in OnDidGetApplicationInfo. | 2073 // the dialog when the data is available in OnDidGetApplicationInfo. |
2074 current_tab->extension_tab_helper()->GetApplicationInfo(entry->page_id()); | 2074 current_tab->extension_tab_helper()->GetApplicationInfo(entry->page_id()); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2168 } | 2168 } |
2169 | 2169 |
2170 void Browser::ShowAboutConflictsTab() { | 2170 void Browser::ShowAboutConflictsTab() { |
2171 content::RecordAction(UserMetricsAction("AboutConflicts")); | 2171 content::RecordAction(UserMetricsAction("AboutConflicts")); |
2172 ShowSingletonTab(GURL(chrome::kChromeUIConflictsURL)); | 2172 ShowSingletonTab(GURL(chrome::kChromeUIConflictsURL)); |
2173 } | 2173 } |
2174 | 2174 |
2175 void Browser::ShowBrokenPageTab(TabContents* contents) { | 2175 void Browser::ShowBrokenPageTab(TabContents* contents) { |
2176 content::RecordAction(UserMetricsAction("ReportBug")); | 2176 content::RecordAction(UserMetricsAction("ReportBug")); |
2177 string16 page_title = contents->GetTitle(); | 2177 string16 page_title = contents->GetTitle(); |
2178 NavigationEntry* entry = contents->GetController().GetActiveEntry(); | 2178 NavigationEntry* entry = contents->controller().GetActiveEntry(); |
2179 if (!entry) | 2179 if (!entry) |
2180 return; | 2180 return; |
2181 std::string page_url = entry->url().spec(); | 2181 std::string page_url = entry->url().spec(); |
2182 std::vector<std::string> subst; | 2182 std::vector<std::string> subst; |
2183 subst.push_back(UTF16ToASCII(page_title)); | 2183 subst.push_back(UTF16ToASCII(page_title)); |
2184 subst.push_back(page_url); | 2184 subst.push_back(page_url); |
2185 std::string report_page_url = | 2185 std::string report_page_url = |
2186 ReplaceStringPlaceholders(kBrokenPageUrl, subst, NULL); | 2186 ReplaceStringPlaceholders(kBrokenPageUrl, subst, NULL); |
2187 ShowSingletonTab(GURL(report_page_url)); | 2187 ShowSingletonTab(GURL(report_page_url)); |
2188 } | 2188 } |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3088 TabContentsWrapper* Browser::CreateTabContentsForURL( | 3088 TabContentsWrapper* Browser::CreateTabContentsForURL( |
3089 const GURL& url, const content::Referrer& referrer, Profile* profile, | 3089 const GURL& url, const content::Referrer& referrer, Profile* profile, |
3090 content::PageTransition transition, bool defer_load, | 3090 content::PageTransition transition, bool defer_load, |
3091 SiteInstance* instance) const { | 3091 SiteInstance* instance) const { |
3092 TabContentsWrapper* contents = TabContentsFactory(profile, instance, | 3092 TabContentsWrapper* contents = TabContentsFactory(profile, instance, |
3093 MSG_ROUTING_NONE, | 3093 MSG_ROUTING_NONE, |
3094 GetSelectedTabContents(), NULL); | 3094 GetSelectedTabContents(), NULL); |
3095 if (!defer_load) { | 3095 if (!defer_load) { |
3096 // Load the initial URL before adding the new tab contents to the tab strip | 3096 // Load the initial URL before adding the new tab contents to the tab strip |
3097 // so that the tab contents has navigation state. | 3097 // so that the tab contents has navigation state. |
3098 contents->tab_contents()->GetController().LoadURL( | 3098 contents->tab_contents()->controller().LoadURL( |
3099 url, referrer, transition, std::string()); | 3099 url, referrer, transition, std::string()); |
3100 } | 3100 } |
3101 | 3101 |
3102 return contents; | 3102 return contents; |
3103 } | 3103 } |
3104 | 3104 |
3105 bool Browser::CanDuplicateContentsAt(int index) { | 3105 bool Browser::CanDuplicateContentsAt(int index) { |
3106 NavigationController& nc = GetTabContentsAt(index)->GetController(); | 3106 NavigationController& nc = GetTabContentsAt(index)->controller(); |
3107 return nc.tab_contents() && nc.GetLastCommittedEntry(); | 3107 return nc.tab_contents() && nc.GetLastCommittedEntry(); |
3108 } | 3108 } |
3109 | 3109 |
3110 void Browser::DuplicateContentsAt(int index) { | 3110 void Browser::DuplicateContentsAt(int index) { |
3111 TabContentsWrapper* contents = GetTabContentsWrapperAt(index); | 3111 TabContentsWrapper* contents = GetTabContentsWrapperAt(index); |
3112 CHECK(contents); | 3112 CHECK(contents); |
3113 TabContentsWrapper* contents_dupe = contents->Clone(); | 3113 TabContentsWrapper* contents_dupe = contents->Clone(); |
3114 | 3114 |
3115 bool pinned = false; | 3115 bool pinned = false; |
3116 if (CanSupportWindowFeature(FEATURE_TABSTRIP)) { | 3116 if (CanSupportWindowFeature(FEATURE_TABSTRIP)) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3175 | 3175 |
3176 // We don't create historical tabs for print preview tabs. | 3176 // We don't create historical tabs for print preview tabs. |
3177 if (contents->tab_contents()->GetURL() == GURL(chrome::kChromeUIPrintURL)) | 3177 if (contents->tab_contents()->GetURL() == GURL(chrome::kChromeUIPrintURL)) |
3178 return; | 3178 return; |
3179 | 3179 |
3180 TabRestoreService* service = | 3180 TabRestoreService* service = |
3181 TabRestoreServiceFactory::GetForProfile(profile()); | 3181 TabRestoreServiceFactory::GetForProfile(profile()); |
3182 | 3182 |
3183 // We only create historical tab entries for tabbed browser windows. | 3183 // We only create historical tab entries for tabbed browser windows. |
3184 if (service && CanSupportWindowFeature(FEATURE_TABSTRIP)) { | 3184 if (service && CanSupportWindowFeature(FEATURE_TABSTRIP)) { |
3185 service->CreateHistoricalTab(&contents->tab_contents()->GetController(), | 3185 service->CreateHistoricalTab(&contents->tab_contents()->controller(), |
3186 tab_handler_->GetTabStripModel()->GetIndexOfTabContents(contents)); | 3186 tab_handler_->GetTabStripModel()->GetIndexOfTabContents(contents)); |
3187 } | 3187 } |
3188 } | 3188 } |
3189 | 3189 |
3190 bool Browser::RunUnloadListenerBeforeClosing(TabContentsWrapper* contents) { | 3190 bool Browser::RunUnloadListenerBeforeClosing(TabContentsWrapper* contents) { |
3191 return Browser::RunUnloadEventsHelper(contents->tab_contents()); | 3191 return Browser::RunUnloadEventsHelper(contents->tab_contents()); |
3192 } | 3192 } |
3193 | 3193 |
3194 bool Browser::CanReloadContents(TabContents* source) const { | 3194 bool Browser::CanReloadContents(TabContents* source) const { |
3195 return !is_devtools(); | 3195 return !is_devtools(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3264 content::Source<TabContents>(contents->tab_contents())); | 3264 content::Source<TabContents>(contents->tab_contents())); |
3265 } | 3265 } |
3266 | 3266 |
3267 void Browser::TabClosingAt(TabStripModel* tab_strip_model, | 3267 void Browser::TabClosingAt(TabStripModel* tab_strip_model, |
3268 TabContentsWrapper* contents, | 3268 TabContentsWrapper* contents, |
3269 int index) { | 3269 int index) { |
3270 fullscreen_controller_->OnTabClosing(contents->tab_contents()); | 3270 fullscreen_controller_->OnTabClosing(contents->tab_contents()); |
3271 content::NotificationService::current()->Notify( | 3271 content::NotificationService::current()->Notify( |
3272 content::NOTIFICATION_TAB_CLOSING, | 3272 content::NOTIFICATION_TAB_CLOSING, |
3273 content::Source<NavigationController>( | 3273 content::Source<NavigationController>( |
3274 &contents->tab_contents()->GetController()), | 3274 &contents->tab_contents()->controller()), |
3275 content::NotificationService::NoDetails()); | 3275 content::NotificationService::NoDetails()); |
3276 | 3276 |
3277 // Sever the TabContents' connection back to us. | 3277 // Sever the TabContents' connection back to us. |
3278 SetAsDelegate(contents, NULL); | 3278 SetAsDelegate(contents, NULL); |
3279 } | 3279 } |
3280 | 3280 |
3281 void Browser::TabDetachedAt(TabContentsWrapper* contents, int index) { | 3281 void Browser::TabDetachedAt(TabContentsWrapper* contents, int index) { |
3282 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH); | 3282 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH); |
3283 } | 3283 } |
3284 | 3284 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3362 } | 3362 } |
3363 | 3363 |
3364 void Browser::TabReplacedAt(TabStripModel* tab_strip_model, | 3364 void Browser::TabReplacedAt(TabStripModel* tab_strip_model, |
3365 TabContentsWrapper* old_contents, | 3365 TabContentsWrapper* old_contents, |
3366 TabContentsWrapper* new_contents, | 3366 TabContentsWrapper* new_contents, |
3367 int index) { | 3367 int index) { |
3368 TabDetachedAtImpl(old_contents, index, DETACH_TYPE_REPLACE); | 3368 TabDetachedAtImpl(old_contents, index, DETACH_TYPE_REPLACE); |
3369 TabInsertedAt(new_contents, index, | 3369 TabInsertedAt(new_contents, index, |
3370 (index == tab_handler_->GetTabStripModel()->active_index())); | 3370 (index == tab_handler_->GetTabStripModel()->active_index())); |
3371 | 3371 |
3372 int entry_count = new_contents->tab_contents()->GetController().entry_count(); | 3372 int entry_count = new_contents->tab_contents()->controller().entry_count(); |
3373 if (entry_count > 0) { | 3373 if (entry_count > 0) { |
3374 // Send out notification so that observers are updated appropriately. | 3374 // Send out notification so that observers are updated appropriately. |
3375 new_contents->tab_contents()->GetController().NotifyEntryChanged( | 3375 new_contents->tab_contents()->controller().NotifyEntryChanged( |
3376 new_contents->tab_contents()->GetController().GetEntryAtIndex( | 3376 new_contents->tab_contents()->controller().GetEntryAtIndex( |
3377 entry_count - 1), | 3377 entry_count - 1), |
3378 entry_count - 1); | 3378 entry_count - 1); |
3379 } | 3379 } |
3380 | 3380 |
3381 SessionService* session_service = | 3381 SessionService* session_service = |
3382 SessionServiceFactory::GetForProfile(profile()); | 3382 SessionServiceFactory::GetForProfile(profile()); |
3383 if (session_service) { | 3383 if (session_service) { |
3384 // The new_contents may end up with a different navigation stack. Force | 3384 // The new_contents may end up with a different navigation stack. Force |
3385 // the session service to update itself. | 3385 // the session service to update itself. |
3386 session_service->TabRestored( | 3386 session_service->TabRestored( |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3534 if (GetStatusBubble()) { | 3534 if (GetStatusBubble()) { |
3535 GetStatusBubble()->SetStatus( | 3535 GetStatusBubble()->SetStatus( |
3536 GetSelectedTabContentsWrapper()->core_tab_helper()->GetStatusText()); | 3536 GetSelectedTabContentsWrapper()->core_tab_helper()->GetStatusText()); |
3537 } | 3537 } |
3538 | 3538 |
3539 if (!is_loading && pending_web_app_action_ == UPDATE_SHORTCUT) { | 3539 if (!is_loading && pending_web_app_action_ == UPDATE_SHORTCUT) { |
3540 // Schedule a shortcut update when web application info is available if | 3540 // Schedule a shortcut update when web application info is available if |
3541 // last committed entry is not NULL. Last committed entry could be NULL | 3541 // last committed entry is not NULL. Last committed entry could be NULL |
3542 // when an interstitial page is injected (e.g. bad https certificate, | 3542 // when an interstitial page is injected (e.g. bad https certificate, |
3543 // malware site etc). When this happens, we abort the shortcut update. | 3543 // malware site etc). When this happens, we abort the shortcut update. |
3544 NavigationEntry* entry = source->GetController().GetLastCommittedEntry(); | 3544 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); |
3545 if (entry) { | 3545 if (entry) { |
3546 TabContentsWrapper::GetCurrentWrapperForContents(source)-> | 3546 TabContentsWrapper::GetCurrentWrapperForContents(source)-> |
3547 extension_tab_helper()->GetApplicationInfo(entry->page_id()); | 3547 extension_tab_helper()->GetApplicationInfo(entry->page_id()); |
3548 } else { | 3548 } else { |
3549 pending_web_app_action_ = NONE; | 3549 pending_web_app_action_ = NONE; |
3550 } | 3550 } |
3551 } | 3551 } |
3552 } | 3552 } |
3553 } | 3553 } |
3554 | 3554 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3635 content::Source<Browser>(this), | 3635 content::Source<Browser>(this), |
3636 content::NotificationService::NoDetails()); | 3636 content::NotificationService::NoDetails()); |
3637 return false; | 3637 return false; |
3638 } | 3638 } |
3639 | 3639 |
3640 bool Browser::IsApplication() const { | 3640 bool Browser::IsApplication() const { |
3641 return is_app(); | 3641 return is_app(); |
3642 } | 3642 } |
3643 | 3643 |
3644 void Browser::ConvertContentsToApplication(TabContents* contents) { | 3644 void Browser::ConvertContentsToApplication(TabContents* contents) { |
3645 const GURL& url = contents->GetController().GetActiveEntry()->url(); | 3645 const GURL& url = contents->controller().GetActiveEntry()->url(); |
3646 std::string app_name = web_app::GenerateApplicationNameFromURL(url); | 3646 std::string app_name = web_app::GenerateApplicationNameFromURL(url); |
3647 | 3647 |
3648 DetachContents(contents); | 3648 DetachContents(contents); |
3649 Browser* app_browser = Browser::CreateForApp( | 3649 Browser* app_browser = Browser::CreateForApp( |
3650 TYPE_POPUP, app_name, gfx::Rect(), profile_); | 3650 TYPE_POPUP, app_name, gfx::Rect(), profile_); |
3651 TabContentsWrapper* wrapper = | 3651 TabContentsWrapper* wrapper = |
3652 TabContentsWrapper::GetCurrentWrapperForContents(contents); | 3652 TabContentsWrapper::GetCurrentWrapperForContents(contents); |
3653 if (!wrapper) | 3653 if (!wrapper) |
3654 wrapper = new TabContentsWrapper(contents); | 3654 wrapper = new TabContentsWrapper(contents); |
3655 app_browser->tabstrip_model()->AppendTabContents(wrapper, true); | 3655 app_browser->tabstrip_model()->AppendTabContents(wrapper, true); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3753 if ((download->GetTotalBytes() > 0) && | 3753 if ((download->GetTotalBytes() > 0) && |
3754 !ChromeDownloadManagerDelegate::IsExtensionDownload(download) && | 3754 !ChromeDownloadManagerDelegate::IsExtensionDownload(download) && |
3755 platform_util::IsVisible(shelf_tab->GetNativeView()) && | 3755 platform_util::IsVisible(shelf_tab->GetNativeView()) && |
3756 ui::Animation::ShouldRenderRichAnimation()) { | 3756 ui::Animation::ShouldRenderRichAnimation()) { |
3757 DownloadStartedAnimation::Show(shelf_tab); | 3757 DownloadStartedAnimation::Show(shelf_tab); |
3758 } | 3758 } |
3759 #endif | 3759 #endif |
3760 } | 3760 } |
3761 | 3761 |
3762 // If the download occurs in a new tab, close it. | 3762 // If the download occurs in a new tab, close it. |
3763 if (source->GetController().IsInitialNavigation() && tab_count() > 1) | 3763 if (source->controller().IsInitialNavigation() && tab_count() > 1) |
3764 CloseContents(source); | 3764 CloseContents(source); |
3765 } | 3765 } |
3766 | 3766 |
3767 void Browser::ShowPageInfo(content::BrowserContext* browser_context, | 3767 void Browser::ShowPageInfo(content::BrowserContext* browser_context, |
3768 const GURL& url, | 3768 const GURL& url, |
3769 const NavigationEntry::SSLStatus& ssl, | 3769 const NavigationEntry::SSLStatus& ssl, |
3770 bool show_history) { | 3770 bool show_history) { |
3771 Profile* profile = Profile::FromBrowserContext(browser_context); | 3771 Profile* profile = Profile::FromBrowserContext(browser_context); |
3772 window()->ShowPageInfo(profile, url, ssl, show_history); | 3772 window()->ShowPageInfo(profile, url, ssl, show_history); |
3773 } | 3773 } |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3978 | 3978 |
3979 /////////////////////////////////////////////////////////////////////////////// | 3979 /////////////////////////////////////////////////////////////////////////////// |
3980 // Browser, CoreTabHelperDelegate implementation: | 3980 // Browser, CoreTabHelperDelegate implementation: |
3981 | 3981 |
3982 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source, | 3982 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source, |
3983 int32 page_id) { | 3983 int32 page_id) { |
3984 if (GetSelectedTabContentsWrapper() != source) | 3984 if (GetSelectedTabContentsWrapper() != source) |
3985 return; | 3985 return; |
3986 | 3986 |
3987 NavigationEntry* entry = | 3987 NavigationEntry* entry = |
3988 source->tab_contents()->GetController().GetLastCommittedEntry(); | 3988 source->tab_contents()->controller().GetLastCommittedEntry(); |
3989 if (!entry || (entry->page_id() != page_id)) | 3989 if (!entry || (entry->page_id() != page_id)) |
3990 return; | 3990 return; |
3991 | 3991 |
3992 switch (pending_web_app_action_) { | 3992 switch (pending_web_app_action_) { |
3993 case CREATE_SHORTCUT: { | 3993 case CREATE_SHORTCUT: { |
3994 window()->ShowCreateWebAppShortcutsDialog(source); | 3994 window()->ShowCreateWebAppShortcutsDialog(source); |
3995 break; | 3995 break; |
3996 } | 3996 } |
3997 case UPDATE_SHORTCUT: { | 3997 case UPDATE_SHORTCUT: { |
3998 web_app::UpdateShortcutForTabContents(source); | 3998 web_app::UpdateShortcutForTabContents(source); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4089 break; | 4089 break; |
4090 | 4090 |
4091 case content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED: | 4091 case content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED: |
4092 // When the current tab's SSL state changes, we need to update the URL | 4092 // When the current tab's SSL state changes, we need to update the URL |
4093 // bar to reflect the new state. Note that it's possible for the selected | 4093 // bar to reflect the new state. Note that it's possible for the selected |
4094 // tab contents to be NULL. This is because we listen for all sources | 4094 // tab contents to be NULL. This is because we listen for all sources |
4095 // (NavigationControllers) for convenience, so the notification could | 4095 // (NavigationControllers) for convenience, so the notification could |
4096 // actually be for a different window while we're doing asynchronous | 4096 // actually be for a different window while we're doing asynchronous |
4097 // closing of this one. | 4097 // closing of this one. |
4098 if (GetSelectedTabContents() && | 4098 if (GetSelectedTabContents() && |
4099 &GetSelectedTabContents()->GetController() == | 4099 &GetSelectedTabContents()->controller() == |
4100 content::Source<NavigationController>(source).ptr()) | 4100 content::Source<NavigationController>(source).ptr()) |
4101 UpdateToolbar(false); | 4101 UpdateToolbar(false); |
4102 break; | 4102 break; |
4103 | 4103 |
4104 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: { | 4104 case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED: { |
4105 // Show the UI if the extension was disabled for escalated permissions. | 4105 // Show the UI if the extension was disabled for escalated permissions. |
4106 Profile* profile = content::Source<Profile>(source).ptr(); | 4106 Profile* profile = content::Source<Profile>(source).ptr(); |
4107 if (profile_->IsSameProfile(profile)) { | 4107 if (profile_->IsSameProfile(profile)) { |
4108 ExtensionService* service = profile->GetExtensionService(); | 4108 ExtensionService* service = profile->GetExtensionService(); |
4109 DCHECK(service); | 4109 DCHECK(service); |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4563 UpdateCommandsForBookmarkBar(); | 4563 UpdateCommandsForBookmarkBar(); |
4564 } | 4564 } |
4565 | 4565 |
4566 void Browser::UpdateCommandsForTabState() { | 4566 void Browser::UpdateCommandsForTabState() { |
4567 TabContents* current_tab = GetSelectedTabContents(); | 4567 TabContents* current_tab = GetSelectedTabContents(); |
4568 TabContentsWrapper* current_tab_wrapper = GetSelectedTabContentsWrapper(); | 4568 TabContentsWrapper* current_tab_wrapper = GetSelectedTabContentsWrapper(); |
4569 if (!current_tab || !current_tab_wrapper) // May be NULL during tab restore. | 4569 if (!current_tab || !current_tab_wrapper) // May be NULL during tab restore. |
4570 return; | 4570 return; |
4571 | 4571 |
4572 // Navigation commands | 4572 // Navigation commands |
4573 NavigationController& nc = current_tab->GetController(); | 4573 NavigationController& nc = current_tab->controller(); |
4574 command_updater_.UpdateCommandEnabled(IDC_BACK, nc.CanGoBack()); | 4574 command_updater_.UpdateCommandEnabled(IDC_BACK, nc.CanGoBack()); |
4575 command_updater_.UpdateCommandEnabled(IDC_FORWARD, nc.CanGoForward()); | 4575 command_updater_.UpdateCommandEnabled(IDC_FORWARD, nc.CanGoForward()); |
4576 command_updater_.UpdateCommandEnabled(IDC_RELOAD, | 4576 command_updater_.UpdateCommandEnabled(IDC_RELOAD, |
4577 CanReloadContents(current_tab)); | 4577 CanReloadContents(current_tab)); |
4578 command_updater_.UpdateCommandEnabled(IDC_RELOAD_IGNORING_CACHE, | 4578 command_updater_.UpdateCommandEnabled(IDC_RELOAD_IGNORING_CACHE, |
4579 CanReloadContents(current_tab)); | 4579 CanReloadContents(current_tab)); |
4580 | 4580 |
4581 // Window management commands | 4581 // Window management commands |
4582 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, | 4582 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, |
4583 !is_app() && CanDuplicateContentsAt(active_index())); | 4583 !is_app() && CanDuplicateContentsAt(active_index())); |
4584 | 4584 |
4585 // Page-related commands | 4585 // Page-related commands |
4586 window_->SetStarredState( | 4586 window_->SetStarredState( |
4587 current_tab_wrapper->bookmark_tab_helper()->is_starred()); | 4587 current_tab_wrapper->bookmark_tab_helper()->is_starred()); |
4588 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, | 4588 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, |
4589 current_tab->GetController().CanViewSource()); | 4589 current_tab->controller().CanViewSource()); |
4590 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, | 4590 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, |
4591 toolbar_model_.ShouldDisplayURL() && current_tab->GetURL().is_valid()); | 4591 toolbar_model_.ShouldDisplayURL() && current_tab->GetURL().is_valid()); |
4592 if (is_devtools()) | 4592 if (is_devtools()) |
4593 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false); | 4593 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false); |
4594 | 4594 |
4595 // Changing the encoding is not possible on Chrome-internal webpages. | 4595 // Changing the encoding is not possible on Chrome-internal webpages. |
4596 bool is_chrome_internal = HasInternalURL(nc.GetActiveEntry()); | 4596 bool is_chrome_internal = HasInternalURL(nc.GetActiveEntry()); |
4597 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, | 4597 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, |
4598 !is_chrome_internal && SavePackage::IsSavableContents( | 4598 !is_chrome_internal && SavePackage::IsSavableContents( |
4599 current_tab->contents_mime_type())); | 4599 current_tab->contents_mime_type())); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4734 // synchronously by NavigationStateChanged. | 4734 // synchronously by NavigationStateChanged. |
4735 UpdateToolbar(false); | 4735 UpdateToolbar(false); |
4736 changed_flags &= ~TabContents::INVALIDATE_URL; | 4736 changed_flags &= ~TabContents::INVALIDATE_URL; |
4737 } | 4737 } |
4738 if (changed_flags & TabContents::INVALIDATE_LOAD) { | 4738 if (changed_flags & TabContents::INVALIDATE_LOAD) { |
4739 // Update the loading state synchronously. This is so the throbber will | 4739 // Update the loading state synchronously. This is so the throbber will |
4740 // immediately start/stop, which gives a more snappy feel. We want to do | 4740 // immediately start/stop, which gives a more snappy feel. We want to do |
4741 // this for any tab so they start & stop quickly. | 4741 // this for any tab so they start & stop quickly. |
4742 tab_handler_->GetTabStripModel()->UpdateTabContentsStateAt( | 4742 tab_handler_->GetTabStripModel()->UpdateTabContentsStateAt( |
4743 tab_handler_->GetTabStripModel()->GetIndexOfController( | 4743 tab_handler_->GetTabStripModel()->GetIndexOfController( |
4744 &source->GetController()), | 4744 &source->controller()), |
4745 TabStripModelObserver::LOADING_ONLY); | 4745 TabStripModelObserver::LOADING_ONLY); |
4746 // The status bubble needs to be updated during INVALIDATE_LOAD too, but | 4746 // The status bubble needs to be updated during INVALIDATE_LOAD too, but |
4747 // we do that asynchronously by not stripping INVALIDATE_LOAD from | 4747 // we do that asynchronously by not stripping INVALIDATE_LOAD from |
4748 // changed_flags. | 4748 // changed_flags. |
4749 } | 4749 } |
4750 | 4750 |
4751 if (changed_flags & TabContents::INVALIDATE_TITLE && !source->IsLoading()) { | 4751 if (changed_flags & TabContents::INVALIDATE_TITLE && !source->IsLoading()) { |
4752 // To correctly calculate whether the title changed while not loading | 4752 // To correctly calculate whether the title changed while not loading |
4753 // we need to process the update synchronously. This state only matters for | 4753 // we need to process the update synchronously. This state only matters for |
4754 // the TabStripModel, so we notify the TabStripModel now and notify others | 4754 // the TabStripModel, so we notify the TabStripModel now and notify others |
4755 // asynchronously. | 4755 // asynchronously. |
4756 tab_handler_->GetTabStripModel()->UpdateTabContentsStateAt( | 4756 tab_handler_->GetTabStripModel()->UpdateTabContentsStateAt( |
4757 tab_handler_->GetTabStripModel()->GetIndexOfController( | 4757 tab_handler_->GetTabStripModel()->GetIndexOfController( |
4758 &source->GetController()), | 4758 &source->controller()), |
4759 TabStripModelObserver::TITLE_NOT_LOADING); | 4759 TabStripModelObserver::TITLE_NOT_LOADING); |
4760 } | 4760 } |
4761 | 4761 |
4762 // If the only updates were synchronously handled above, we're done. | 4762 // If the only updates were synchronously handled above, we're done. |
4763 if (changed_flags == 0) | 4763 if (changed_flags == 0) |
4764 return; | 4764 return; |
4765 | 4765 |
4766 // Save the dirty bits. | 4766 // Save the dirty bits. |
4767 scheduled_updates_[source] |= changed_flags; | 4767 scheduled_updates_[source] |= changed_flags; |
4768 | 4768 |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5154 INSTANT_COMMIT_PRESSED_ENTER)), | 5154 INSTANT_COMMIT_PRESSED_ENTER)), |
5155 content::NotificationService::NoDetails()); | 5155 content::NotificationService::NoDetails()); |
5156 return true; | 5156 return true; |
5157 } | 5157 } |
5158 if (disposition == NEW_FOREGROUND_TAB) { | 5158 if (disposition == NEW_FOREGROUND_TAB) { |
5159 TabContentsWrapper* preview_contents = instant()->ReleasePreviewContents( | 5159 TabContentsWrapper* preview_contents = instant()->ReleasePreviewContents( |
5160 INSTANT_COMMIT_PRESSED_ENTER); | 5160 INSTANT_COMMIT_PRESSED_ENTER); |
5161 // HideInstant is invoked after release so that InstantController is not | 5161 // HideInstant is invoked after release so that InstantController is not |
5162 // active when HideInstant asks it for its state. | 5162 // active when HideInstant asks it for its state. |
5163 HideInstant(); | 5163 HideInstant(); |
5164 preview_contents->tab_contents()->GetController().PruneAllButActive(); | 5164 preview_contents->tab_contents()->controller().PruneAllButActive(); |
5165 tab_handler_->GetTabStripModel()->AddTabContents( | 5165 tab_handler_->GetTabStripModel()->AddTabContents( |
5166 preview_contents, | 5166 preview_contents, |
5167 -1, | 5167 -1, |
5168 instant()->last_transition_type(), | 5168 instant()->last_transition_type(), |
5169 TabStripModel::ADD_ACTIVE); | 5169 TabStripModel::ADD_ACTIVE); |
5170 instant()->CompleteRelease(preview_contents); | 5170 instant()->CompleteRelease(preview_contents); |
5171 content::NotificationService::current()->Notify( | 5171 content::NotificationService::current()->Notify( |
5172 chrome::NOTIFICATION_INSTANT_COMMITTED, | 5172 chrome::NOTIFICATION_INSTANT_COMMITTED, |
5173 content::Source<TabContentsWrapper>(preview_contents), | 5173 content::Source<TabContentsWrapper>(preview_contents), |
5174 content::NotificationService::NoDetails()); | 5174 content::NotificationService::NoDetails()); |
(...skipping 11 matching lines...) Expand all Loading... |
5186 !profile()->IsOffTheRecord()) { | 5186 !profile()->IsOffTheRecord()) { |
5187 instant_.reset(new InstantController(profile_, this)); | 5187 instant_.reset(new InstantController(profile_, this)); |
5188 instant_unload_handler_.reset(new InstantUnloadHandler(this)); | 5188 instant_unload_handler_.reset(new InstantUnloadHandler(this)); |
5189 } | 5189 } |
5190 } | 5190 } |
5191 | 5191 |
5192 void Browser::ViewSource(TabContentsWrapper* contents) { | 5192 void Browser::ViewSource(TabContentsWrapper* contents) { |
5193 DCHECK(contents); | 5193 DCHECK(contents); |
5194 | 5194 |
5195 NavigationEntry* active_entry = | 5195 NavigationEntry* active_entry = |
5196 contents->tab_contents()->GetController().GetActiveEntry(); | 5196 contents->tab_contents()->controller().GetActiveEntry(); |
5197 if (!active_entry) | 5197 if (!active_entry) |
5198 return; | 5198 return; |
5199 | 5199 |
5200 ViewSource(contents, active_entry->url(), active_entry->content_state()); | 5200 ViewSource(contents, active_entry->url(), active_entry->content_state()); |
5201 } | 5201 } |
5202 | 5202 |
5203 void Browser::ViewSource(TabContentsWrapper* contents, | 5203 void Browser::ViewSource(TabContentsWrapper* contents, |
5204 const GURL& url, | 5204 const GURL& url, |
5205 const std::string& content_state) { | 5205 const std::string& content_state) { |
5206 content::RecordAction(UserMetricsAction("ViewSource")); | 5206 content::RecordAction(UserMetricsAction("ViewSource")); |
5207 DCHECK(contents); | 5207 DCHECK(contents); |
5208 | 5208 |
5209 TabContentsWrapper* view_source_contents = contents->Clone(); | 5209 TabContentsWrapper* view_source_contents = contents->Clone(); |
5210 view_source_contents->tab_contents()->GetController().PruneAllButActive(); | 5210 view_source_contents->tab_contents()->controller().PruneAllButActive(); |
5211 NavigationEntry* active_entry = | 5211 NavigationEntry* active_entry = |
5212 view_source_contents->tab_contents()->GetController().GetActiveEntry(); | 5212 view_source_contents->tab_contents()->controller().GetActiveEntry(); |
5213 if (!active_entry) | 5213 if (!active_entry) |
5214 return; | 5214 return; |
5215 | 5215 |
5216 GURL view_source_url = GURL(chrome::kViewSourceScheme + std::string(":") + | 5216 GURL view_source_url = GURL(chrome::kViewSourceScheme + std::string(":") + |
5217 url.spec()); | 5217 url.spec()); |
5218 active_entry->set_virtual_url(view_source_url); | 5218 active_entry->set_virtual_url(view_source_url); |
5219 | 5219 |
5220 // Do not restore scroller position. | 5220 // Do not restore scroller position. |
5221 active_entry->set_content_state( | 5221 active_entry->set_content_state( |
5222 webkit_glue::RemoveScrollOffsetFromHistoryState(content_state)); | 5222 webkit_glue::RemoveScrollOffsetFromHistoryState(content_state)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5256 SessionServiceFactory::GetForProfileIfExisting(profile_); | 5256 SessionServiceFactory::GetForProfileIfExisting(profile_); |
5257 if (session_service) | 5257 if (session_service) |
5258 session_service->TabRestored(view_source_contents, false); | 5258 session_service->TabRestored(view_source_contents, false); |
5259 } | 5259 } |
5260 | 5260 |
5261 int Browser::GetContentRestrictionsForSelectedTab() { | 5261 int Browser::GetContentRestrictionsForSelectedTab() { |
5262 int content_restrictions = 0; | 5262 int content_restrictions = 0; |
5263 TabContents* current_tab = GetSelectedTabContents(); | 5263 TabContents* current_tab = GetSelectedTabContents(); |
5264 if (current_tab) { | 5264 if (current_tab) { |
5265 content_restrictions = current_tab->content_restrictions(); | 5265 content_restrictions = current_tab->content_restrictions(); |
5266 NavigationEntry* active_entry = | 5266 NavigationEntry* active_entry = current_tab->controller().GetActiveEntry(); |
5267 current_tab->GetController().GetActiveEntry(); | |
5268 // See comment in UpdateCommandsForTabState about why we call url(). | 5267 // See comment in UpdateCommandsForTabState about why we call url(). |
5269 if (!SavePackage::IsSavableURL(active_entry ? active_entry->url() : GURL())) | 5268 if (!SavePackage::IsSavableURL(active_entry ? active_entry->url() : GURL())) |
5270 content_restrictions |= content::CONTENT_RESTRICTION_SAVE; | 5269 content_restrictions |= content::CONTENT_RESTRICTION_SAVE; |
5271 } | 5270 } |
5272 return content_restrictions; | 5271 return content_restrictions; |
5273 } | 5272 } |
5274 | 5273 |
5275 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { | 5274 void Browser::UpdateBookmarkBarState(BookmarkBarStateChangeReason reason) { |
5276 BookmarkBar::State state; | 5275 BookmarkBar::State state; |
5277 // The bookmark bar is hidden in fullscreen mode, unless on the new tab page. | 5276 // The bookmark bar is hidden in fullscreen mode, unless on the new tab page. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5357 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); | 5356 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); |
5358 } else { | 5357 } else { |
5359 GlobalErrorService* service = | 5358 GlobalErrorService* service = |
5360 GlobalErrorServiceFactory::GetForProfile(profile()); | 5359 GlobalErrorServiceFactory::GetForProfile(profile()); |
5361 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); | 5360 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); |
5362 if (error) { | 5361 if (error) { |
5363 error->ShowBubbleView(this); | 5362 error->ShowBubbleView(this); |
5364 } | 5363 } |
5365 } | 5364 } |
5366 } | 5365 } |
OLD | NEW |