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

Side by Side Diff: chrome/browser/ui/browser.cc

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

Powered by Google App Engine
This is Rietveld 408576698