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

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

Issue 8892011: Clean up TCW, make it solely a hub for 1:1 observer/helper objects. (Closed) Base URL: svn://svn.chromium.org/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
« no previous file with comments | « chrome/browser/ui/alternate_error_tab_observer.cc ('k') | chrome/browser/ui/browser_init.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 #include "content/browser/download/download_item.h" 141 #include "content/browser/download/download_item.h"
142 #include "content/browser/download/download_manager.h" 142 #include "content/browser/download/download_manager.h"
143 #include "content/browser/download/save_package.h" 143 #include "content/browser/download/save_package.h"
144 #include "content/browser/host_zoom_map.h" 144 #include "content/browser/host_zoom_map.h"
145 #include "content/browser/plugin_service.h" 145 #include "content/browser/plugin_service.h"
146 #include "content/browser/renderer_host/render_view_host.h" 146 #include "content/browser/renderer_host/render_view_host.h"
147 #include "content/browser/site_instance.h" 147 #include "content/browser/site_instance.h"
148 #include "content/browser/tab_contents/interstitial_page.h" 148 #include "content/browser/tab_contents/interstitial_page.h"
149 #include "content/browser/tab_contents/navigation_controller.h" 149 #include "content/browser/tab_contents/navigation_controller.h"
150 #include "content/browser/tab_contents/navigation_entry.h" 150 #include "content/browser/tab_contents/navigation_entry.h"
151 #include "content/browser/tab_contents/tab_contents.h"
151 #include "content/browser/tab_contents/tab_contents_view.h" 152 #include "content/browser/tab_contents/tab_contents_view.h"
152 #include "content/browser/user_metrics.h" 153 #include "content/browser/user_metrics.h"
153 #include "content/public/browser/devtools_manager.h" 154 #include "content/public/browser/devtools_manager.h"
154 #include "content/public/browser/notification_service.h" 155 #include "content/public/browser/notification_service.h"
155 #include "content/public/browser/notification_details.h" 156 #include "content/public/browser/notification_details.h"
156 #include "content/public/browser/intents_host.h" 157 #include "content/public/browser/intents_host.h"
157 #include "content/public/common/content_restriction.h" 158 #include "content/public/common/content_restriction.h"
158 #include "content/public/common/content_switches.h" 159 #include "content/public/common/content_switches.h"
159 #include "content/public/common/page_zoom.h" 160 #include "content/public/common/page_zoom.h"
160 #include "grit/chromium_strings.h" 161 #include "grit/chromium_strings.h"
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 bool Browser::IsClosingPermitted() { 1476 bool Browser::IsClosingPermitted() {
1476 TabCloseableStateWatcher* watcher = 1477 TabCloseableStateWatcher* watcher =
1477 g_browser_process->tab_closeable_state_watcher(); 1478 g_browser_process->tab_closeable_state_watcher();
1478 bool can_close = !watcher || watcher->CanCloseBrowser(this); 1479 bool can_close = !watcher || watcher->CanCloseBrowser(this);
1479 if (!can_close && is_attempting_to_close_browser_) 1480 if (!can_close && is_attempting_to_close_browser_)
1480 CancelWindowClose(); 1481 CancelWindowClose();
1481 return can_close; 1482 return can_close;
1482 } 1483 }
1483 1484
1484 bool Browser::CanGoBack() const { 1485 bool Browser::CanGoBack() const {
1485 return GetSelectedTabContentsWrapper()->controller().CanGoBack(); 1486 return GetSelectedTabContentsWrapper()->
1487 tab_contents()->controller().CanGoBack();
1486 } 1488 }
1487 1489
1488 void Browser::GoBack(WindowOpenDisposition disposition) { 1490 void Browser::GoBack(WindowOpenDisposition disposition) {
1489 UserMetrics::RecordAction(UserMetricsAction("Back")); 1491 UserMetrics::RecordAction(UserMetricsAction("Back"));
1490 1492
1491 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); 1493 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper();
1492 if (CanGoBack()) { 1494 if (CanGoBack()) {
1493 TabContents* new_tab = GetOrCloneTabForDisposition(disposition); 1495 TabContents* new_tab = GetOrCloneTabForDisposition(disposition);
1494 // If we are on an interstitial page and clone the tab, it won't be copied 1496 // If we are on an interstitial page and clone the tab, it won't be copied
1495 // to the new tab, so we don't need to go back. 1497 // to the new tab, so we don't need to go back.
1496 if (current_tab->tab_contents()->showing_interstitial_page() && 1498 if (current_tab->tab_contents()->showing_interstitial_page() &&
1497 (new_tab != current_tab->tab_contents())) 1499 (new_tab != current_tab->tab_contents()))
1498 return; 1500 return;
1499 new_tab->controller().GoBack(); 1501 new_tab->controller().GoBack();
1500 } 1502 }
1501 } 1503 }
1502 1504
1503 bool Browser::CanGoForward() const { 1505 bool Browser::CanGoForward() const {
1504 return GetSelectedTabContentsWrapper()->controller().CanGoForward(); 1506 return GetSelectedTabContentsWrapper()->
1507 tab_contents()->controller().CanGoForward();
1505 } 1508 }
1506 1509
1507 void Browser::GoForward(WindowOpenDisposition disposition) { 1510 void Browser::GoForward(WindowOpenDisposition disposition) {
1508 UserMetrics::RecordAction(UserMetricsAction("Forward")); 1511 UserMetrics::RecordAction(UserMetricsAction("Forward"));
1509 if (CanGoForward()) 1512 if (CanGoForward())
1510 GetOrCloneTabForDisposition(disposition)->controller().GoForward(); 1513 GetOrCloneTabForDisposition(disposition)->controller().GoForward();
1511 } 1514 }
1512 1515
1513 void Browser::Reload(WindowOpenDisposition disposition) { 1516 void Browser::Reload(WindowOpenDisposition disposition) {
1514 UserMetrics::RecordAction(UserMetricsAction("Reload")); 1517 UserMetrics::RecordAction(UserMetricsAction("Reload"));
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 void Browser::CloseWindow() { 1632 void Browser::CloseWindow() {
1630 UserMetrics::RecordAction(UserMetricsAction("CloseWindow")); 1633 UserMetrics::RecordAction(UserMetricsAction("CloseWindow"));
1631 window_->Close(); 1634 window_->Close();
1632 } 1635 }
1633 1636
1634 void Browser::NewTab() { 1637 void Browser::NewTab() {
1635 UserMetrics::RecordAction(UserMetricsAction("NewTab")); 1638 UserMetrics::RecordAction(UserMetricsAction("NewTab"));
1636 1639
1637 if (is_type_tabbed()) { 1640 if (is_type_tabbed()) {
1638 AddBlankTab(true); 1641 AddBlankTab(true);
1639 GetSelectedTabContentsWrapper()->view()->RestoreFocus(); 1642 GetSelectedTabContentsWrapper()->tab_contents()->view()->RestoreFocus();
1640 } else { 1643 } else {
1641 Browser* b = GetOrCreateTabbedBrowser(profile_); 1644 Browser* b = GetOrCreateTabbedBrowser(profile_);
1642 b->AddBlankTab(true); 1645 b->AddBlankTab(true);
1643 b->window()->Show(); 1646 b->window()->Show();
1644 // The call to AddBlankTab above did not set the focus to the tab as its 1647 // The call to AddBlankTab above did not set the focus to the tab as its
1645 // window was not active, so we have to do it explicitly. 1648 // window was not active, so we have to do it explicitly.
1646 // See http://crbug.com/6380. 1649 // See http://crbug.com/6380.
1647 b->GetSelectedTabContentsWrapper()->view()->RestoreFocus(); 1650 b->GetSelectedTabContentsWrapper()->tab_contents()->view()->RestoreFocus();
1648 } 1651 }
1649 } 1652 }
1650 1653
1651 void Browser::CloseTab() { 1654 void Browser::CloseTab() {
1652 UserMetrics::RecordAction(UserMetricsAction("CloseTab_Accelerator")); 1655 UserMetrics::RecordAction(UserMetricsAction("CloseTab_Accelerator"));
1653 if (CanCloseTab()) 1656 if (CanCloseTab())
1654 tab_handler_->GetTabStripModel()->CloseSelectedTabs(); 1657 tab_handler_->GetTabStripModel()->CloseSelectedTabs();
1655 } 1658 }
1656 1659
1657 void Browser::SelectNextTab() { 1660 void Browser::SelectNextTab() {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 1922
1920 void Browser::FindPrevious() { 1923 void Browser::FindPrevious() {
1921 UserMetrics::RecordAction(UserMetricsAction("FindPrevious")); 1924 UserMetrics::RecordAction(UserMetricsAction("FindPrevious"));
1922 FindInPage(true, false); 1925 FindInPage(true, false);
1923 } 1926 }
1924 1927
1925 void Browser::Zoom(content::PageZoom zoom) { 1928 void Browser::Zoom(content::PageZoom zoom) {
1926 if (is_devtools()) 1929 if (is_devtools())
1927 return; 1930 return;
1928 1931
1929 RenderViewHost* host = GetSelectedTabContentsWrapper()->render_view_host(); 1932 RenderViewHost* host =
1933 GetSelectedTabContentsWrapper()->tab_contents()->render_view_host();
1930 if (zoom == content::PAGE_ZOOM_RESET) { 1934 if (zoom == content::PAGE_ZOOM_RESET) {
1931 host->SetZoomLevel(0); 1935 host->SetZoomLevel(0);
1932 UserMetrics::RecordAction(UserMetricsAction("ZoomNormal")); 1936 UserMetrics::RecordAction(UserMetricsAction("ZoomNormal"));
1933 return; 1937 return;
1934 } 1938 }
1935 1939
1936 double current_zoom_level = GetSelectedTabContents()->GetZoomLevel(); 1940 double current_zoom_level = GetSelectedTabContents()->GetZoomLevel();
1937 double default_zoom_level = 1941 double default_zoom_level =
1938 profile_->GetPrefs()->GetDouble(prefs::kDefaultZoomLevel); 1942 profile_->GetPrefs()->GetDouble(prefs::kDefaultZoomLevel);
1939 1943
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 } 2037 }
2034 2038
2035 void Browser::OpenCreateShortcutsDialog() { 2039 void Browser::OpenCreateShortcutsDialog() {
2036 UserMetrics::RecordAction(UserMetricsAction("CreateShortcut")); 2040 UserMetrics::RecordAction(UserMetricsAction("CreateShortcut"));
2037 #if !defined(OS_MACOSX) 2041 #if !defined(OS_MACOSX)
2038 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper(); 2042 TabContentsWrapper* current_tab = GetSelectedTabContentsWrapper();
2039 DCHECK(current_tab && 2043 DCHECK(current_tab &&
2040 web_app::IsValidUrl(current_tab->tab_contents()->GetURL())) << 2044 web_app::IsValidUrl(current_tab->tab_contents()->GetURL())) <<
2041 "Menu item should be disabled."; 2045 "Menu item should be disabled.";
2042 2046
2043 NavigationEntry* entry = current_tab->controller().GetLastCommittedEntry(); 2047 NavigationEntry* entry =
2048 current_tab->tab_contents()->controller().GetLastCommittedEntry();
2044 if (!entry) 2049 if (!entry)
2045 return; 2050 return;
2046 2051
2047 // RVH's GetApplicationInfo should not be called before it returns. 2052 // RVH's GetApplicationInfo should not be called before it returns.
2048 DCHECK(pending_web_app_action_ == NONE); 2053 DCHECK(pending_web_app_action_ == NONE);
2049 pending_web_app_action_ = CREATE_SHORTCUT; 2054 pending_web_app_action_ = CREATE_SHORTCUT;
2050 2055
2051 // Start fetching web app info for CreateApplicationShortcut dialog and show 2056 // Start fetching web app info for CreateApplicationShortcut dialog and show
2052 // the dialog when the data is available in OnDidGetApplicationInfo. 2057 // the dialog when the data is available in OnDidGetApplicationInfo.
2053 current_tab->extension_tab_helper()->GetApplicationInfo(entry->page_id()); 2058 current_tab->extension_tab_helper()->GetApplicationInfo(entry->page_id());
2054 #else 2059 #else
2055 NOTIMPLEMENTED(); 2060 NOTIMPLEMENTED();
2056 #endif 2061 #endif
2057 } 2062 }
2058 2063
2059 void Browser::ToggleDevToolsWindow(DevToolsToggleAction action) { 2064 void Browser::ToggleDevToolsWindow(DevToolsToggleAction action) {
2060 if (action == DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE) 2065 if (action == DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE)
2061 UserMetrics::RecordAction(UserMetricsAction("DevTools_ToggleConsole")); 2066 UserMetrics::RecordAction(UserMetricsAction("DevTools_ToggleConsole"));
2062 else 2067 else
2063 UserMetrics::RecordAction(UserMetricsAction("DevTools_ToggleWindow")); 2068 UserMetrics::RecordAction(UserMetricsAction("DevTools_ToggleWindow"));
2064 2069
2065 DevToolsWindow::ToggleDevToolsWindow( 2070 DevToolsWindow::ToggleDevToolsWindow(
2066 GetSelectedTabContentsWrapper()->render_view_host(), action); 2071 GetSelectedTabContentsWrapper()->tab_contents()->render_view_host(),
2072 action);
2067 } 2073 }
2068 2074
2069 void Browser::OpenTaskManager(bool highlight_background_resources) { 2075 void Browser::OpenTaskManager(bool highlight_background_resources) {
2070 UserMetrics::RecordAction(UserMetricsAction("TaskManager")); 2076 UserMetrics::RecordAction(UserMetricsAction("TaskManager"));
2071 if (highlight_background_resources) 2077 if (highlight_background_resources)
2072 window_->ShowBackgroundPages(); 2078 window_->ShowBackgroundPages();
2073 else 2079 else
2074 window_->ShowTaskManager(); 2080 window_->ShowTaskManager();
2075 } 2081 }
2076 2082
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
3065 TabContentsWrapper* Browser::CreateTabContentsForURL( 3071 TabContentsWrapper* Browser::CreateTabContentsForURL(
3066 const GURL& url, const content::Referrer& referrer, Profile* profile, 3072 const GURL& url, const content::Referrer& referrer, Profile* profile,
3067 content::PageTransition transition, bool defer_load, 3073 content::PageTransition transition, bool defer_load,
3068 SiteInstance* instance) const { 3074 SiteInstance* instance) const {
3069 TabContentsWrapper* contents = TabContentsFactory(profile, instance, 3075 TabContentsWrapper* contents = TabContentsFactory(profile, instance,
3070 MSG_ROUTING_NONE, 3076 MSG_ROUTING_NONE,
3071 GetSelectedTabContents(), NULL); 3077 GetSelectedTabContents(), NULL);
3072 if (!defer_load) { 3078 if (!defer_load) {
3073 // Load the initial URL before adding the new tab contents to the tab strip 3079 // Load the initial URL before adding the new tab contents to the tab strip
3074 // so that the tab contents has navigation state. 3080 // so that the tab contents has navigation state.
3075 contents->controller().LoadURL(url, referrer, transition, std::string()); 3081 contents->tab_contents()->controller().LoadURL(
3082 url, referrer, transition, std::string());
3076 } 3083 }
3077 3084
3078 return contents; 3085 return contents;
3079 } 3086 }
3080 3087
3081 bool Browser::CanDuplicateContentsAt(int index) { 3088 bool Browser::CanDuplicateContentsAt(int index) {
3082 NavigationController& nc = GetTabContentsAt(index)->controller(); 3089 NavigationController& nc = GetTabContentsAt(index)->controller();
3083 return nc.tab_contents() && nc.GetLastCommittedEntry(); 3090 return nc.tab_contents() && nc.GetLastCommittedEntry();
3084 } 3091 }
3085 3092
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
3151 3158
3152 // We don't create historical tabs for print preview tabs. 3159 // We don't create historical tabs for print preview tabs.
3153 if (contents->tab_contents()->GetURL() == GURL(chrome::kChromeUIPrintURL)) 3160 if (contents->tab_contents()->GetURL() == GURL(chrome::kChromeUIPrintURL))
3154 return; 3161 return;
3155 3162
3156 TabRestoreService* service = 3163 TabRestoreService* service =
3157 TabRestoreServiceFactory::GetForProfile(profile()); 3164 TabRestoreServiceFactory::GetForProfile(profile());
3158 3165
3159 // We only create historical tab entries for tabbed browser windows. 3166 // We only create historical tab entries for tabbed browser windows.
3160 if (service && CanSupportWindowFeature(FEATURE_TABSTRIP)) { 3167 if (service && CanSupportWindowFeature(FEATURE_TABSTRIP)) {
3161 service->CreateHistoricalTab(&contents->controller(), 3168 service->CreateHistoricalTab(&contents->tab_contents()->controller(),
3162 tab_handler_->GetTabStripModel()->GetIndexOfTabContents(contents)); 3169 tab_handler_->GetTabStripModel()->GetIndexOfTabContents(contents));
3163 } 3170 }
3164 } 3171 }
3165 3172
3166 bool Browser::RunUnloadListenerBeforeClosing(TabContentsWrapper* contents) { 3173 bool Browser::RunUnloadListenerBeforeClosing(TabContentsWrapper* contents) {
3167 return Browser::RunUnloadEventsHelper(contents->tab_contents()); 3174 return Browser::RunUnloadEventsHelper(contents->tab_contents());
3168 } 3175 }
3169 3176
3170 bool Browser::CanReloadContents(TabContents* source) const { 3177 bool Browser::CanReloadContents(TabContents* source) const {
3171 return !is_devtools(); 3178 return !is_devtools();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
3239 registrar_.Add(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED, 3246 registrar_.Add(this, content::NOTIFICATION_INTERSTITIAL_ATTACHED,
3240 content::Source<TabContents>(contents->tab_contents())); 3247 content::Source<TabContents>(contents->tab_contents()));
3241 } 3248 }
3242 3249
3243 void Browser::TabClosingAt(TabStripModel* tab_strip_model, 3250 void Browser::TabClosingAt(TabStripModel* tab_strip_model,
3244 TabContentsWrapper* contents, 3251 TabContentsWrapper* contents,
3245 int index) { 3252 int index) {
3246 fullscreen_controller_->OnTabClosing(contents->tab_contents()); 3253 fullscreen_controller_->OnTabClosing(contents->tab_contents());
3247 content::NotificationService::current()->Notify( 3254 content::NotificationService::current()->Notify(
3248 content::NOTIFICATION_TAB_CLOSING, 3255 content::NOTIFICATION_TAB_CLOSING,
3249 content::Source<NavigationController>(&contents->controller()), 3256 content::Source<NavigationController>(
3257 &contents->tab_contents()->controller()),
3250 content::NotificationService::NoDetails()); 3258 content::NotificationService::NoDetails());
3251 3259
3252 // Sever the TabContents' connection back to us. 3260 // Sever the TabContents' connection back to us.
3253 SetAsDelegate(contents, NULL); 3261 SetAsDelegate(contents, NULL);
3254 } 3262 }
3255 3263
3256 void Browser::TabDetachedAt(TabContentsWrapper* contents, int index) { 3264 void Browser::TabDetachedAt(TabContentsWrapper* contents, int index) {
3257 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH); 3265 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH);
3258 } 3266 }
3259 3267
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
3337 } 3345 }
3338 3346
3339 void Browser::TabReplacedAt(TabStripModel* tab_strip_model, 3347 void Browser::TabReplacedAt(TabStripModel* tab_strip_model,
3340 TabContentsWrapper* old_contents, 3348 TabContentsWrapper* old_contents,
3341 TabContentsWrapper* new_contents, 3349 TabContentsWrapper* new_contents,
3342 int index) { 3350 int index) {
3343 TabDetachedAtImpl(old_contents, index, DETACH_TYPE_REPLACE); 3351 TabDetachedAtImpl(old_contents, index, DETACH_TYPE_REPLACE);
3344 TabInsertedAt(new_contents, index, 3352 TabInsertedAt(new_contents, index,
3345 (index == tab_handler_->GetTabStripModel()->active_index())); 3353 (index == tab_handler_->GetTabStripModel()->active_index()));
3346 3354
3347 int entry_count = new_contents->controller().entry_count(); 3355 int entry_count = new_contents->tab_contents()->controller().entry_count();
3348 if (entry_count > 0) { 3356 if (entry_count > 0) {
3349 // Send out notification so that observers are updated appropriately. 3357 // Send out notification so that observers are updated appropriately.
3350 new_contents->controller().NotifyEntryChanged( 3358 new_contents->tab_contents()->controller().NotifyEntryChanged(
3351 new_contents->controller().GetEntryAtIndex(entry_count - 1), 3359 new_contents->tab_contents()->controller().GetEntryAtIndex(
3360 entry_count - 1),
3352 entry_count - 1); 3361 entry_count - 1);
3353 } 3362 }
3354 3363
3355 SessionService* session_service = 3364 SessionService* session_service =
3356 SessionServiceFactory::GetForProfile(profile()); 3365 SessionServiceFactory::GetForProfile(profile());
3357 if (session_service) { 3366 if (session_service) {
3358 // The new_contents may end up with a different navigation stack. Force 3367 // The new_contents may end up with a different navigation stack. Force
3359 // the session service to update itself. 3368 // the session service to update itself.
3360 session_service->TabRestored( 3369 session_service->TabRestored(
3361 new_contents, tab_handler_->GetTabStripModel()->IsTabPinned(index)); 3370 new_contents, tab_handler_->GetTabStripModel()->IsTabPinned(index));
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
3955 3964
3956 3965
3957 /////////////////////////////////////////////////////////////////////////////// 3966 ///////////////////////////////////////////////////////////////////////////////
3958 // Browser, CoreTabHelperDelegate implementation: 3967 // Browser, CoreTabHelperDelegate implementation:
3959 3968
3960 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source, 3969 void Browser::OnDidGetApplicationInfo(TabContentsWrapper* source,
3961 int32 page_id) { 3970 int32 page_id) {
3962 if (GetSelectedTabContentsWrapper() != source) 3971 if (GetSelectedTabContentsWrapper() != source)
3963 return; 3972 return;
3964 3973
3965 NavigationEntry* entry = source->controller().GetLastCommittedEntry(); 3974 NavigationEntry* entry =
3975 source->tab_contents()->controller().GetLastCommittedEntry();
3966 if (!entry || (entry->page_id() != page_id)) 3976 if (!entry || (entry->page_id() != page_id))
3967 return; 3977 return;
3968 3978
3969 switch (pending_web_app_action_) { 3979 switch (pending_web_app_action_) {
3970 case CREATE_SHORTCUT: { 3980 case CREATE_SHORTCUT: {
3971 window()->ShowCreateWebAppShortcutsDialog(source); 3981 window()->ShowCreateWebAppShortcutsDialog(source);
3972 break; 3982 break;
3973 } 3983 }
3974 case UPDATE_SHORTCUT: { 3984 case UPDATE_SHORTCUT: {
3975 web_app::UpdateShortcutForTabContents(source); 3985 web_app::UpdateShortcutForTabContents(source);
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
5133 INSTANT_COMMIT_PRESSED_ENTER)), 5143 INSTANT_COMMIT_PRESSED_ENTER)),
5134 content::NotificationService::NoDetails()); 5144 content::NotificationService::NoDetails());
5135 return true; 5145 return true;
5136 } 5146 }
5137 if (disposition == NEW_FOREGROUND_TAB) { 5147 if (disposition == NEW_FOREGROUND_TAB) {
5138 TabContentsWrapper* preview_contents = instant()->ReleasePreviewContents( 5148 TabContentsWrapper* preview_contents = instant()->ReleasePreviewContents(
5139 INSTANT_COMMIT_PRESSED_ENTER); 5149 INSTANT_COMMIT_PRESSED_ENTER);
5140 // HideInstant is invoked after release so that InstantController is not 5150 // HideInstant is invoked after release so that InstantController is not
5141 // active when HideInstant asks it for its state. 5151 // active when HideInstant asks it for its state.
5142 HideInstant(); 5152 HideInstant();
5143 preview_contents->controller().PruneAllButActive(); 5153 preview_contents->tab_contents()->controller().PruneAllButActive();
5144 tab_handler_->GetTabStripModel()->AddTabContents( 5154 tab_handler_->GetTabStripModel()->AddTabContents(
5145 preview_contents, 5155 preview_contents,
5146 -1, 5156 -1,
5147 instant()->last_transition_type(), 5157 instant()->last_transition_type(),
5148 TabStripModel::ADD_ACTIVE); 5158 TabStripModel::ADD_ACTIVE);
5149 instant()->CompleteRelease(preview_contents); 5159 instant()->CompleteRelease(preview_contents);
5150 content::NotificationService::current()->Notify( 5160 content::NotificationService::current()->Notify(
5151 chrome::NOTIFICATION_INSTANT_COMMITTED, 5161 chrome::NOTIFICATION_INSTANT_COMMITTED,
5152 content::Source<TabContentsWrapper>(preview_contents), 5162 content::Source<TabContentsWrapper>(preview_contents),
5153 content::NotificationService::NoDetails()); 5163 content::NotificationService::NoDetails());
(...skipping 10 matching lines...) Expand all
5164 if (is_type_tabbed() && InstantController::IsEnabled(profile()) && 5174 if (is_type_tabbed() && InstantController::IsEnabled(profile()) &&
5165 !profile()->IsOffTheRecord()) { 5175 !profile()->IsOffTheRecord()) {
5166 instant_.reset(new InstantController(profile_, this)); 5176 instant_.reset(new InstantController(profile_, this));
5167 instant_unload_handler_.reset(new InstantUnloadHandler(this)); 5177 instant_unload_handler_.reset(new InstantUnloadHandler(this));
5168 } 5178 }
5169 } 5179 }
5170 5180
5171 void Browser::ViewSource(TabContentsWrapper* contents) { 5181 void Browser::ViewSource(TabContentsWrapper* contents) {
5172 DCHECK(contents); 5182 DCHECK(contents);
5173 5183
5174 NavigationEntry* active_entry = contents->controller().GetActiveEntry(); 5184 NavigationEntry* active_entry =
5185 contents->tab_contents()->controller().GetActiveEntry();
5175 if (!active_entry) 5186 if (!active_entry)
5176 return; 5187 return;
5177 5188
5178 ViewSource(contents, active_entry->url(), active_entry->content_state()); 5189 ViewSource(contents, active_entry->url(), active_entry->content_state());
5179 } 5190 }
5180 5191
5181 void Browser::ViewSource(TabContentsWrapper* contents, 5192 void Browser::ViewSource(TabContentsWrapper* contents,
5182 const GURL& url, 5193 const GURL& url,
5183 const std::string& content_state) { 5194 const std::string& content_state) {
5184 UserMetrics::RecordAction(UserMetricsAction("ViewSource")); 5195 UserMetrics::RecordAction(UserMetricsAction("ViewSource"));
5185 DCHECK(contents); 5196 DCHECK(contents);
5186 5197
5187 TabContentsWrapper* view_source_contents = contents->Clone(); 5198 TabContentsWrapper* view_source_contents = contents->Clone();
5188 view_source_contents->controller().PruneAllButActive(); 5199 view_source_contents->tab_contents()->controller().PruneAllButActive();
5189 NavigationEntry* active_entry = 5200 NavigationEntry* active_entry =
5190 view_source_contents->controller().GetActiveEntry(); 5201 view_source_contents->tab_contents()->controller().GetActiveEntry();
5191 if (!active_entry) 5202 if (!active_entry)
5192 return; 5203 return;
5193 5204
5194 GURL view_source_url = GURL(chrome::kViewSourceScheme + std::string(":") + 5205 GURL view_source_url = GURL(chrome::kViewSourceScheme + std::string(":") +
5195 url.spec()); 5206 url.spec());
5196 active_entry->set_virtual_url(view_source_url); 5207 active_entry->set_virtual_url(view_source_url);
5197 5208
5198 // Do not restore scroller position. 5209 // Do not restore scroller position.
5199 active_entry->set_content_state( 5210 active_entry->set_content_state(
5200 webkit_glue::RemoveScrollOffsetFromHistoryState(content_state)); 5211 webkit_glue::RemoveScrollOffsetFromHistoryState(content_state));
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
5288 void Browser::ShowSyncSetup() { 5299 void Browser::ShowSyncSetup() {
5289 ProfileSyncService* service = 5300 ProfileSyncService* service =
5290 profile()->GetOriginalProfile()->GetProfileSyncService(); 5301 profile()->GetOriginalProfile()->GetProfileSyncService();
5291 if (service->HasSyncSetupCompleted()) 5302 if (service->HasSyncSetupCompleted())
5292 ShowOptionsTab(chrome::kPersonalOptionsSubPage); 5303 ShowOptionsTab(chrome::kPersonalOptionsSubPage);
5293 else 5304 else
5294 service->ShowLoginDialog(); 5305 service->ShowLoginDialog();
5295 } 5306 }
5296 5307
5297 void Browser::ToggleSpeechInput() { 5308 void Browser::ToggleSpeechInput() {
5298 GetSelectedTabContentsWrapper()->render_view_host()->ToggleSpeechInput(); 5309 GetSelectedTabContentsWrapper()->tab_contents()->render_view_host()->
5310 ToggleSpeechInput();
5299 } 5311 }
5300 5312
5301 void Browser::OnWindowDidShow() { 5313 void Browser::OnWindowDidShow() {
5302 if (window_has_shown_) 5314 if (window_has_shown_)
5303 return; 5315 return;
5304 window_has_shown_ = true; 5316 window_has_shown_ = true;
5305 5317
5306 // Nothing to do for non-tabbed windows. 5318 // Nothing to do for non-tabbed windows.
5307 if (!is_type_tabbed()) 5319 if (!is_type_tabbed())
5308 return; 5320 return;
(...skipping 24 matching lines...) Expand all
5333 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type); 5345 window_->GetLocationBar()->ShowFirstRunBubble(bubble_type);
5334 } else { 5346 } else {
5335 GlobalErrorService* service = 5347 GlobalErrorService* service =
5336 GlobalErrorServiceFactory::GetForProfile(profile()); 5348 GlobalErrorServiceFactory::GetForProfile(profile());
5337 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); 5349 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView();
5338 if (error) { 5350 if (error) {
5339 error->ShowBubbleView(this); 5351 error->ShowBubbleView(this);
5340 } 5352 }
5341 } 5353 }
5342 } 5354 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/alternate_error_tab_observer.cc ('k') | chrome/browser/ui/browser_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698