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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 10540100: TabContentsWrapper -> TabContents, part 48. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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
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/views/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 19 matching lines...) Expand all
30 #include "chrome/browser/profiles/profile_info_cache.h" 30 #include "chrome/browser/profiles/profile_info_cache.h"
31 #include "chrome/browser/profiles/profile_manager.h" 31 #include "chrome/browser/profiles/profile_manager.h"
32 #include "chrome/browser/sessions/tab_restore_service.h" 32 #include "chrome/browser/sessions/tab_restore_service.h"
33 #include "chrome/browser/sessions/tab_restore_service_factory.h" 33 #include "chrome/browser/sessions/tab_restore_service_factory.h"
34 #include "chrome/browser/speech/extension_api/tts_extension_api.h" 34 #include "chrome/browser/speech/extension_api/tts_extension_api.h"
35 #include "chrome/browser/themes/theme_service.h" 35 #include "chrome/browser/themes/theme_service.h"
36 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" 36 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
37 #include "chrome/browser/ui/browser.h" 37 #include "chrome/browser/ui/browser.h"
38 #include "chrome/browser/ui/browser_dialogs.h" 38 #include "chrome/browser/ui/browser_dialogs.h"
39 #include "chrome/browser/ui/browser_list.h" 39 #include "chrome/browser/ui/browser_list.h"
40 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 40 #include "chrome/browser/ui/tab_contents/tab_contents.h"
41 #include "chrome/browser/ui/tabs/tab_menu_model.h" 41 #include "chrome/browser/ui/tabs/tab_menu_model.h"
42 #include "chrome/browser/ui/tabs/tab_strip_model.h" 42 #include "chrome/browser/ui/tabs/tab_strip_model.h"
43 #include "chrome/browser/ui/view_ids.h" 43 #include "chrome/browser/ui/view_ids.h"
44 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h" 44 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h"
45 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" 45 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h"
46 #include "chrome/browser/ui/views/avatar_menu_button.h" 46 #include "chrome/browser/ui/views/avatar_menu_button.h"
47 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 47 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
48 #include "chrome/browser/ui/views/browser_dialogs.h" 48 #include "chrome/browser/ui/views/browser_dialogs.h"
49 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" 49 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h"
50 #include "chrome/browser/ui/views/download/download_shelf_view.h" 50 #include "chrome/browser/ui/views/download/download_shelf_view.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas, 198 void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas,
199 views::View* view) const { 199 views::View* view) const {
200 ui::ThemeProvider* tp = host_view_->GetThemeProvider(); 200 ui::ThemeProvider* tp = host_view_->GetThemeProvider();
201 int toolbar_overlap = host_view_->GetToolbarOverlap(); 201 int toolbar_overlap = host_view_->GetToolbarOverlap();
202 // The client edge is drawn below the toolbar bounds. 202 // The client edge is drawn below the toolbar bounds.
203 if (toolbar_overlap) 203 if (toolbar_overlap)
204 toolbar_overlap += views::NonClientFrameView::kClientEdgeThickness; 204 toolbar_overlap += views::NonClientFrameView::kClientEdgeThickness;
205 if (host_view_->IsDetached()) { 205 if (host_view_->IsDetached()) {
206 // Draw the background to match the new tab page. 206 // Draw the background to match the new tab page.
207 int height = 0; 207 int height = 0;
208 WebContents* contents = browser_->GetSelectedWebContents(); 208 WebContents* contents = browser_->GetActiveWebContents();
209 if (contents && contents->GetView()) 209 if (contents && contents->GetView())
210 height = contents->GetView()->GetContainerSize().height(); 210 height = contents->GetView()->GetContainerSize().height();
211 NtpBackgroundUtil::PaintBackgroundDetachedMode( 211 NtpBackgroundUtil::PaintBackgroundDetachedMode(
212 host_view_->GetThemeProvider(), canvas, 212 host_view_->GetThemeProvider(), canvas,
213 gfx::Rect(0, toolbar_overlap, host_view_->width(), 213 gfx::Rect(0, toolbar_overlap, host_view_->width(),
214 host_view_->height() - toolbar_overlap), height); 214 host_view_->height() - toolbar_overlap), height);
215 215
216 // As 'hidden' according to the animation is the full in-tab state, 216 // As 'hidden' according to the animation is the full in-tab state,
217 // we invert the value - when current_state is at '0', we expect the 217 // we invert the value - when current_state is at '0', we expect the
218 // bar to be docked. 218 // bar to be docked.
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 if (active_browser && (browser_ != active_browser)) { 501 if (active_browser && (browser_ != active_browser)) {
502 active_browser->window()->FlashFrame(true); 502 active_browser->window()->FlashFrame(true);
503 active_browser->window()->Activate(); 503 active_browser->window()->Activate();
504 } 504 }
505 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); 505 AppModalDialogQueue::GetInstance()->ActivateModalDialog();
506 return true; 506 return true;
507 } 507 }
508 return false; 508 return false;
509 } 509 }
510 510
511 WebContents* BrowserView::GetSelectedWebContents() const { 511 WebContents* BrowserView::GetActiveWebContents() const {
512 return browser_->GetSelectedWebContents(); 512 return browser_->GetActiveWebContents();
513 } 513 }
514 514
515 TabContentsWrapper* BrowserView::GetSelectedTabContentsWrapper() const { 515 TabContents* BrowserView::GetActiveTabContents() const {
516 return browser_->GetSelectedTabContentsWrapper(); 516 return browser_->GetActiveTabContents();
517 } 517 }
518 518
519 gfx::ImageSkia BrowserView::GetOTRAvatarIcon() const { 519 gfx::ImageSkia BrowserView::GetOTRAvatarIcon() const {
520 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 520 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
521 const gfx::ImageSkia* otr_avatar = 521 const gfx::ImageSkia* otr_avatar =
522 rb.GetNativeImageNamed(IDR_OTR_ICON).ToImageSkia(); 522 rb.GetNativeImageNamed(IDR_OTR_ICON).ToImageSkia();
523 return *otr_avatar; 523 return *otr_avatar;
524 } 524 }
525 525
526 bool BrowserView::IsPositionInWindowCaption(const gfx::Point& point) { 526 bool BrowserView::IsPositionInWindowCaption(const gfx::Point& point) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 // early-return in this case because we need to layout again so the infobar 626 // early-return in this case because we need to layout again so the infobar
627 // container's bounds are set correctly. 627 // container's bounds are set correctly.
628 static CallState call_state = NORMAL; 628 static CallState call_state = NORMAL;
629 629
630 // A reentrant call can (and should) use the fast resize path unless both it 630 // A reentrant call can (and should) use the fast resize path unless both it
631 // and the normal call are both non-animating. 631 // and the normal call are both non-animating.
632 bool use_fast_resize = 632 bool use_fast_resize =
633 is_animating || (call_state == REENTRANT_FORCE_FAST_RESIZE); 633 is_animating || (call_state == REENTRANT_FORCE_FAST_RESIZE);
634 if (use_fast_resize) 634 if (use_fast_resize)
635 contents_container_->SetFastResize(true); 635 contents_container_->SetFastResize(true);
636 UpdateUIForContents(browser_->GetSelectedTabContentsWrapper()); 636 UpdateUIForContents(browser_->GetActiveTabContents());
637 if (use_fast_resize) 637 if (use_fast_resize)
638 contents_container_->SetFastResize(false); 638 contents_container_->SetFastResize(false);
639 639
640 // Inform the InfoBarContainer that the distance to the location icon may have 640 // Inform the InfoBarContainer that the distance to the location icon may have
641 // changed. We have to do this after the block above so that the toolbars are 641 // changed. We have to do this after the block above so that the toolbars are
642 // laid out correctly for calculating the maximum arrow height below. 642 // laid out correctly for calculating the maximum arrow height below.
643 { 643 {
644 const LocationIconView* location_icon_view = 644 const LocationIconView* location_icon_view =
645 toolbar_->location_bar()->location_icon_view(); 645 toolbar_->location_bar()->location_icon_view();
646 // The +1 in the next line creates a 1-px gap between icon and arrow tip. 646 // The +1 in the next line creates a 1-px gap between icon and arrow tip.
(...skipping 25 matching lines...) Expand all
672 if (ShouldShowWindowIcon() && !loading_animation_timer_.IsRunning()) 672 if (ShouldShowWindowIcon() && !loading_animation_timer_.IsRunning())
673 frame_->UpdateWindowIcon(); 673 frame_->UpdateWindowIcon();
674 } 674 }
675 675
676 void BrowserView::BookmarkBarStateChanged( 676 void BrowserView::BookmarkBarStateChanged(
677 BookmarkBar::AnimateChangeType change_type) { 677 BookmarkBar::AnimateChangeType change_type) {
678 if (bookmark_bar_view_.get()) { 678 if (bookmark_bar_view_.get()) {
679 bookmark_bar_view_->SetBookmarkBarState( 679 bookmark_bar_view_->SetBookmarkBarState(
680 browser_->bookmark_bar_state(), change_type); 680 browser_->bookmark_bar_state(), change_type);
681 } 681 }
682 if (MaybeShowBookmarkBar(browser_->GetSelectedTabContentsWrapper())) 682 if (MaybeShowBookmarkBar(browser_->GetActiveTabContents()))
683 Layout(); 683 Layout();
684 } 684 }
685 685
686 void BrowserView::UpdateDevTools() { 686 void BrowserView::UpdateDevTools() {
687 UpdateDevToolsForContents(GetSelectedTabContentsWrapper()); 687 UpdateDevToolsForContents(GetActiveTabContents());
688 Layout(); 688 Layout();
689 } 689 }
690 690
691 691
692 void BrowserView::SetDevToolsDockSide(DevToolsDockSide side) { 692 void BrowserView::SetDevToolsDockSide(DevToolsDockSide side) {
693 if (devtools_dock_side_ == side) 693 if (devtools_dock_side_ == side)
694 return; 694 return;
695 695
696 if (devtools_container_->visible()) { 696 if (devtools_container_->visible()) {
697 HideDevToolsContainer(); 697 HideDevToolsContainer();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 } else { 810 } else {
811 ProcessFullscreen(true, GURL(), 811 ProcessFullscreen(true, GURL(),
812 FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION); 812 FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION);
813 } 813 }
814 } else { 814 } else {
815 ProcessFullscreen(false, GURL(), FEB_TYPE_NONE); 815 ProcessFullscreen(false, GURL(), FEB_TYPE_NONE);
816 } 816 }
817 } 817 }
818 818
819 void BrowserView::RestoreFocus() { 819 void BrowserView::RestoreFocus() {
820 WebContents* selected_web_contents = GetSelectedWebContents(); 820 WebContents* selected_web_contents = GetActiveWebContents();
821 if (selected_web_contents) 821 if (selected_web_contents)
822 selected_web_contents->GetView()->RestoreFocus(); 822 selected_web_contents->GetView()->RestoreFocus();
823 } 823 }
824 824
825 void BrowserView::SetWindowSwitcherButton(views::Button* button) { 825 void BrowserView::SetWindowSwitcherButton(views::Button* button) {
826 if (window_switcher_button_) 826 if (window_switcher_button_)
827 RemoveChildView(window_switcher_button_); 827 RemoveChildView(window_switcher_button_);
828 window_switcher_button_ = button; 828 window_switcher_button_ = button;
829 AddChildView(button); 829 AddChildView(button);
830 } 830 }
(...skipping 22 matching lines...) Expand all
853 DCHECK(focus_manager); 853 DCHECK(focus_manager);
854 focus_manager->ClearFocus(); 854 focus_manager->ClearFocus();
855 } 855 }
856 } 856 }
857 857
858 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) { 858 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) {
859 toolbar_->reload_button()->ChangeMode( 859 toolbar_->reload_button()->ChangeMode(
860 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, force); 860 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, force);
861 } 861 }
862 862
863 void BrowserView::UpdateToolbar(TabContentsWrapper* contents, 863 void BrowserView::UpdateToolbar(TabContents* contents,
864 bool should_restore_state) { 864 bool should_restore_state) {
865 toolbar_->Update(contents->web_contents(), should_restore_state); 865 toolbar_->Update(contents->web_contents(), should_restore_state);
866 } 866 }
867 867
868 void BrowserView::FocusToolbar() { 868 void BrowserView::FocusToolbar() {
869 // Start the traversal within the main toolbar. SetPaneFocus stores 869 // Start the traversal within the main toolbar. SetPaneFocus stores
870 // the current focused view before changing focus. 870 // the current focused view before changing focus.
871 toolbar_->SetPaneFocus(NULL); 871 toolbar_->SetPaneFocus(NULL);
872 } 872 }
873 873
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 download_shelf_->set_owned_by_client(); 1106 download_shelf_->set_owned_by_client();
1107 } 1107 }
1108 return download_shelf_.get(); 1108 return download_shelf_.get();
1109 } 1109 }
1110 1110
1111 void BrowserView::ConfirmBrowserCloseWithPendingDownloads() { 1111 void BrowserView::ConfirmBrowserCloseWithPendingDownloads() {
1112 DownloadInProgressDialogView::Show(browser_.get(), GetNativeWindow()); 1112 DownloadInProgressDialogView::Show(browser_.get(), GetNativeWindow());
1113 } 1113 }
1114 1114
1115 void BrowserView::ShowCreateWebAppShortcutsDialog( 1115 void BrowserView::ShowCreateWebAppShortcutsDialog(
1116 TabContentsWrapper* tab_contents) { 1116 TabContents* tab_contents) {
1117 browser::ShowCreateWebAppShortcutsDialog(GetNativeWindow(), tab_contents); 1117 browser::ShowCreateWebAppShortcutsDialog(GetNativeWindow(), tab_contents);
1118 } 1118 }
1119 1119
1120 void BrowserView::ShowCreateChromeAppShortcutsDialog( 1120 void BrowserView::ShowCreateChromeAppShortcutsDialog(
1121 Profile* profile, 1121 Profile* profile,
1122 const extensions::Extension* app) { 1122 const extensions::Extension* app) {
1123 browser::ShowCreateChromeAppShortcutsDialog(GetNativeWindow(), profile, app); 1123 browser::ShowCreateChromeAppShortcutsDialog(GetNativeWindow(), profile, app);
1124 } 1124 }
1125 1125
1126 void BrowserView::UserChangedTheme() { 1126 void BrowserView::UserChangedTheme() {
(...skipping 11 matching lines...) Expand all
1138 1138
1139 void BrowserView::ShowPageInfo(Profile* profile, 1139 void BrowserView::ShowPageInfo(Profile* profile,
1140 const GURL& url, 1140 const GURL& url,
1141 const SSLStatus& ssl, 1141 const SSLStatus& ssl,
1142 bool show_history) { 1142 bool show_history) {
1143 browser::ShowPageInfoBubble(GetLocationBarView()->location_icon_view(), 1143 browser::ShowPageInfoBubble(GetLocationBarView()->location_icon_view(),
1144 profile, url, ssl, show_history, browser_.get()); 1144 profile, url, ssl, show_history, browser_.get());
1145 } 1145 }
1146 1146
1147 void BrowserView::ShowWebsiteSettings(Profile* profile, 1147 void BrowserView::ShowWebsiteSettings(Profile* profile,
1148 TabContentsWrapper* tab_contents_wrapper, 1148 TabContents* tab_contents,
1149 const GURL& url, 1149 const GURL& url,
1150 const content::SSLStatus& ssl, 1150 const content::SSLStatus& ssl,
1151 bool show_history) { 1151 bool show_history) {
1152 WebsiteSettingsPopupView::ShowPopup( 1152 WebsiteSettingsPopupView::ShowPopup(
1153 GetLocationBarView()->location_icon_view(), profile, 1153 GetLocationBarView()->location_icon_view(), profile,
1154 tab_contents_wrapper, url, ssl); 1154 tab_contents, url, ssl);
1155 } 1155 }
1156 1156
1157 void BrowserView::ShowAppMenu() { 1157 void BrowserView::ShowAppMenu() {
1158 toolbar_->app_menu()->Activate(); 1158 toolbar_->app_menu()->Activate();
1159 } 1159 }
1160 1160
1161 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 1161 bool BrowserView::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
1162 bool* is_keyboard_shortcut) { 1162 bool* is_keyboard_shortcut) {
1163 *is_keyboard_shortcut = false; 1163 *is_keyboard_shortcut = false;
1164 1164
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 void BrowserView::Copy() { 1259 void BrowserView::Copy() {
1260 ui_controls::SendKeyPress(GetNativeWindow(), ui::VKEY_C, 1260 ui_controls::SendKeyPress(GetNativeWindow(), ui::VKEY_C,
1261 true, false, false, false); 1261 true, false, false, false);
1262 } 1262 }
1263 1263
1264 void BrowserView::Paste() { 1264 void BrowserView::Paste() {
1265 ui_controls::SendKeyPress(GetNativeWindow(), ui::VKEY_V, 1265 ui_controls::SendKeyPress(GetNativeWindow(), ui::VKEY_V,
1266 true, false, false, false); 1266 true, false, false, false);
1267 } 1267 }
1268 1268
1269 void BrowserView::ShowInstant(TabContentsWrapper* preview) { 1269 void BrowserView::ShowInstant(TabContents* preview) {
1270 if (!preview_container_) { 1270 if (!preview_container_) {
1271 preview_container_ = new views::WebView(browser_->profile()); 1271 preview_container_ = new views::WebView(browser_->profile());
1272 preview_container_->set_id(VIEW_ID_TAB_CONTAINER); 1272 preview_container_->set_id(VIEW_ID_TAB_CONTAINER);
1273 } 1273 }
1274 contents_->SetPreview(preview_container_, preview->web_contents()); 1274 contents_->SetPreview(preview_container_, preview->web_contents());
1275 preview_container_->SetWebContents(preview->web_contents()); 1275 preview_container_->SetWebContents(preview->web_contents());
1276 } 1276 }
1277 1277
1278 void BrowserView::HideInstant() { 1278 void BrowserView::HideInstant() {
1279 if (!preview_container_) 1279 if (!preview_container_)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 return contents_container_; 1323 return contents_container_;
1324 } 1324 }
1325 1325
1326 ToolbarView* BrowserView::GetToolbarView() const { 1326 ToolbarView* BrowserView::GetToolbarView() const {
1327 return toolbar_; 1327 return toolbar_;
1328 } 1328 }
1329 1329
1330 /////////////////////////////////////////////////////////////////////////////// 1330 ///////////////////////////////////////////////////////////////////////////////
1331 // BrowserView, TabStripModelObserver implementation: 1331 // BrowserView, TabStripModelObserver implementation:
1332 1332
1333 void BrowserView::TabDetachedAt(TabContentsWrapper* contents, int index) { 1333 void BrowserView::TabDetachedAt(TabContents* contents, int index) {
1334 // We use index here rather than comparing |contents| because by this time 1334 // We use index here rather than comparing |contents| because by this time
1335 // the model has already removed |contents| from its list, so 1335 // the model has already removed |contents| from its list, so
1336 // browser_->GetSelectedWebContents() will return NULL or something else. 1336 // browser_->GetActiveWebContents() will return NULL or something else.
1337 if (index == browser_->active_index()) { 1337 if (index == browser_->active_index()) {
1338 // We need to reset the current tab contents to NULL before it gets 1338 // We need to reset the current tab contents to NULL before it gets
1339 // freed. This is because the focus manager performs some operations 1339 // freed. This is because the focus manager performs some operations
1340 // on the selected WebContents when it is removed. 1340 // on the selected WebContents when it is removed.
1341 contents_container_->SetWebContents(NULL); 1341 contents_container_->SetWebContents(NULL);
1342 infobar_container_->ChangeTabContents(NULL); 1342 infobar_container_->ChangeTabContents(NULL);
1343 UpdateDevToolsForContents(NULL); 1343 UpdateDevToolsForContents(NULL);
1344 } 1344 }
1345 } 1345 }
1346 1346
1347 void BrowserView::TabDeactivated(TabContentsWrapper* contents) { 1347 void BrowserView::TabDeactivated(TabContents* contents) {
1348 // We do not store the focus when closing the tab to work-around bug 4633. 1348 // We do not store the focus when closing the tab to work-around bug 4633.
1349 // Some reports seem to show that the focus manager and/or focused view can 1349 // Some reports seem to show that the focus manager and/or focused view can
1350 // be garbage at that point, it is not clear why. 1350 // be garbage at that point, it is not clear why.
1351 if (!contents->in_destructor()) 1351 if (!contents->in_destructor())
1352 contents->web_contents()->GetView()->StoreFocus(); 1352 contents->web_contents()->GetView()->StoreFocus();
1353 } 1353 }
1354 1354
1355 void BrowserView::ActiveTabChanged(TabContentsWrapper* old_contents, 1355 void BrowserView::ActiveTabChanged(TabContents* old_contents,
1356 TabContentsWrapper* new_contents, 1356 TabContents* new_contents,
1357 int index, 1357 int index,
1358 bool user_gesture) { 1358 bool user_gesture) {
1359 ProcessTabSelected(new_contents); 1359 ProcessTabSelected(new_contents);
1360 } 1360 }
1361 1361
1362 void BrowserView::TabReplacedAt(TabStripModel* tab_strip_model, 1362 void BrowserView::TabReplacedAt(TabStripModel* tab_strip_model,
1363 TabContentsWrapper* old_contents, 1363 TabContents* old_contents,
1364 TabContentsWrapper* new_contents, 1364 TabContents* new_contents,
1365 int index) { 1365 int index) {
1366 if (index != browser_->tab_strip_model()->active_index()) 1366 if (index != browser_->tab_strip_model()->active_index())
1367 return; 1367 return;
1368 1368
1369 if (contents_->preview_web_contents() == new_contents->web_contents()) { 1369 if (contents_->preview_web_contents() == new_contents->web_contents()) {
1370 // If 'preview' is becoming active, swap the 'active' and 'preview' and 1370 // If 'preview' is becoming active, swap the 'active' and 'preview' and
1371 // delete what was the active. 1371 // delete what was the active.
1372 contents_->MakePreviewContentsActiveContents(); 1372 contents_->MakePreviewContentsActiveContents();
1373 views::WebView* old_container = contents_container_; 1373 views::WebView* old_container = contents_container_;
1374 contents_container_ = preview_container_; 1374 contents_container_ = preview_container_;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 // For Ash only, app host windows do not show an icon, crbug.com/119411. 1435 // For Ash only, app host windows do not show an icon, crbug.com/119411.
1436 // Child windows (e.g. extension panels, popups) do show an icon. 1436 // Child windows (e.g. extension panels, popups) do show an icon.
1437 if (browser_->is_app() && browser_->app_type() == Browser::APP_TYPE_HOST) 1437 if (browser_->is_app() && browser_->app_type() == Browser::APP_TYPE_HOST)
1438 return false; 1438 return false;
1439 #endif 1439 #endif
1440 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); 1440 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR);
1441 } 1441 }
1442 1442
1443 gfx::ImageSkia BrowserView::GetWindowAppIcon() { 1443 gfx::ImageSkia BrowserView::GetWindowAppIcon() {
1444 if (browser_->is_app()) { 1444 if (browser_->is_app()) {
1445 TabContentsWrapper* contents = browser_->GetSelectedTabContentsWrapper(); 1445 TabContents* contents = browser_->GetActiveTabContents();
1446 if (contents && contents->extension_tab_helper()->GetExtensionAppIcon()) 1446 if (contents && contents->extension_tab_helper()->GetExtensionAppIcon())
1447 return *contents->extension_tab_helper()->GetExtensionAppIcon(); 1447 return *contents->extension_tab_helper()->GetExtensionAppIcon();
1448 } 1448 }
1449 1449
1450 return GetWindowIcon(); 1450 return GetWindowIcon();
1451 } 1451 }
1452 1452
1453 gfx::ImageSkia BrowserView::GetWindowIcon() { 1453 gfx::ImageSkia BrowserView::GetWindowIcon() {
1454 if (browser_->is_app()) 1454 if (browser_->is_app())
1455 return browser_->GetCurrentPageIcon(); 1455 return browser_->GetCurrentPageIcon();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 launcher_item_controller_->BrowserActivationStateChanged(); 1580 launcher_item_controller_->BrowserActivationStateChanged();
1581 #endif 1581 #endif
1582 1582
1583 if (active) { 1583 if (active) {
1584 BrowserList::SetLastActive(browser_.get()); 1584 BrowserList::SetLastActive(browser_.get());
1585 browser_->OnWindowActivated(); 1585 browser_->OnWindowActivated();
1586 } 1586 }
1587 } 1587 }
1588 1588
1589 void BrowserView::OnWindowBeginUserBoundsChange() { 1589 void BrowserView::OnWindowBeginUserBoundsChange() {
1590 WebContents* web_contents = GetSelectedWebContents(); 1590 WebContents* web_contents = GetActiveWebContents();
1591 if (!web_contents) 1591 if (!web_contents)
1592 return; 1592 return;
1593 web_contents->GetRenderViewHost()->NotifyMoveOrResizeStarted(); 1593 web_contents->GetRenderViewHost()->NotifyMoveOrResizeStarted();
1594 } 1594 }
1595 1595
1596 void BrowserView::OnWidgetMove() { 1596 void BrowserView::OnWidgetMove() {
1597 if (!initialized_) { 1597 if (!initialized_) {
1598 // Creating the widget can trigger a move. Ignore it until we've initialized 1598 // Creating the widget can trigger a move. Ignore it until we've initialized
1599 // things. 1599 // things.
1600 return; 1600 return;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 last_animation_time_ = now; 1877 last_animation_time_ = now;
1878 if (browser_->is_type_tabbed()) { 1878 if (browser_->is_type_tabbed()) {
1879 // Loading animations are shown in the tab for tabbed windows. We check the 1879 // Loading animations are shown in the tab for tabbed windows. We check the
1880 // browser type instead of calling IsTabStripVisible() because the latter 1880 // browser type instead of calling IsTabStripVisible() because the latter
1881 // will return false for fullscreen windows, but we still need to update 1881 // will return false for fullscreen windows, but we still need to update
1882 // their animations (so that when they come out of fullscreen mode they'll 1882 // their animations (so that when they come out of fullscreen mode they'll
1883 // be correct). 1883 // be correct).
1884 tabstrip_->UpdateLoadingAnimations(); 1884 tabstrip_->UpdateLoadingAnimations();
1885 } else if (ShouldShowWindowIcon()) { 1885 } else if (ShouldShowWindowIcon()) {
1886 // ... or in the window icon area for popups and app windows. 1886 // ... or in the window icon area for popups and app windows.
1887 WebContents* web_contents = browser_->GetSelectedWebContents(); 1887 WebContents* web_contents = browser_->GetActiveWebContents();
1888 // GetSelectedWebContents can return NULL for example under Purify when 1888 // GetActiveWebContents can return NULL for example under Purify when
1889 // the animations are running slowly and this function is called on a timer 1889 // the animations are running slowly and this function is called on a timer
1890 // through LoadingAnimationCallback. 1890 // through LoadingAnimationCallback.
1891 frame_->UpdateThrobber(web_contents && web_contents->IsLoading()); 1891 frame_->UpdateThrobber(web_contents && web_contents->IsLoading());
1892 } 1892 }
1893 } 1893 }
1894 1894
1895 // BrowserView, private -------------------------------------------------------- 1895 // BrowserView, private --------------------------------------------------------
1896 1896
1897 BrowserViewLayout* BrowserView::GetBrowserViewLayout() const { 1897 BrowserViewLayout* BrowserView::GetBrowserViewLayout() const {
1898 return static_cast<BrowserViewLayout*>(GetLayoutManager()); 1898 return static_cast<BrowserViewLayout*>(GetLayoutManager());
1899 } 1899 }
1900 1900
1901 void BrowserView::LayoutStatusBubble() { 1901 void BrowserView::LayoutStatusBubble() {
1902 // In restored mode, the client area has a client edge between it and the 1902 // In restored mode, the client area has a client edge between it and the
1903 // frame. 1903 // frame.
1904 int overlap = StatusBubbleViews::kShadowThickness; 1904 int overlap = StatusBubbleViews::kShadowThickness;
1905 // The extra pixels defined by kClientEdgeThickness is only drawn in frame 1905 // The extra pixels defined by kClientEdgeThickness is only drawn in frame
1906 // content border on windows for non-aura build. 1906 // content border on windows for non-aura build.
1907 #if !defined(USE_ASH) 1907 #if !defined(USE_ASH)
1908 overlap += 1908 overlap +=
1909 IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness; 1909 IsMaximized() ? 0 : views::NonClientFrameView::kClientEdgeThickness;
1910 #endif 1910 #endif
1911 int height = status_bubble_->GetPreferredSize().height(); 1911 int height = status_bubble_->GetPreferredSize().height();
1912 int contents_height = status_bubble_->base_view()->bounds().height(); 1912 int contents_height = status_bubble_->base_view()->bounds().height();
1913 gfx::Point origin(-overlap, contents_height - height + overlap); 1913 gfx::Point origin(-overlap, contents_height - height + overlap);
1914 status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3, height); 1914 status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3, height);
1915 } 1915 }
1916 1916
1917 bool BrowserView::MaybeShowBookmarkBar(TabContentsWrapper* contents) { 1917 bool BrowserView::MaybeShowBookmarkBar(TabContents* contents) {
1918 views::View* new_bookmark_bar_view = NULL; 1918 views::View* new_bookmark_bar_view = NULL;
1919 if (browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR) && 1919 if (browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR) &&
1920 contents) { 1920 contents) {
1921 if (!bookmark_bar_view_.get()) { 1921 if (!bookmark_bar_view_.get()) {
1922 bookmark_bar_view_.reset(new BookmarkBarView(browser_.get())); 1922 bookmark_bar_view_.reset(new BookmarkBarView(browser_.get()));
1923 bookmark_bar_view_->set_owned_by_client(); 1923 bookmark_bar_view_->set_owned_by_client();
1924 bookmark_bar_view_->set_background( 1924 bookmark_bar_view_->set_background(
1925 new BookmarkExtensionBackground(this, bookmark_bar_view_.get(), 1925 new BookmarkExtensionBackground(this, bookmark_bar_view_.get(),
1926 browser_.get())); 1926 browser_.get()));
1927 bookmark_bar_view_->SetBookmarkBarState( 1927 bookmark_bar_view_->SetBookmarkBarState(
1928 browser_->bookmark_bar_state(), 1928 browser_->bookmark_bar_state(),
1929 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); 1929 BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
1930 } 1930 }
1931 bookmark_bar_view_->SetPageNavigator(contents->web_contents()); 1931 bookmark_bar_view_->SetPageNavigator(contents->web_contents());
1932 new_bookmark_bar_view = bookmark_bar_view_.get(); 1932 new_bookmark_bar_view = bookmark_bar_view_.get();
1933 } 1933 }
1934 return UpdateChildViewAndLayout(new_bookmark_bar_view, &active_bookmark_bar_); 1934 return UpdateChildViewAndLayout(new_bookmark_bar_view, &active_bookmark_bar_);
1935 } 1935 }
1936 1936
1937 bool BrowserView::MaybeShowInfoBar(TabContentsWrapper* contents) { 1937 bool BrowserView::MaybeShowInfoBar(TabContents* contents) {
1938 // TODO(beng): Remove this function once the interface between 1938 // TODO(beng): Remove this function once the interface between
1939 // InfoBarContainer, DownloadShelfView and WebContents and this 1939 // InfoBarContainer, DownloadShelfView and WebContents and this
1940 // view is sorted out. 1940 // view is sorted out.
1941 return true; 1941 return true;
1942 } 1942 }
1943 1943
1944 void BrowserView::UpdateDevToolsForContents(TabContentsWrapper* wrapper) { 1944 void BrowserView::UpdateDevToolsForContents(TabContents* tab_contents) {
1945 WebContents* devtools_contents = NULL; 1945 WebContents* devtools_contents = NULL;
1946 if (wrapper) { 1946 if (tab_contents) {
1947 TabContentsWrapper* devtools_contents_wrapper = 1947 TabContentsWrapper* devtools_tab_contents =
1948 DevToolsWindow::GetDevToolsContents(wrapper->web_contents()); 1948 DevToolsWindow::GetDevToolsContents(tab_contents->web_contents());
1949 if (devtools_contents_wrapper) 1949 if (devtools_tab_contents)
1950 devtools_contents = devtools_contents_wrapper->web_contents(); 1950 devtools_contents = devtools_tab_contents->web_contents();
1951 } 1951 }
1952 1952
1953 bool should_show = devtools_contents && !devtools_container_->visible(); 1953 bool should_show = devtools_contents && !devtools_container_->visible();
1954 bool should_hide = !devtools_contents && devtools_container_->visible(); 1954 bool should_hide = !devtools_contents && devtools_container_->visible();
1955 1955
1956 devtools_container_->SetWebContents(devtools_contents); 1956 devtools_container_->SetWebContents(devtools_contents);
1957 1957
1958 if (should_show) 1958 if (should_show)
1959 ShowDevToolsContainer(); 1959 ShowDevToolsContainer();
1960 else if (should_hide) 1960 else if (should_hide)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 contents_size - contents_split_->divider_offset()); 2011 contents_size - contents_split_->divider_offset());
2012 2012
2013 // Restore focus to the last focused view when hiding devtools window. 2013 // Restore focus to the last focused view when hiding devtools window.
2014 devtools_focus_tracker_->FocusLastFocusedExternalView(); 2014 devtools_focus_tracker_->FocusLastFocusedExternalView();
2015 2015
2016 devtools_container_->SetVisible(false); 2016 devtools_container_->SetVisible(false);
2017 contents_split_->InvalidateLayout(); 2017 contents_split_->InvalidateLayout();
2018 Layout(); 2018 Layout();
2019 } 2019 }
2020 2020
2021 void BrowserView::UpdateUIForContents(TabContentsWrapper* contents) { 2021 void BrowserView::UpdateUIForContents(TabContents* contents) {
2022 bool needs_layout = MaybeShowBookmarkBar(contents); 2022 bool needs_layout = MaybeShowBookmarkBar(contents);
2023 needs_layout |= MaybeShowInfoBar(contents); 2023 needs_layout |= MaybeShowInfoBar(contents);
2024 if (needs_layout) 2024 if (needs_layout)
2025 Layout(); 2025 Layout();
2026 } 2026 }
2027 2027
2028 bool BrowserView::UpdateChildViewAndLayout(views::View* new_view, 2028 bool BrowserView::UpdateChildViewAndLayout(views::View* new_view,
2029 views::View** old_view) { 2029 views::View** old_view) {
2030 DCHECK(old_view); 2030 DCHECK(old_view);
2031 if (*old_view == new_view) { 2031 if (*old_view == new_view) {
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 else if (key_code == ui::VKEY_K) 2304 else if (key_code == ui::VKEY_K)
2305 content::RecordAction(UserMetricsAction("Accel_FocusSearch_K")); 2305 content::RecordAction(UserMetricsAction("Accel_FocusSearch_K"));
2306 break; 2306 break;
2307 default: 2307 default:
2308 // Do nothing. 2308 // Do nothing.
2309 break; 2309 break;
2310 } 2310 }
2311 #endif 2311 #endif
2312 } 2312 }
2313 2313
2314 void BrowserView::ProcessTabSelected(TabContentsWrapper* new_contents) { 2314 void BrowserView::ProcessTabSelected(TabContents* new_contents) {
2315 // If |contents_container_| already has the correct WebContents, we can save 2315 // If |contents_container_| already has the correct WebContents, we can save
2316 // some work. This also prevents extra events from being reported by the 2316 // some work. This also prevents extra events from being reported by the
2317 // Visibility API under Windows, as ChangeWebContents will briefly hide 2317 // Visibility API under Windows, as ChangeWebContents will briefly hide
2318 // the WebContents window. 2318 // the WebContents window.
2319 DCHECK(new_contents); 2319 DCHECK(new_contents);
2320 bool change_tab_contents = 2320 bool change_tab_contents =
2321 contents_container_->web_contents() != new_contents->web_contents(); 2321 contents_container_->web_contents() != new_contents->web_contents();
2322 2322
2323 // Update various elements that are interested in knowing the current 2323 // Update various elements that are interested in knowing the current
2324 // WebContents. 2324 // WebContents.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2415 void BrowserView::ShowPasswordGenerationBubble( 2415 void BrowserView::ShowPasswordGenerationBubble(
2416 const gfx::Rect& rect, 2416 const gfx::Rect& rect,
2417 autofill::PasswordGenerator* password_generator, 2417 autofill::PasswordGenerator* password_generator,
2418 const webkit::forms::PasswordForm& form) { 2418 const webkit::forms::PasswordForm& form) {
2419 // Create a rect in the content bounds that the bubble will point to. 2419 // Create a rect in the content bounds that the bubble will point to.
2420 gfx::Point origin(rect.origin()); 2420 gfx::Point origin(rect.origin());
2421 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin); 2421 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin);
2422 gfx::Rect bounds(origin, rect.size()); 2422 gfx::Rect bounds(origin, rect.size());
2423 2423
2424 // Create the bubble. 2424 // Create the bubble.
2425 WebContents* web_contents = GetSelectedWebContents(); 2425 TabContents* tab_contents = GetActiveTabContents();
2426 TabContentsWrapper* wrapper = GetSelectedTabContentsWrapper(); 2426 if (!tab_contents)
2427 if (!web_contents || !wrapper)
2428 return; 2427 return;
2429 2428
2430 PasswordGenerationBubbleView* bubble = 2429 PasswordGenerationBubbleView* bubble =
2431 new PasswordGenerationBubbleView(bounds, 2430 new PasswordGenerationBubbleView(
2432 form, 2431 bounds,
2433 this, 2432 form,
2434 web_contents->GetRenderViewHost(), 2433 this,
2435 password_generator, 2434 tab_contents->web_contents()->GetRenderViewHost(),
2436 browser_.get(), 2435 password_generator,
2437 wrapper->password_manager()); 2436 browser_.get(),
2437 tab_contents->password_manager());
2438 2438
2439 views::BubbleDelegateView::CreateBubble(bubble); 2439 views::BubbleDelegateView::CreateBubble(bubble);
2440 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 2440 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
2441 bubble->Show(); 2441 bubble->Show();
2442 } 2442 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.h ('k') | chrome/browser/ui/views/frame/opaque_browser_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698