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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 #include "content/browser/site_instance.h" | 142 #include "content/browser/site_instance.h" |
143 #include "content/browser/tab_contents/interstitial_page.h" | 143 #include "content/browser/tab_contents/interstitial_page.h" |
144 #include "content/browser/tab_contents/navigation_controller.h" | 144 #include "content/browser/tab_contents/navigation_controller.h" |
145 #include "content/browser/tab_contents/navigation_entry.h" | 145 #include "content/browser/tab_contents/navigation_entry.h" |
146 #include "content/browser/tab_contents/tab_contents_view.h" | 146 #include "content/browser/tab_contents/tab_contents_view.h" |
147 #include "content/browser/user_metrics.h" | 147 #include "content/browser/user_metrics.h" |
148 #include "content/common/content_restriction.h" | 148 #include "content/common/content_restriction.h" |
149 #include "content/common/content_switches.h" | 149 #include "content/common/content_switches.h" |
150 #include "content/common/notification_details.h" | 150 #include "content/common/notification_details.h" |
151 #include "content/common/notification_service.h" | 151 #include "content/common/notification_service.h" |
152 #include "content/common/page_transition_types.h" | |
153 #include "content/common/page_zoom.h" | 152 #include "content/common/page_zoom.h" |
154 #include "grit/chromium_strings.h" | 153 #include "grit/chromium_strings.h" |
155 #include "grit/generated_resources.h" | 154 #include "grit/generated_resources.h" |
156 #include "grit/locale_settings.h" | 155 #include "grit/locale_settings.h" |
157 #include "grit/theme_resources_standard.h" | 156 #include "grit/theme_resources_standard.h" |
158 #include "net/base/cookie_monster.h" | 157 #include "net/base/cookie_monster.h" |
159 #include "net/base/net_util.h" | 158 #include "net/base/net_util.h" |
160 #include "net/base/registry_controlled_domain.h" | 159 #include "net/base/registry_controlled_domain.h" |
161 #include "net/url_request/url_request_context.h" | 160 #include "net/url_request/url_request_context.h" |
162 #include "ui/base/animation/animation.h" | 161 #include "ui/base/animation/animation.h" |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 void Browser::OpenWindowWithRestoredTabs(Profile* profile) { | 548 void Browser::OpenWindowWithRestoredTabs(Profile* profile) { |
550 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); | 549 TabRestoreService* service = TabRestoreServiceFactory::GetForProfile(profile); |
551 if (service) | 550 if (service) |
552 service->RestoreMostRecentEntry(NULL); | 551 service->RestoreMostRecentEntry(NULL); |
553 } | 552 } |
554 | 553 |
555 // static | 554 // static |
556 void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) { | 555 void Browser::OpenURLOffTheRecord(Profile* profile, const GURL& url) { |
557 Browser* browser = GetOrCreateTabbedBrowser( | 556 Browser* browser = GetOrCreateTabbedBrowser( |
558 profile->GetOffTheRecordProfile()); | 557 profile->GetOffTheRecordProfile()); |
559 browser->AddSelectedTabWithURL(url, PageTransition::LINK); | 558 browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_LINK); |
560 browser->window()->Show(); | 559 browser->window()->Show(); |
561 } | 560 } |
562 | 561 |
563 // static | 562 // static |
564 TabContents* Browser::OpenApplication( | 563 TabContents* Browser::OpenApplication( |
565 Profile* profile, | 564 Profile* profile, |
566 const Extension* extension, | 565 const Extension* extension, |
567 extension_misc::LaunchContainer container, | 566 extension_misc::LaunchContainer container, |
568 WindowOpenDisposition disposition) { | 567 WindowOpenDisposition disposition) { |
569 TabContents* tab = NULL; | 568 TabContents* tab = NULL; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 window_bounds.set_height(extension->launch_height()); | 621 window_bounds.set_height(extension->launch_height()); |
623 } | 622 } |
624 | 623 |
625 Browser* browser = Browser::CreateForApp(type, app_name, window_bounds, | 624 Browser* browser = Browser::CreateForApp(type, app_name, window_bounds, |
626 profile); | 625 profile); |
627 | 626 |
628 if (app_browser) | 627 if (app_browser) |
629 *app_browser = browser; | 628 *app_browser = browser; |
630 | 629 |
631 TabContentsWrapper* wrapper = | 630 TabContentsWrapper* wrapper = |
632 browser->AddSelectedTabWithURL(url, PageTransition::START_PAGE); | 631 browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_START_PAGE); |
633 TabContents* contents = wrapper->tab_contents(); | 632 TabContents* contents = wrapper->tab_contents(); |
634 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 633 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
635 contents->render_view_host()->SyncRendererPrefs(); | 634 contents->render_view_host()->SyncRendererPrefs(); |
636 browser->window()->Show(); | 635 browser->window()->Show(); |
637 | 636 |
638 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial | 637 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial |
639 // focus explicitly. | 638 // focus explicitly. |
640 contents->view()->SetInitialFocus(); | 639 contents->view()->SetInitialFocus(); |
641 return contents; | 640 return contents; |
642 } | 641 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 if (!extension_url.is_valid()) { | 702 if (!extension_url.is_valid()) { |
704 extension_url = extension->options_url(); | 703 extension_url = extension->options_url(); |
705 if (!extension_url.is_valid()) | 704 if (!extension_url.is_valid()) |
706 extension_url = GURL(std::string(chrome::kChromeUISettingsURL) + | 705 extension_url = GURL(std::string(chrome::kChromeUISettingsURL) + |
707 chrome::kExtensionsSubPage); | 706 chrome::kExtensionsSubPage); |
708 } | 707 } |
709 | 708 |
710 // TODO(erikkay): START_PAGE doesn't seem like the right transition in all | 709 // TODO(erikkay): START_PAGE doesn't seem like the right transition in all |
711 // cases. | 710 // cases. |
712 browser::NavigateParams params(browser, extension_url, | 711 browser::NavigateParams params(browser, extension_url, |
713 PageTransition::START_PAGE); | 712 content::PAGE_TRANSITION_START_PAGE); |
714 params.tabstrip_add_types = add_type; | 713 params.tabstrip_add_types = add_type; |
715 params.disposition = disposition; | 714 params.disposition = disposition; |
716 | 715 |
717 if (disposition == CURRENT_TAB) { | 716 if (disposition == CURRENT_TAB) { |
718 TabContents* existing_tab = browser->GetSelectedTabContents(); | 717 TabContents* existing_tab = browser->GetSelectedTabContents(); |
719 TabStripModel* model = browser->tabstrip_model(); | 718 TabStripModel* model = browser->tabstrip_model(); |
720 int tab_index = model->GetWrapperIndex(existing_tab); | 719 int tab_index = model->GetWrapperIndex(existing_tab); |
721 | 720 |
722 existing_tab->OpenURL(extension->GetFullLaunchURL(), existing_tab->GetURL(), | 721 existing_tab->OpenURL(extension->GetFullLaunchURL(), existing_tab->GetURL(), |
723 disposition, PageTransition::LINK); | 722 disposition, content::PAGE_TRANSITION_LINK); |
724 if (params.tabstrip_add_types & TabStripModel::ADD_PINNED) { | 723 if (params.tabstrip_add_types & TabStripModel::ADD_PINNED) { |
725 model->SetTabPinned(tab_index, true); | 724 model->SetTabPinned(tab_index, true); |
726 tab_index = model->GetWrapperIndex(existing_tab); | 725 tab_index = model->GetWrapperIndex(existing_tab); |
727 } | 726 } |
728 if (params.tabstrip_add_types & TabStripModel::ADD_ACTIVE) | 727 if (params.tabstrip_add_types & TabStripModel::ADD_ACTIVE) |
729 model->ActivateTabAt(tab_index, true); | 728 model->ActivateTabAt(tab_index, true); |
730 | 729 |
731 contents = existing_tab; | 730 contents = existing_tab; |
732 } else { | 731 } else { |
733 browser::Navigate(¶ms); | 732 browser::Navigate(¶ms); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 return window()->IsTabStripEditable(); | 1091 return window()->IsTabStripEditable(); |
1093 } | 1092 } |
1094 | 1093 |
1095 int Browser::GetIndexForInsertionDuringRestore(int relative_index) { | 1094 int Browser::GetIndexForInsertionDuringRestore(int relative_index) { |
1096 return (tab_handler_->GetTabStripModel()->insertion_policy() == | 1095 return (tab_handler_->GetTabStripModel()->insertion_policy() == |
1097 TabStripModel::INSERT_AFTER) ? tab_count() : relative_index; | 1096 TabStripModel::INSERT_AFTER) ? tab_count() : relative_index; |
1098 } | 1097 } |
1099 | 1098 |
1100 TabContentsWrapper* Browser::AddSelectedTabWithURL( | 1099 TabContentsWrapper* Browser::AddSelectedTabWithURL( |
1101 const GURL& url, | 1100 const GURL& url, |
1102 PageTransition::Type transition) { | 1101 content::PageTransition transition) { |
1103 browser::NavigateParams params(this, url, transition); | 1102 browser::NavigateParams params(this, url, transition); |
1104 params.disposition = NEW_FOREGROUND_TAB; | 1103 params.disposition = NEW_FOREGROUND_TAB; |
1105 browser::Navigate(¶ms); | 1104 browser::Navigate(¶ms); |
1106 return params.target_contents; | 1105 return params.target_contents; |
1107 } | 1106 } |
1108 | 1107 |
1109 TabContents* Browser::AddTab(TabContentsWrapper* tab_contents, | 1108 TabContents* Browser::AddTab(TabContentsWrapper* tab_contents, |
1110 PageTransition::Type type) { | 1109 content::PageTransition type) { |
1111 tab_handler_->GetTabStripModel()->AddTabContents( | 1110 tab_handler_->GetTabStripModel()->AddTabContents( |
1112 tab_contents, -1, type, TabStripModel::ADD_ACTIVE); | 1111 tab_contents, -1, type, TabStripModel::ADD_ACTIVE); |
1113 return tab_contents->tab_contents(); | 1112 return tab_contents->tab_contents(); |
1114 } | 1113 } |
1115 | 1114 |
1116 void Browser::AddTabContents(TabContents* new_contents, | 1115 void Browser::AddTabContents(TabContents* new_contents, |
1117 WindowOpenDisposition disposition, | 1116 WindowOpenDisposition disposition, |
1118 const gfx::Rect& initial_pos, | 1117 const gfx::Rect& initial_pos, |
1119 bool user_gesture) { | 1118 bool user_gesture) { |
1120 AddNewContents(NULL, new_contents, disposition, initial_pos, user_gesture); | 1119 AddNewContents(NULL, new_contents, disposition, initial_pos, user_gesture); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 NavigationController& controller = | 1239 NavigationController& controller = |
1241 GetOrCloneTabForDisposition(disp)->controller(); | 1240 GetOrCloneTabForDisposition(disp)->controller(); |
1242 if (index < 0 || index >= controller.entry_count()) | 1241 if (index < 0 || index >= controller.entry_count()) |
1243 return false; | 1242 return false; |
1244 controller.GoToIndex(index); | 1243 controller.GoToIndex(index); |
1245 return true; | 1244 return true; |
1246 } | 1245 } |
1247 | 1246 |
1248 browser::NavigateParams Browser::GetSingletonTabNavigateParams( | 1247 browser::NavigateParams Browser::GetSingletonTabNavigateParams( |
1249 const GURL& url) { | 1248 const GURL& url) { |
1250 browser::NavigateParams params(this, url, PageTransition::AUTO_BOOKMARK); | 1249 browser::NavigateParams params( |
| 1250 this, url, content::PAGE_TRANSITION_AUTO_BOOKMARK); |
1251 params.disposition = SINGLETON_TAB; | 1251 params.disposition = SINGLETON_TAB; |
1252 params.window_action = browser::NavigateParams::SHOW_WINDOW; | 1252 params.window_action = browser::NavigateParams::SHOW_WINDOW; |
1253 params.user_gesture = true; | 1253 params.user_gesture = true; |
1254 return params; | 1254 return params; |
1255 } | 1255 } |
1256 | 1256 |
1257 void Browser::ShowSingletonTab(const GURL& url) { | 1257 void Browser::ShowSingletonTab(const GURL& url) { |
1258 browser::NavigateParams params(GetSingletonTabNavigateParams(url)); | 1258 browser::NavigateParams params(GetSingletonTabNavigateParams(url)); |
1259 browser::Navigate(¶ms); | 1259 browser::Navigate(¶ms); |
1260 } | 1260 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 // Browser, Assorted browser commands: | 1308 // Browser, Assorted browser commands: |
1309 | 1309 |
1310 TabContents* Browser::GetOrCloneTabForDisposition( | 1310 TabContents* Browser::GetOrCloneTabForDisposition( |
1311 WindowOpenDisposition disposition) { | 1311 WindowOpenDisposition disposition) { |
1312 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); | 1312 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); |
1313 switch (disposition) { | 1313 switch (disposition) { |
1314 case NEW_FOREGROUND_TAB: | 1314 case NEW_FOREGROUND_TAB: |
1315 case NEW_BACKGROUND_TAB: { | 1315 case NEW_BACKGROUND_TAB: { |
1316 current_tab = current_tab->Clone(); | 1316 current_tab = current_tab->Clone(); |
1317 tab_handler_->GetTabStripModel()->AddTabContents( | 1317 tab_handler_->GetTabStripModel()->AddTabContents( |
1318 current_tab, -1, PageTransition::LINK, | 1318 current_tab, -1, content::PAGE_TRANSITION_LINK, |
1319 disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_ACTIVE : | 1319 disposition == NEW_FOREGROUND_TAB ? TabStripModel::ADD_ACTIVE : |
1320 TabStripModel::ADD_NONE); | 1320 TabStripModel::ADD_NONE); |
1321 break; | 1321 break; |
1322 } | 1322 } |
1323 case NEW_WINDOW: { | 1323 case NEW_WINDOW: { |
1324 current_tab = current_tab->Clone(); | 1324 current_tab = current_tab->Clone(); |
1325 Browser* browser = Browser::Create(profile_); | 1325 Browser* browser = Browser::Create(profile_); |
1326 browser->tabstrip_model()->AddTabContents( | 1326 browser->tabstrip_model()->AddTabContents( |
1327 current_tab, -1, PageTransition::LINK, TabStripModel::ADD_ACTIVE); | 1327 current_tab, -1, content::PAGE_TRANSITION_LINK, |
| 1328 TabStripModel::ADD_ACTIVE); |
1328 browser->window()->Show(); | 1329 browser->window()->Show(); |
1329 break; | 1330 break; |
1330 } | 1331 } |
1331 default: | 1332 default: |
1332 break; | 1333 break; |
1333 } | 1334 } |
1334 return current_tab->tab_contents(); | 1335 return current_tab->tab_contents(); |
1335 } | 1336 } |
1336 | 1337 |
1337 bool Browser::SupportsWindowFeatureImpl(WindowFeature feature, | 1338 bool Browser::SupportsWindowFeatureImpl(WindowFeature feature, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 ReloadInternal(disposition, true); | 1420 ReloadInternal(disposition, true); |
1420 } | 1421 } |
1421 | 1422 |
1422 void Browser::ReloadInternal(WindowOpenDisposition disposition, | 1423 void Browser::ReloadInternal(WindowOpenDisposition disposition, |
1423 bool ignore_cache) { | 1424 bool ignore_cache) { |
1424 // If we are showing an interstitial, treat this as an OpenURL. | 1425 // If we are showing an interstitial, treat this as an OpenURL. |
1425 TabContents* current_tab = GetSelectedTabContents(); | 1426 TabContents* current_tab = GetSelectedTabContents(); |
1426 if (current_tab && current_tab->showing_interstitial_page()) { | 1427 if (current_tab && current_tab->showing_interstitial_page()) { |
1427 NavigationEntry* entry = current_tab->controller().GetActiveEntry(); | 1428 NavigationEntry* entry = current_tab->controller().GetActiveEntry(); |
1428 DCHECK(entry); // Should exist if interstitial is showing. | 1429 DCHECK(entry); // Should exist if interstitial is showing. |
1429 OpenURL(entry->url(), GURL(), disposition, PageTransition::RELOAD); | 1430 OpenURL(entry->url(), GURL(), disposition, content::PAGE_TRANSITION_RELOAD); |
1430 return; | 1431 return; |
1431 } | 1432 } |
1432 | 1433 |
1433 // As this is caused by a user action, give the focus to the page. | 1434 // As this is caused by a user action, give the focus to the page. |
1434 TabContents* tab = GetOrCloneTabForDisposition(disposition); | 1435 TabContents* tab = GetOrCloneTabForDisposition(disposition); |
1435 if (!tab->FocusLocationBarByDefault()) | 1436 if (!tab->FocusLocationBarByDefault()) |
1436 tab->Focus(); | 1437 tab->Focus(); |
1437 if (ignore_cache) | 1438 if (ignore_cache) |
1438 tab->controller().ReloadIgnoringCache(true); | 1439 tab->controller().ReloadIgnoringCache(true); |
1439 else | 1440 else |
1440 tab->controller().Reload(true); | 1441 tab->controller().Reload(true); |
1441 } | 1442 } |
1442 | 1443 |
1443 void Browser::Home(WindowOpenDisposition disposition) { | 1444 void Browser::Home(WindowOpenDisposition disposition) { |
1444 UserMetrics::RecordAction(UserMetricsAction("Home")); | 1445 UserMetrics::RecordAction(UserMetricsAction("Home")); |
1445 OpenURL(GetHomePage(), GURL(), disposition, | 1446 OpenURL( |
1446 PageTransition::AUTO_BOOKMARK | PageTransition::HOME_PAGE); | 1447 GetHomePage(), GURL(), disposition, |
| 1448 content::PageTransitionFromInt( |
| 1449 content::PAGE_TRANSITION_AUTO_BOOKMARK | |
| 1450 content::PAGE_TRANSITION_HOME_PAGE)); |
1447 } | 1451 } |
1448 | 1452 |
1449 void Browser::OpenCurrentURL() { | 1453 void Browser::OpenCurrentURL() { |
1450 UserMetrics::RecordAction(UserMetricsAction("LoadURL")); | 1454 UserMetrics::RecordAction(UserMetricsAction("LoadURL")); |
1451 LocationBar* location_bar = window_->GetLocationBar(); | 1455 LocationBar* location_bar = window_->GetLocationBar(); |
1452 if (!location_bar) | 1456 if (!location_bar) |
1453 return; | 1457 return; |
1454 | 1458 |
1455 WindowOpenDisposition open_disposition = | 1459 WindowOpenDisposition open_disposition = |
1456 location_bar->GetWindowOpenDisposition(); | 1460 location_bar->GetWindowOpenDisposition(); |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2111 | 2115 |
2112 void Browser::ShowHelpTab() { | 2116 void Browser::ShowHelpTab() { |
2113 UserMetrics::RecordAction(UserMetricsAction("ShowHelpTab")); | 2117 UserMetrics::RecordAction(UserMetricsAction("ShowHelpTab")); |
2114 GURL help_url(kHelpContentUrl); | 2118 GURL help_url(kHelpContentUrl); |
2115 GURL localized_help_url = google_util::AppendGoogleLocaleParam(help_url); | 2119 GURL localized_help_url = google_util::AppendGoogleLocaleParam(help_url); |
2116 ShowSingletonTab(localized_help_url); | 2120 ShowSingletonTab(localized_help_url); |
2117 } | 2121 } |
2118 | 2122 |
2119 void Browser::OpenPrivacyDashboardTabAndActivate() { | 2123 void Browser::OpenPrivacyDashboardTabAndActivate() { |
2120 OpenURL(GURL(kPrivacyDashboardUrl), GURL(), | 2124 OpenURL(GURL(kPrivacyDashboardUrl), GURL(), |
2121 NEW_FOREGROUND_TAB, PageTransition::LINK); | 2125 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK); |
2122 window_->Activate(); | 2126 window_->Activate(); |
2123 } | 2127 } |
2124 | 2128 |
2125 void Browser::OpenAutofillHelpTabAndActivate() { | 2129 void Browser::OpenAutofillHelpTabAndActivate() { |
2126 GURL help_url = google_util::AppendGoogleLocaleParam(GURL(kAutofillHelpUrl)); | 2130 GURL help_url = google_util::AppendGoogleLocaleParam(GURL(kAutofillHelpUrl)); |
2127 AddSelectedTabWithURL(help_url, PageTransition::LINK); | 2131 AddSelectedTabWithURL(help_url, content::PAGE_TRANSITION_LINK); |
2128 } | 2132 } |
2129 | 2133 |
2130 void Browser::OpenSearchEngineOptionsDialog() { | 2134 void Browser::OpenSearchEngineOptionsDialog() { |
2131 UserMetrics::RecordAction(UserMetricsAction("EditSearchEngines")); | 2135 UserMetrics::RecordAction(UserMetricsAction("EditSearchEngines")); |
2132 ShowOptionsTab(chrome::kSearchEnginesSubPage); | 2136 ShowOptionsTab(chrome::kSearchEnginesSubPage); |
2133 } | 2137 } |
2134 | 2138 |
2135 #if defined(FILE_MANAGER_EXTENSION) | 2139 #if defined(FILE_MANAGER_EXTENSION) |
2136 void Browser::OpenFileManager() { | 2140 void Browser::OpenFileManager() { |
2137 UserMetrics::RecordAction(UserMetricsAction("OpenFileManager")); | 2141 UserMetrics::RecordAction(UserMetricsAction("OpenFileManager")); |
(...skipping 12 matching lines...) Expand all Loading... |
2150 ShowOptionsTab(chrome::kInternetOptionsSubPage); | 2154 ShowOptionsTab(chrome::kInternetOptionsSubPage); |
2151 } | 2155 } |
2152 | 2156 |
2153 void Browser::OpenLanguageOptionsDialog() { | 2157 void Browser::OpenLanguageOptionsDialog() { |
2154 UserMetrics::RecordAction(UserMetricsAction("OpenLanguageOptionsDialog")); | 2158 UserMetrics::RecordAction(UserMetricsAction("OpenLanguageOptionsDialog")); |
2155 ShowOptionsTab(chrome::kLanguageOptionsSubPage); | 2159 ShowOptionsTab(chrome::kLanguageOptionsSubPage); |
2156 } | 2160 } |
2157 | 2161 |
2158 void Browser::OpenSystemTabAndActivate() { | 2162 void Browser::OpenSystemTabAndActivate() { |
2159 OpenURL(GURL(chrome::kChromeUISystemInfoURL), GURL(), | 2163 OpenURL(GURL(chrome::kChromeUISystemInfoURL), GURL(), |
2160 NEW_FOREGROUND_TAB, PageTransition::LINK); | 2164 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK); |
2161 window_->Activate(); | 2165 window_->Activate(); |
2162 } | 2166 } |
2163 | 2167 |
2164 void Browser::OpenMobilePlanTabAndActivate() { | 2168 void Browser::OpenMobilePlanTabAndActivate() { |
2165 OpenURL(GURL(chrome::kChromeUIMobileSetupURL), GURL(), | 2169 OpenURL(GURL(chrome::kChromeUIMobileSetupURL), GURL(), |
2166 NEW_FOREGROUND_TAB, PageTransition::LINK); | 2170 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK); |
2167 window_->Activate(); | 2171 window_->Activate(); |
2168 } | 2172 } |
2169 #endif | 2173 #endif |
2170 | 2174 |
2171 void Browser::OpenPluginsTabAndActivate() { | 2175 void Browser::OpenPluginsTabAndActivate() { |
2172 OpenURL(GURL(chrome::kChromeUIPluginsURL), GURL(), | 2176 OpenURL(GURL(chrome::kChromeUIPluginsURL), GURL(), |
2173 NEW_FOREGROUND_TAB, PageTransition::LINK); | 2177 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK); |
2174 window_->Activate(); | 2178 window_->Activate(); |
2175 } | 2179 } |
2176 | 2180 |
2177 /////////////////////////////////////////////////////////////////////////////// | 2181 /////////////////////////////////////////////////////////////////////////////// |
2178 | 2182 |
2179 // static | 2183 // static |
2180 void Browser::SetNewHomePagePrefs(PrefService* prefs) { | 2184 void Browser::SetNewHomePagePrefs(PrefService* prefs) { |
2181 const PrefService::Preference* home_page_pref = | 2185 const PrefService::Preference* home_page_pref = |
2182 prefs->FindPreference(prefs::kHomePage); | 2186 prefs->FindPreference(prefs::kHomePage); |
2183 if (home_page_pref && | 2187 if (home_page_pref && |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2797 } | 2801 } |
2798 } | 2802 } |
2799 | 2803 |
2800 int Browser::GetLastBlockedCommand(WindowOpenDisposition* disposition) { | 2804 int Browser::GetLastBlockedCommand(WindowOpenDisposition* disposition) { |
2801 if (disposition) | 2805 if (disposition) |
2802 *disposition = last_blocked_command_disposition_; | 2806 *disposition = last_blocked_command_disposition_; |
2803 return last_blocked_command_id_; | 2807 return last_blocked_command_id_; |
2804 } | 2808 } |
2805 | 2809 |
2806 void Browser::UpdateUIForNavigationInTab(TabContentsWrapper* contents, | 2810 void Browser::UpdateUIForNavigationInTab(TabContentsWrapper* contents, |
2807 PageTransition::Type transition, | 2811 content::PageTransition transition, |
2808 bool user_initiated) { | 2812 bool user_initiated) { |
2809 tabstrip_model()->TabNavigating(contents, transition); | 2813 tabstrip_model()->TabNavigating(contents, transition); |
2810 | 2814 |
2811 bool contents_is_selected = contents == GetSelectedTabContentsWrapper(); | 2815 bool contents_is_selected = contents == GetSelectedTabContentsWrapper(); |
2812 if (user_initiated && contents_is_selected && window()->GetLocationBar()) { | 2816 if (user_initiated && contents_is_selected && window()->GetLocationBar()) { |
2813 // Forcibly reset the location bar if the url is going to change in the | 2817 // Forcibly reset the location bar if the url is going to change in the |
2814 // current tab, since otherwise it won't discard any ongoing user edits, | 2818 // current tab, since otherwise it won't discard any ongoing user edits, |
2815 // since it doesn't realize this is a user-initiated action. | 2819 // since it doesn't realize this is a user-initiated action. |
2816 window()->GetLocationBar()->Revert(); | 2820 window()->GetLocationBar()->Revert(); |
2817 } | 2821 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2858 return home_page; | 2862 return home_page; |
2859 } | 2863 } |
2860 | 2864 |
2861 /////////////////////////////////////////////////////////////////////////////// | 2865 /////////////////////////////////////////////////////////////////////////////// |
2862 // Browser, PageNavigator implementation: | 2866 // Browser, PageNavigator implementation: |
2863 | 2867 |
2864 // TODO(adriansc): Remove this method once refactoring changed all call sites. | 2868 // TODO(adriansc): Remove this method once refactoring changed all call sites. |
2865 TabContents* Browser::OpenURL(const GURL& url, | 2869 TabContents* Browser::OpenURL(const GURL& url, |
2866 const GURL& referrer, | 2870 const GURL& referrer, |
2867 WindowOpenDisposition disposition, | 2871 WindowOpenDisposition disposition, |
2868 PageTransition::Type transition) { | 2872 content::PageTransition transition) { |
2869 return OpenURLFromTab(NULL, | 2873 return OpenURLFromTab(NULL, |
2870 OpenURLParams(url, referrer, disposition, transition)); | 2874 OpenURLParams(url, referrer, disposition, transition)); |
2871 } | 2875 } |
2872 | 2876 |
2873 TabContents* Browser::OpenURL(const OpenURLParams& params) { | 2877 TabContents* Browser::OpenURL(const OpenURLParams& params) { |
2874 return OpenURLFromTab(NULL, params); | 2878 return OpenURLFromTab(NULL, params); |
2875 } | 2879 } |
2876 | 2880 |
2877 /////////////////////////////////////////////////////////////////////////////// | 2881 /////////////////////////////////////////////////////////////////////////////// |
2878 // Browser, CommandUpdater::CommandUpdaterDelegate implementation: | 2882 // Browser, CommandUpdater::CommandUpdaterDelegate implementation: |
(...skipping 22 matching lines...) Expand all Loading... |
2901 | 2905 |
2902 return AddBlankTabAt(-1, foreground); | 2906 return AddBlankTabAt(-1, foreground); |
2903 } | 2907 } |
2904 | 2908 |
2905 TabContentsWrapper* Browser::AddBlankTabAt(int index, bool foreground) { | 2909 TabContentsWrapper* Browser::AddBlankTabAt(int index, bool foreground) { |
2906 // Time new tab page creation time. We keep track of the timing data in | 2910 // Time new tab page creation time. We keep track of the timing data in |
2907 // TabContents, but we want to include the time it takes to create the | 2911 // TabContents, but we want to include the time it takes to create the |
2908 // TabContents object too. | 2912 // TabContents object too. |
2909 base::TimeTicks new_tab_start_time = base::TimeTicks::Now(); | 2913 base::TimeTicks new_tab_start_time = base::TimeTicks::Now(); |
2910 browser::NavigateParams params(this, GURL(chrome::kChromeUINewTabURL), | 2914 browser::NavigateParams params(this, GURL(chrome::kChromeUINewTabURL), |
2911 PageTransition::TYPED); | 2915 content::PAGE_TRANSITION_TYPED); |
2912 params.disposition = foreground ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; | 2916 params.disposition = foreground ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; |
2913 params.tabstrip_index = index; | 2917 params.tabstrip_index = index; |
2914 browser::Navigate(¶ms); | 2918 browser::Navigate(¶ms); |
2915 params.target_contents->tab_contents()->set_new_tab_start_time( | 2919 params.target_contents->tab_contents()->set_new_tab_start_time( |
2916 new_tab_start_time); | 2920 new_tab_start_time); |
2917 return params.target_contents; | 2921 return params.target_contents; |
2918 } | 2922 } |
2919 | 2923 |
2920 Browser* Browser::CreateNewStripWithContents( | 2924 Browser* Browser::CreateNewStripWithContents( |
2921 TabContentsWrapper* detached_contents, | 2925 TabContentsWrapper* detached_contents, |
(...skipping 19 matching lines...) Expand all Loading... |
2941 return browser; | 2945 return browser; |
2942 } | 2946 } |
2943 | 2947 |
2944 int Browser::GetDragActions() const { | 2948 int Browser::GetDragActions() const { |
2945 return TabStripModelDelegate::TAB_TEAROFF_ACTION | (tab_count() > 1 ? | 2949 return TabStripModelDelegate::TAB_TEAROFF_ACTION | (tab_count() > 1 ? |
2946 TabStripModelDelegate::TAB_MOVE_ACTION : 0); | 2950 TabStripModelDelegate::TAB_MOVE_ACTION : 0); |
2947 } | 2951 } |
2948 | 2952 |
2949 TabContentsWrapper* Browser::CreateTabContentsForURL( | 2953 TabContentsWrapper* Browser::CreateTabContentsForURL( |
2950 const GURL& url, const GURL& referrer, Profile* profile, | 2954 const GURL& url, const GURL& referrer, Profile* profile, |
2951 PageTransition::Type transition, bool defer_load, | 2955 content::PageTransition transition, bool defer_load, |
2952 SiteInstance* instance) const { | 2956 SiteInstance* instance) const { |
2953 TabContentsWrapper* contents = TabContentsFactory(profile, instance, | 2957 TabContentsWrapper* contents = TabContentsFactory(profile, instance, |
2954 MSG_ROUTING_NONE, | 2958 MSG_ROUTING_NONE, |
2955 GetSelectedTabContents(), NULL); | 2959 GetSelectedTabContents(), NULL); |
2956 if (!defer_load) { | 2960 if (!defer_load) { |
2957 // Load the initial URL before adding the new tab contents to the tab strip | 2961 // Load the initial URL before adding the new tab contents to the tab strip |
2958 // so that the tab contents has navigation state. | 2962 // so that the tab contents has navigation state. |
2959 contents->controller().LoadURL(url, referrer, transition, std::string()); | 2963 contents->controller().LoadURL(url, referrer, transition, std::string()); |
2960 } | 2964 } |
2961 | 2965 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3000 // been given an offset by the OS, so we shouldn't copy the old bounds. | 3004 // been given an offset by the OS, so we shouldn't copy the old bounds. |
3001 BrowserWindow* new_window = browser->window(); | 3005 BrowserWindow* new_window = browser->window(); |
3002 new_window->SetBounds(gfx::Rect(new_window->GetRestoredBounds().origin(), | 3006 new_window->SetBounds(gfx::Rect(new_window->GetRestoredBounds().origin(), |
3003 window()->GetRestoredBounds().size())); | 3007 window()->GetRestoredBounds().size())); |
3004 | 3008 |
3005 // We need to show the browser now. Otherwise ContainerWin assumes the | 3009 // We need to show the browser now. Otherwise ContainerWin assumes the |
3006 // TabContents is invisible and won't size it. | 3010 // TabContents is invisible and won't size it. |
3007 browser->window()->Show(); | 3011 browser->window()->Show(); |
3008 | 3012 |
3009 // The page transition below is only for the purpose of inserting the tab. | 3013 // The page transition below is only for the purpose of inserting the tab. |
3010 browser->AddTab(contents_dupe, PageTransition::LINK); | 3014 browser->AddTab(contents_dupe, content::PAGE_TRANSITION_LINK); |
3011 } | 3015 } |
3012 | 3016 |
3013 SessionService* session_service = | 3017 SessionService* session_service = |
3014 SessionServiceFactory::GetForProfileIfExisting(profile_); | 3018 SessionServiceFactory::GetForProfileIfExisting(profile_); |
3015 if (session_service) | 3019 if (session_service) |
3016 session_service->TabRestored(contents_dupe, pinned); | 3020 session_service->TabRestored(contents_dupe, pinned); |
3017 } | 3021 } |
3018 | 3022 |
3019 void Browser::CloseFrameAfterDragSession() { | 3023 void Browser::CloseFrameAfterDragSession() { |
3020 #if !defined(OS_MACOSX) | 3024 #if !defined(OS_MACOSX) |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3284 } | 3288 } |
3285 | 3289 |
3286 /////////////////////////////////////////////////////////////////////////////// | 3290 /////////////////////////////////////////////////////////////////////////////// |
3287 // Browser, TabContentsDelegate implementation: | 3291 // Browser, TabContentsDelegate implementation: |
3288 | 3292 |
3289 // TODO(adriansc): Remove this method once refactoring changed all call sites. | 3293 // TODO(adriansc): Remove this method once refactoring changed all call sites. |
3290 TabContents* Browser::OpenURLFromTab(TabContents* source, | 3294 TabContents* Browser::OpenURLFromTab(TabContents* source, |
3291 const GURL& url, | 3295 const GURL& url, |
3292 const GURL& referrer, | 3296 const GURL& referrer, |
3293 WindowOpenDisposition disposition, | 3297 WindowOpenDisposition disposition, |
3294 PageTransition::Type transition) { | 3298 content::PageTransition transition) { |
3295 return OpenURLFromTab(source, OpenURLParams(url, referrer, disposition, | 3299 return OpenURLFromTab(source, OpenURLParams(url, referrer, disposition, |
3296 transition)); | 3300 transition)); |
3297 } | 3301 } |
3298 | 3302 |
3299 TabContents* Browser::OpenURLFromTab(TabContents* source, | 3303 TabContents* Browser::OpenURLFromTab(TabContents* source, |
3300 const OpenURLParams& params) { | 3304 const OpenURLParams& params) { |
3301 browser::NavigateParams nav_params(this, params.url, params.transition); | 3305 browser::NavigateParams nav_params(this, params.url, params.transition); |
3302 nav_params.source_contents = | 3306 nav_params.source_contents = |
3303 tabstrip_model()->GetTabContentsAt( | 3307 tabstrip_model()->GetTabContentsAt( |
3304 tabstrip_model()->GetWrapperIndex(source)); | 3308 tabstrip_model()->GetWrapperIndex(source)); |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3942 window_->SetStarredState(starred); | 3946 window_->SetStarredState(starred); |
3943 } | 3947 } |
3944 | 3948 |
3945 /////////////////////////////////////////////////////////////////////////////// | 3949 /////////////////////////////////////////////////////////////////////////////// |
3946 // Browser, SelectFileDialog::Listener implementation: | 3950 // Browser, SelectFileDialog::Listener implementation: |
3947 | 3951 |
3948 void Browser::FileSelected(const FilePath& path, int index, void* params) { | 3952 void Browser::FileSelected(const FilePath& path, int index, void* params) { |
3949 profile_->set_last_selected_directory(path.DirName()); | 3953 profile_->set_last_selected_directory(path.DirName()); |
3950 GURL file_url = net::FilePathToFileURL(path); | 3954 GURL file_url = net::FilePathToFileURL(path); |
3951 if (!file_url.is_empty()) | 3955 if (!file_url.is_empty()) |
3952 OpenURL(file_url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 3956 OpenURL(file_url, GURL(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED); |
3953 } | 3957 } |
3954 | 3958 |
3955 /////////////////////////////////////////////////////////////////////////////// | 3959 /////////////////////////////////////////////////////////////////////////////// |
3956 // Browser, NotificationObserver implementation: | 3960 // Browser, NotificationObserver implementation: |
3957 | 3961 |
3958 void Browser::Observe(int type, | 3962 void Browser::Observe(int type, |
3959 const NotificationSource& source, | 3963 const NotificationSource& source, |
3960 const NotificationDetails& details) { | 3964 const NotificationDetails& details) { |
3961 switch (type) { | 3965 switch (type) { |
3962 case content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED: | 3966 case content::NOTIFICATION_TAB_CONTENTS_DISCONNECTED: |
(...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5176 // been given an offset by the OS, so we shouldn't copy the old bounds. | 5180 // been given an offset by the OS, so we shouldn't copy the old bounds. |
5177 BrowserWindow* new_window = browser->window(); | 5181 BrowserWindow* new_window = browser->window(); |
5178 new_window->SetBounds(gfx::Rect(new_window->GetRestoredBounds().origin(), | 5182 new_window->SetBounds(gfx::Rect(new_window->GetRestoredBounds().origin(), |
5179 window()->GetRestoredBounds().size())); | 5183 window()->GetRestoredBounds().size())); |
5180 | 5184 |
5181 // We need to show the browser now. Otherwise ContainerWin assumes the | 5185 // We need to show the browser now. Otherwise ContainerWin assumes the |
5182 // TabContents is invisible and won't size it. | 5186 // TabContents is invisible and won't size it. |
5183 browser->window()->Show(); | 5187 browser->window()->Show(); |
5184 | 5188 |
5185 // The page transition below is only for the purpose of inserting the tab. | 5189 // The page transition below is only for the purpose of inserting the tab. |
5186 browser->AddTab(view_source_contents, PageTransition::LINK); | 5190 browser->AddTab(view_source_contents, content::PAGE_TRANSITION_LINK); |
5187 } | 5191 } |
5188 | 5192 |
5189 SessionService* session_service = | 5193 SessionService* session_service = |
5190 SessionServiceFactory::GetForProfileIfExisting(profile_); | 5194 SessionServiceFactory::GetForProfileIfExisting(profile_); |
5191 if (session_service) | 5195 if (session_service) |
5192 session_service->TabRestored(view_source_contents, false); | 5196 session_service->TabRestored(view_source_contents, false); |
5193 } | 5197 } |
5194 | 5198 |
5195 int Browser::GetContentRestrictionsForSelectedTab() { | 5199 int Browser::GetContentRestrictionsForSelectedTab() { |
5196 int content_restrictions = 0; | 5200 int content_restrictions = 0; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5279 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); | 5283 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); |
5280 } else if (is_type_tabbed()) { | 5284 } else if (is_type_tabbed()) { |
5281 GlobalErrorService* service = | 5285 GlobalErrorService* service = |
5282 GlobalErrorServiceFactory::GetForProfile(profile()); | 5286 GlobalErrorServiceFactory::GetForProfile(profile()); |
5283 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); | 5287 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); |
5284 if (error) { | 5288 if (error) { |
5285 error->ShowBubbleView(this); | 5289 error->ShowBubbleView(this); |
5286 } | 5290 } |
5287 } | 5291 } |
5288 } | 5292 } |
OLD | NEW |