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

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

Issue 10105030: TabContents -> WebContentsImpl, part 21. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months 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/browser.h ('k') | chrome/browser/ui/browser_list.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #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 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 extension_misc::LAUNCH_WINDOW, 844 extension_misc::LAUNCH_WINDOW,
845 url, 845 url,
846 &app_browser); 846 &app_browser);
847 847
848 if (!tab) 848 if (!tab)
849 return NULL; 849 return NULL;
850 850
851 if (update_shortcut) { 851 if (update_shortcut) {
852 // Set UPDATE_SHORTCUT as the pending web app action. This action is picked 852 // Set UPDATE_SHORTCUT as the pending web app action. This action is picked
853 // up in LoadingStateChanged to schedule a GetApplicationInfo. And when 853 // up in LoadingStateChanged to schedule a GetApplicationInfo. And when
854 // the web app info is available, TabContents notifies Browser via 854 // the web app info is available, ExtensionTabHelper notifies Browser via
855 // OnDidGetApplicationInfo, which calls 855 // OnDidGetApplicationInfo, which calls
856 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as 856 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as
857 // pending web app action. 857 // pending web app action.
858 app_browser->pending_web_app_action_ = UPDATE_SHORTCUT; 858 app_browser->pending_web_app_action_ = UPDATE_SHORTCUT;
859 } 859 }
860 return tab; 860 return tab;
861 } 861 }
862 862
863 // static 863 // static
864 WebContents* Browser::OpenApplicationTab(Profile* profile, 864 WebContents* Browser::OpenApplicationTab(Profile* profile,
(...skipping 1906 matching lines...) Expand 10 before | Expand all | Expand 10 after
2771 prefs->RegisterIntegerPref(prefs::kDiskCacheSize, 2771 prefs->RegisterIntegerPref(prefs::kDiskCacheSize,
2772 0, 2772 0,
2773 PrefService::UNSYNCABLE_PREF); 2773 PrefService::UNSYNCABLE_PREF);
2774 prefs->RegisterIntegerPref(prefs::kMediaCacheSize, 2774 prefs->RegisterIntegerPref(prefs::kMediaCacheSize,
2775 0, 2775 0,
2776 PrefService::UNSYNCABLE_PREF); 2776 PrefService::UNSYNCABLE_PREF);
2777 } 2777 }
2778 2778
2779 // static 2779 // static
2780 bool Browser::RunUnloadEventsHelper(WebContents* contents) { 2780 bool Browser::RunUnloadEventsHelper(WebContents* contents) {
2781 // If the TabContents is not connected yet, then there's no unload 2781 // If the WebContents is not connected yet, then there's no unload
2782 // handler we can fire even if the TabContents has an unload listener. 2782 // handler we can fire even if the WebContents has an unload listener.
2783 // One case where we hit this is in a tab that has an infinite loop 2783 // One case where we hit this is in a tab that has an infinite loop
2784 // before load. 2784 // before load.
2785 if (contents->NeedToFireBeforeUnload()) { 2785 if (contents->NeedToFireBeforeUnload()) {
2786 // If the page has unload listeners, then we tell the renderer to fire 2786 // If the page has unload listeners, then we tell the renderer to fire
2787 // them. Once they have fired, we'll get a message back saying whether 2787 // them. Once they have fired, we'll get a message back saying whether
2788 // to proceed closing the page or not, which sends us back to this method 2788 // to proceed closing the page or not, which sends us back to this method
2789 // with the NeedToFireBeforeUnload bit cleared. 2789 // with the NeedToFireBeforeUnload bit cleared.
2790 contents->GetRenderViewHost()->FirePageBeforeUnload(false); 2790 contents->GetRenderViewHost()->FirePageBeforeUnload(false);
2791 return true; 2791 return true;
2792 } 2792 }
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
3272 3272
3273 /////////////////////////////////////////////////////////////////////////////// 3273 ///////////////////////////////////////////////////////////////////////////////
3274 // Browser, TabStripModelDelegate implementation: 3274 // Browser, TabStripModelDelegate implementation:
3275 3275
3276 TabContentsWrapper* Browser::AddBlankTab(bool foreground) { 3276 TabContentsWrapper* Browser::AddBlankTab(bool foreground) {
3277 return AddBlankTabAt(-1, foreground); 3277 return AddBlankTabAt(-1, foreground);
3278 } 3278 }
3279 3279
3280 TabContentsWrapper* Browser::AddBlankTabAt(int index, bool foreground) { 3280 TabContentsWrapper* Browser::AddBlankTabAt(int index, bool foreground) {
3281 // Time new tab page creation time. We keep track of the timing data in 3281 // Time new tab page creation time. We keep track of the timing data in
3282 // TabContents, but we want to include the time it takes to create the 3282 // WebContents, but we want to include the time it takes to create the
3283 // TabContents object too. 3283 // WebContents object too.
3284 base::TimeTicks new_tab_start_time = base::TimeTicks::Now(); 3284 base::TimeTicks new_tab_start_time = base::TimeTicks::Now();
3285 browser::NavigateParams params(this, GURL(chrome::kChromeUINewTabURL), 3285 browser::NavigateParams params(this, GURL(chrome::kChromeUINewTabURL),
3286 content::PAGE_TRANSITION_TYPED); 3286 content::PAGE_TRANSITION_TYPED);
3287 params.disposition = foreground ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; 3287 params.disposition = foreground ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB;
3288 params.tabstrip_index = index; 3288 params.tabstrip_index = index;
3289 browser::Navigate(&params); 3289 browser::Navigate(&params);
3290 params.target_contents->web_contents()->SetNewTabStartTime( 3290 params.target_contents->web_contents()->SetNewTabStartTime(
3291 new_tab_start_time); 3291 new_tab_start_time);
3292 return params.target_contents; 3292 return params.target_contents;
3293 } 3293 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
3374 Browser::CreateParams(TYPE_POPUP, profile_)); 3374 Browser::CreateParams(TYPE_POPUP, profile_));
3375 } 3375 }
3376 3376
3377 // Preserve the size of the original window. The new window has already 3377 // Preserve the size of the original window. The new window has already
3378 // been given an offset by the OS, so we shouldn't copy the old bounds. 3378 // been given an offset by the OS, so we shouldn't copy the old bounds.
3379 BrowserWindow* new_window = browser->window(); 3379 BrowserWindow* new_window = browser->window();
3380 new_window->SetBounds(gfx::Rect(new_window->GetRestoredBounds().origin(), 3380 new_window->SetBounds(gfx::Rect(new_window->GetRestoredBounds().origin(),
3381 window()->GetRestoredBounds().size())); 3381 window()->GetRestoredBounds().size()));
3382 3382
3383 // We need to show the browser now. Otherwise ContainerWin assumes the 3383 // We need to show the browser now. Otherwise ContainerWin assumes the
3384 // TabContents is invisible and won't size it. 3384 // WebContents is invisible and won't size it.
3385 browser->window()->Show(); 3385 browser->window()->Show();
3386 3386
3387 // The page transition below is only for the purpose of inserting the tab. 3387 // The page transition below is only for the purpose of inserting the tab.
3388 browser->AddTab(contents_dupe, content::PAGE_TRANSITION_LINK); 3388 browser->AddTab(contents_dupe, content::PAGE_TRANSITION_LINK);
3389 } 3389 }
3390 3390
3391 SessionService* session_service = 3391 SessionService* session_service =
3392 SessionServiceFactory::GetForProfileIfExisting(profile_); 3392 SessionServiceFactory::GetForProfileIfExisting(profile_);
3393 if (session_service) 3393 if (session_service)
3394 session_service->TabRestored(contents_dupe, pinned); 3394 session_service->TabRestored(contents_dupe, pinned);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
3507 void Browser::TabClosingAt(TabStripModel* tab_strip_model, 3507 void Browser::TabClosingAt(TabStripModel* tab_strip_model,
3508 TabContentsWrapper* contents, 3508 TabContentsWrapper* contents,
3509 int index) { 3509 int index) {
3510 fullscreen_controller_->OnTabClosing(contents->web_contents()); 3510 fullscreen_controller_->OnTabClosing(contents->web_contents());
3511 content::NotificationService::current()->Notify( 3511 content::NotificationService::current()->Notify(
3512 chrome::NOTIFICATION_TAB_CLOSING, 3512 chrome::NOTIFICATION_TAB_CLOSING,
3513 content::Source<NavigationController>( 3513 content::Source<NavigationController>(
3514 &contents->web_contents()->GetController()), 3514 &contents->web_contents()->GetController()),
3515 content::NotificationService::NoDetails()); 3515 content::NotificationService::NoDetails());
3516 3516
3517 // Sever the TabContents' connection back to us. 3517 // Sever the WebContents' connection back to us.
3518 SetAsDelegate(contents, NULL); 3518 SetAsDelegate(contents, NULL);
3519 } 3519 }
3520 3520
3521 void Browser::TabDetachedAt(TabContentsWrapper* contents, int index) { 3521 void Browser::TabDetachedAt(TabContentsWrapper* contents, int index) {
3522 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH); 3522 TabDetachedAtImpl(contents, index, DETACH_TYPE_DETACH);
3523 } 3523 }
3524 3524
3525 void Browser::TabDeactivated(TabContentsWrapper* contents) { 3525 void Browser::TabDeactivated(TabContentsWrapper* contents) {
3526 fullscreen_controller_->OnTabDeactivated(contents); 3526 fullscreen_controller_->OnTabDeactivated(contents);
3527 if (instant()) 3527 if (instant())
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
4107 4107
4108 return true; 4108 return true;
4109 } 4109 }
4110 4110
4111 void Browser::WebContentsCreated(WebContents* source_contents, 4111 void Browser::WebContentsCreated(WebContents* source_contents,
4112 int64 source_frame_id, 4112 int64 source_frame_id,
4113 const GURL& target_url, 4113 const GURL& target_url,
4114 WebContents* new_contents) { 4114 WebContents* new_contents) {
4115 // Create a TabContentsWrapper now, so all observers are in place, as the 4115 // Create a TabContentsWrapper now, so all observers are in place, as the
4116 // network requests for its initial navigation will start immediately. The 4116 // network requests for its initial navigation will start immediately. The
4117 // TabContents will later be inserted into this browser using 4117 // WebContents will later be inserted into this browser using
4118 // Browser::Navigate via AddNewContents. The latter will retrieve the newly 4118 // Browser::Navigate via AddNewContents. The latter will retrieve the newly
4119 // created TabContentsWrapper from TabContents object. 4119 // created TabContentsWrapper from WebContents object.
4120 new TabContentsWrapper(new_contents); 4120 new TabContentsWrapper(new_contents);
4121 4121
4122 // Notify. 4122 // Notify.
4123 RetargetingDetails details; 4123 RetargetingDetails details;
4124 details.source_web_contents = source_contents; 4124 details.source_web_contents = source_contents;
4125 details.source_frame_id = source_frame_id; 4125 details.source_frame_id = source_frame_id;
4126 details.target_url = target_url; 4126 details.target_url = target_url;
4127 details.target_web_contents = new_contents; 4127 details.target_web_contents = new_contents;
4128 details.not_yet_in_tabstrip = true; 4128 details.not_yet_in_tabstrip = true;
4129 content::NotificationService::current()->Notify( 4129 content::NotificationService::current()->Notify(
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after
5379 5379
5380 // static 5380 // static
5381 Browser* Browser::GetOrCreateTabbedBrowser(Profile* profile) { 5381 Browser* Browser::GetOrCreateTabbedBrowser(Profile* profile) {
5382 Browser* browser = GetTabbedBrowser(profile, false); 5382 Browser* browser = GetTabbedBrowser(profile, false);
5383 if (!browser) 5383 if (!browser)
5384 browser = Browser::Create(profile); 5384 browser = Browser::Create(profile);
5385 return browser; 5385 return browser;
5386 } 5386 }
5387 5387
5388 void Browser::SetAsDelegate(TabContentsWrapper* tab, Browser* delegate) { 5388 void Browser::SetAsDelegate(TabContentsWrapper* tab, Browser* delegate) {
5389 // TabContents... 5389 // WebContents...
5390 tab->web_contents()->SetDelegate(delegate); 5390 tab->web_contents()->SetDelegate(delegate);
5391 5391
5392 // ...and all the helpers. 5392 // ...and all the helpers.
5393 tab->blocked_content_tab_helper()->set_delegate(delegate); 5393 tab->blocked_content_tab_helper()->set_delegate(delegate);
5394 tab->bookmark_tab_helper()->set_delegate(delegate); 5394 tab->bookmark_tab_helper()->set_delegate(delegate);
5395 tab->constrained_window_tab_helper()->set_delegate(delegate); 5395 tab->constrained_window_tab_helper()->set_delegate(delegate);
5396 tab->core_tab_helper()->set_delegate(delegate); 5396 tab->core_tab_helper()->set_delegate(delegate);
5397 tab->extension_tab_helper()->set_delegate(delegate); 5397 tab->extension_tab_helper()->set_delegate(delegate);
5398 tab->search_engine_tab_helper()->set_delegate(delegate); 5398 tab->search_engine_tab_helper()->set_delegate(delegate);
5399 } 5399 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
5477 5477
5478 void Browser::TabRestoreServiceDestroyed(TabRestoreService* service) { 5478 void Browser::TabRestoreServiceDestroyed(TabRestoreService* service) {
5479 if (!tab_restore_service_) 5479 if (!tab_restore_service_)
5480 return; 5480 return;
5481 5481
5482 DCHECK_EQ(tab_restore_service_, service); 5482 DCHECK_EQ(tab_restore_service_, service);
5483 tab_restore_service_->RemoveObserver(this); 5483 tab_restore_service_->RemoveObserver(this);
5484 tab_restore_service_ = NULL; 5484 tab_restore_service_ = NULL;
5485 } 5485 }
5486 5486
5487 // Centralized method for creating a TabContents, configuring and installing 5487 // Centralized method for creating a TabContentsWrapper, configuring and
5488 // all its supporting objects and observers. 5488 // installing all its supporting objects and observers.
5489 TabContentsWrapper* Browser::TabContentsFactory( 5489 TabContentsWrapper* Browser::TabContentsFactory(
5490 Profile* profile, 5490 Profile* profile,
5491 SiteInstance* site_instance, 5491 SiteInstance* site_instance,
5492 int routing_id, 5492 int routing_id,
5493 const WebContents* base_web_contents, 5493 const WebContents* base_web_contents,
5494 content::SessionStorageNamespace* session_storage_namespace) { 5494 content::SessionStorageNamespace* session_storage_namespace) {
5495 WebContents* new_contents = WebContents::Create( 5495 WebContents* new_contents = WebContents::Create(
5496 profile, site_instance, routing_id, base_web_contents, 5496 profile, site_instance, routing_id, base_web_contents,
5497 session_storage_namespace); 5497 session_storage_namespace);
5498 TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents); 5498 TabContentsWrapper* wrapper = new TabContentsWrapper(new_contents);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
5599 Browser* browser = Browser::CreateWithParams( 5599 Browser* browser = Browser::CreateWithParams(
5600 Browser::CreateParams(TYPE_TABBED, profile_)); 5600 Browser::CreateParams(TYPE_TABBED, profile_));
5601 5601
5602 // Preserve the size of the original window. The new window has already 5602 // Preserve the size of the original window. The new window has already
5603 // been given an offset by the OS, so we shouldn't copy the old bounds. 5603 // been given an offset by the OS, so we shouldn't copy the old bounds.
5604 BrowserWindow* new_window = browser->window(); 5604 BrowserWindow* new_window = browser->window();
5605 new_window->SetBounds(gfx::Rect(new_window->GetRestoredBounds().origin(), 5605 new_window->SetBounds(gfx::Rect(new_window->GetRestoredBounds().origin(),
5606 window()->GetRestoredBounds().size())); 5606 window()->GetRestoredBounds().size()));
5607 5607
5608 // We need to show the browser now. Otherwise ContainerWin assumes the 5608 // We need to show the browser now. Otherwise ContainerWin assumes the
5609 // TabContents is invisible and won't size it. 5609 // WebContents is invisible and won't size it.
5610 browser->window()->Show(); 5610 browser->window()->Show();
5611 5611
5612 // The page transition below is only for the purpose of inserting the tab. 5612 // The page transition below is only for the purpose of inserting the tab.
5613 browser->AddTab(view_source_contents, content::PAGE_TRANSITION_LINK); 5613 browser->AddTab(view_source_contents, content::PAGE_TRANSITION_LINK);
5614 } 5614 }
5615 5615
5616 SessionService* session_service = 5616 SessionService* session_service =
5617 SessionServiceFactory::GetForProfileIfExisting(profile_); 5617 SessionServiceFactory::GetForProfileIfExisting(profile_);
5618 if (session_service) 5618 if (session_service)
5619 session_service->TabRestored(view_source_contents, false); 5619 session_service->TabRestored(view_source_contents, false);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
5690 ShowSingletonTabOverwritingNTP(params); 5690 ShowSingletonTabOverwritingNTP(params);
5691 } else { 5691 } else {
5692 LoginUIServiceFactory::GetForProfile( 5692 LoginUIServiceFactory::GetForProfile(
5693 profile()->GetOriginalProfile())->ShowLoginUI(false); 5693 profile()->GetOriginalProfile())->ShowLoginUI(false);
5694 } 5694 }
5695 } 5695 }
5696 5696
5697 void Browser::ToggleSpeechInput() { 5697 void Browser::ToggleSpeechInput() {
5698 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); 5698 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput();
5699 } 5699 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/browser_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698