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

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

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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/sessions/tab_restore_service.h" 30 #include "chrome/browser/sessions/tab_restore_service.h"
31 #include "chrome/browser/sessions/tab_restore_service_factory.h" 31 #include "chrome/browser/sessions/tab_restore_service_factory.h"
32 #include "chrome/browser/speech/extension_api/tts_extension_api.h" 32 #include "chrome/browser/speech/extension_api/tts_extension_api.h"
33 #include "chrome/browser/themes/theme_service.h" 33 #include "chrome/browser/themes/theme_service.h"
34 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" 34 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
35 #include "chrome/browser/ui/browser.h" 35 #include "chrome/browser/ui/browser.h"
36 #include "chrome/browser/ui/browser_command_controller.h" 36 #include "chrome/browser/ui/browser_command_controller.h"
37 #include "chrome/browser/ui/browser_commands.h" 37 #include "chrome/browser/ui/browser_commands.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/browser_tabstrip.h"
40 #include "chrome/browser/ui/browser_window_state.h" 41 #include "chrome/browser/ui/browser_window_state.h"
41 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 42 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
42 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" 43 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h"
43 #include "chrome/browser/ui/omnibox/omnibox_view.h" 44 #include "chrome/browser/ui/omnibox/omnibox_view.h"
44 #include "chrome/browser/ui/search/search.h" 45 #include "chrome/browser/ui/search/search.h"
45 #include "chrome/browser/ui/search/search_model.h" 46 #include "chrome/browser/ui/search/search_model.h"
46 #include "chrome/browser/ui/tab_contents/tab_contents.h" 47 #include "chrome/browser/ui/tab_contents/tab_contents.h"
47 #include "chrome/browser/ui/tabs/tab_menu_model.h" 48 #include "chrome/browser/ui/tabs/tab_menu_model.h"
48 #include "chrome/browser/ui/tabs/tab_strip_model.h" 49 #include "chrome/browser/ui/tabs/tab_strip_model.h"
49 #include "chrome/browser/ui/view_ids.h" 50 #include "chrome/browser/ui/view_ids.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas, 208 void BookmarkExtensionBackground::Paint(gfx::Canvas* canvas,
208 views::View* view) const { 209 views::View* view) const {
209 ui::ThemeProvider* tp = host_view_->GetThemeProvider(); 210 ui::ThemeProvider* tp = host_view_->GetThemeProvider();
210 int toolbar_overlap = host_view_->GetToolbarOverlap(); 211 int toolbar_overlap = host_view_->GetToolbarOverlap();
211 // The client edge is drawn below the toolbar bounds. 212 // The client edge is drawn below the toolbar bounds.
212 if (toolbar_overlap) 213 if (toolbar_overlap)
213 toolbar_overlap += views::NonClientFrameView::kClientEdgeThickness; 214 toolbar_overlap += views::NonClientFrameView::kClientEdgeThickness;
214 if (host_view_->IsDetached()) { 215 if (host_view_->IsDetached()) {
215 // Draw the background to match the new tab page. 216 // Draw the background to match the new tab page.
216 int height = 0; 217 int height = 0;
217 WebContents* contents = browser_->GetActiveWebContents(); 218 WebContents* contents = chrome::GetActiveWebContents(browser_);
218 if (contents && contents->GetView()) 219 if (contents && contents->GetView())
219 height = contents->GetView()->GetContainerSize().height(); 220 height = contents->GetView()->GetContainerSize().height();
220 NtpBackgroundUtil::PaintBackgroundDetachedMode( 221 NtpBackgroundUtil::PaintBackgroundDetachedMode(
221 host_view_->GetThemeProvider(), canvas, 222 host_view_->GetThemeProvider(), canvas,
222 gfx::Rect(0, toolbar_overlap, host_view_->width(), 223 gfx::Rect(0, toolbar_overlap, host_view_->width(),
223 host_view_->height() - toolbar_overlap), height); 224 host_view_->height() - toolbar_overlap), height);
224 225
225 // As 'hidden' according to the animation is the full in-tab state, 226 // As 'hidden' according to the animation is the full in-tab state,
226 // we invert the value - when current_state is at '0', we expect the 227 // we invert the value - when current_state is at '0', we expect the
227 // bar to be docked. 228 // bar to be docked.
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 active_browser->window()->FlashFrame(true); 522 active_browser->window()->FlashFrame(true);
522 active_browser->window()->Activate(); 523 active_browser->window()->Activate();
523 } 524 }
524 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); 525 AppModalDialogQueue::GetInstance()->ActivateModalDialog();
525 return true; 526 return true;
526 } 527 }
527 return false; 528 return false;
528 } 529 }
529 530
530 WebContents* BrowserView::GetActiveWebContents() const { 531 WebContents* BrowserView::GetActiveWebContents() const {
531 return browser_->GetActiveWebContents(); 532 return chrome::GetActiveWebContents(browser_.get());
532 } 533 }
533 534
534 TabContents* BrowserView::GetActiveTabContents() const { 535 TabContents* BrowserView::GetActiveTabContents() const {
535 return browser_->GetActiveTabContents(); 536 return chrome::GetActiveTabContents(browser_.get());
536 } 537 }
537 538
538 gfx::ImageSkia BrowserView::GetOTRAvatarIcon() const { 539 gfx::ImageSkia BrowserView::GetOTRAvatarIcon() const {
539 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 540 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
540 const gfx::ImageSkia* otr_avatar = 541 const gfx::ImageSkia* otr_avatar =
541 rb.GetNativeImageNamed(GetOTRIconResourceID()).ToImageSkia(); 542 rb.GetNativeImageNamed(GetOTRIconResourceID()).ToImageSkia();
542 return *otr_avatar; 543 return *otr_avatar;
543 } 544 }
544 545
545 bool BrowserView::IsPositionInWindowCaption(const gfx::Point& point) { 546 bool BrowserView::IsPositionInWindowCaption(const gfx::Point& point) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 if (ShouldShowWindowIcon() && !loading_animation_timer_.IsRunning()) 645 if (ShouldShowWindowIcon() && !loading_animation_timer_.IsRunning())
645 frame_->UpdateWindowIcon(); 646 frame_->UpdateWindowIcon();
646 } 647 }
647 648
648 void BrowserView::BookmarkBarStateChanged( 649 void BrowserView::BookmarkBarStateChanged(
649 BookmarkBar::AnimateChangeType change_type) { 650 BookmarkBar::AnimateChangeType change_type) {
650 if (bookmark_bar_view_.get()) { 651 if (bookmark_bar_view_.get()) {
651 bookmark_bar_view_->SetBookmarkBarState( 652 bookmark_bar_view_->SetBookmarkBarState(
652 browser_->bookmark_bar_state(), change_type); 653 browser_->bookmark_bar_state(), change_type);
653 } 654 }
654 if (MaybeShowBookmarkBar(browser_->GetActiveTabContents())) 655 if (MaybeShowBookmarkBar(chrome::GetActiveTabContents(browser_.get())))
655 Layout(); 656 Layout();
656 } 657 }
657 658
658 void BrowserView::UpdateDevTools() { 659 void BrowserView::UpdateDevTools() {
659 UpdateDevToolsForContents(GetActiveTabContents()); 660 UpdateDevToolsForContents(GetActiveTabContents());
660 Layout(); 661 Layout();
661 } 662 }
662 663
663 664
664 void BrowserView::SetDevToolsDockSide(DevToolsDockSide side) { 665 void BrowserView::SetDevToolsDockSide(DevToolsDockSide side) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 // early-return in this case because we need to layout again so the infobar 824 // early-return in this case because we need to layout again so the infobar
824 // container's bounds are set correctly. 825 // container's bounds are set correctly.
825 static CallState call_state = NORMAL; 826 static CallState call_state = NORMAL;
826 827
827 // A reentrant call can (and should) use the fast resize path unless both it 828 // A reentrant call can (and should) use the fast resize path unless both it
828 // and the normal call are both non-animating. 829 // and the normal call are both non-animating.
829 bool use_fast_resize = 830 bool use_fast_resize =
830 is_animating || (call_state == REENTRANT_FORCE_FAST_RESIZE); 831 is_animating || (call_state == REENTRANT_FORCE_FAST_RESIZE);
831 if (use_fast_resize) 832 if (use_fast_resize)
832 contents_container_->SetFastResize(true); 833 contents_container_->SetFastResize(true);
833 UpdateUIForContents(browser_->GetActiveTabContents()); 834 UpdateUIForContents(chrome::GetActiveTabContents(browser_.get()));
834 if (use_fast_resize) 835 if (use_fast_resize)
835 contents_container_->SetFastResize(false); 836 contents_container_->SetFastResize(false);
836 837
837 // Inform the InfoBarContainer that the distance to the location icon may have 838 // Inform the InfoBarContainer that the distance to the location icon may have
838 // changed. We have to do this after the block above so that the toolbars are 839 // changed. We have to do this after the block above so that the toolbars are
839 // laid out correctly for calculating the maximum arrow height below. 840 // laid out correctly for calculating the maximum arrow height below.
840 { 841 {
841 const LocationIconView* location_icon_view = 842 const LocationIconView* location_icon_view =
842 toolbar_->location_bar()->location_icon_view(); 843 toolbar_->location_bar()->location_icon_view();
843 // The +1 in the next line creates a 1-px gap between icon and arrow tip. 844 // The +1 in the next line creates a 1-px gap between icon and arrow tip.
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 // For Ash only, app host windows do not show an icon, crbug.com/119411. 1520 // For Ash only, app host windows do not show an icon, crbug.com/119411.
1520 // Child windows (e.g. extension panels, popups) do show an icon. 1521 // Child windows (e.g. extension panels, popups) do show an icon.
1521 if (browser_->is_app() && browser_->app_type() == Browser::APP_TYPE_HOST) 1522 if (browser_->is_app() && browser_->app_type() == Browser::APP_TYPE_HOST)
1522 return false; 1523 return false;
1523 #endif 1524 #endif
1524 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); 1525 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR);
1525 } 1526 }
1526 1527
1527 gfx::ImageSkia BrowserView::GetWindowAppIcon() { 1528 gfx::ImageSkia BrowserView::GetWindowAppIcon() {
1528 if (browser_->is_app()) { 1529 if (browser_->is_app()) {
1529 TabContents* contents = browser_->GetActiveTabContents(); 1530 TabContents* contents = chrome::GetActiveTabContents(browser_.get());
1530 if (contents && contents->extension_tab_helper()->GetExtensionAppIcon()) 1531 if (contents && contents->extension_tab_helper()->GetExtensionAppIcon())
1531 return *contents->extension_tab_helper()->GetExtensionAppIcon(); 1532 return *contents->extension_tab_helper()->GetExtensionAppIcon();
1532 } 1533 }
1533 1534
1534 return GetWindowIcon(); 1535 return GetWindowIcon();
1535 } 1536 }
1536 1537
1537 gfx::ImageSkia BrowserView::GetWindowIcon() { 1538 gfx::ImageSkia BrowserView::GetWindowIcon() {
1538 if (browser_->is_app()) 1539 if (browser_->is_app())
1539 return browser_->GetCurrentPageIcon(); 1540 return browser_->GetCurrentPageIcon();
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 last_animation_time_ = now; 1997 last_animation_time_ = now;
1997 if (browser_->is_type_tabbed()) { 1998 if (browser_->is_type_tabbed()) {
1998 // Loading animations are shown in the tab for tabbed windows. We check the 1999 // Loading animations are shown in the tab for tabbed windows. We check the
1999 // browser type instead of calling IsTabStripVisible() because the latter 2000 // browser type instead of calling IsTabStripVisible() because the latter
2000 // will return false for fullscreen windows, but we still need to update 2001 // will return false for fullscreen windows, but we still need to update
2001 // their animations (so that when they come out of fullscreen mode they'll 2002 // their animations (so that when they come out of fullscreen mode they'll
2002 // be correct). 2003 // be correct).
2003 tabstrip_->UpdateLoadingAnimations(); 2004 tabstrip_->UpdateLoadingAnimations();
2004 } else if (ShouldShowWindowIcon()) { 2005 } else if (ShouldShowWindowIcon()) {
2005 // ... or in the window icon area for popups and app windows. 2006 // ... or in the window icon area for popups and app windows.
2006 WebContents* web_contents = browser_->GetActiveWebContents(); 2007 WebContents* web_contents = chrome::GetActiveWebContents(browser_.get());
2007 // GetActiveWebContents can return NULL for example under Purify when 2008 // GetActiveWebContents can return NULL for example under Purify when
2008 // the animations are running slowly and this function is called on a timer 2009 // the animations are running slowly and this function is called on a timer
2009 // through LoadingAnimationCallback. 2010 // through LoadingAnimationCallback.
2010 frame_->UpdateThrobber(web_contents && web_contents->IsLoading()); 2011 frame_->UpdateThrobber(web_contents && web_contents->IsLoading());
2011 } 2012 }
2012 } 2013 }
2013 2014
2014 // BrowserView, private -------------------------------------------------------- 2015 // BrowserView, private --------------------------------------------------------
2015 2016
2016 BrowserViewLayout* BrowserView::GetBrowserViewLayout() const { 2017 BrowserViewLayout* BrowserView::GetBrowserViewLayout() const {
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
2567 bubble->Show(); 2568 bubble->Show();
2568 } 2569 }
2569 2570
2570 void BrowserView::RestackLocationBarContainer() { 2571 void BrowserView::RestackLocationBarContainer() {
2571 #if defined(USE_AURA) 2572 #if defined(USE_AURA)
2572 if (search_view_controller_.get()) 2573 if (search_view_controller_.get())
2573 search_view_controller_->StackAtTop(); 2574 search_view_controller_->StackAtTop();
2574 #endif 2575 #endif
2575 toolbar_->location_bar_container()->StackAtTop(); 2576 toolbar_->location_bar_container()->StackAtTop();
2576 } 2577 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_frame_win.cc ('k') | chrome/browser/ui/views/location_bar/location_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698