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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_ 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_ 7 #pragma once 8 9 #include "base/compiler_specific.h" 10 #include "base/logging.h" 11 #include "build/build_config.h" 12 #include "chrome/browser/ui/views/frame/native_browser_frame_delegate.h" 13 14 class AeroGlassNonClientView; 15 class BrowserNonClientFrameView; 16 class BrowserRootView; 17 class BrowserView; 18 class NativeBrowserFrame; 19 class NonClientFrameView; 20 class Profile; 21 22 namespace gfx { 23 class Font; 24 class Rect; 25 } 26 27 namespace ui { 28 class ThemeProvider; 29 } 30 31 namespace views { 32 class View; 33 class Window; 34 } 35 36 // This is a virtual interface that allows system specific browser frames. 37 class BrowserFrame : public NativeBrowserFrameDelegate { 38 public: 39 virtual ~BrowserFrame(); 40 41 // Creates the appropriate BrowserFrame for this platform. The returned 42 // object is owned by the caller. 43 static BrowserFrame* Create(BrowserView* browser_view, Profile* profile); 44 45 static const gfx::Font& GetTitleFont(); 46 47 // Returns the Window associated with this frame. Guaranteed non-NULL after 48 // construction. 49 views::Window* GetWindow(); 50 51 // Determine the distance of the left edge of the minimize button from the 52 // left edge of the window. Used in our Non-Client View's Layout. 53 int GetMinimizeButtonOffset() const; 54 55 // Retrieves the bounds, in non-client view coordinates for the specified 56 // TabStrip view. 57 gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const; 58 59 // Returns the y coordinate within the window at which the horizontal TabStrip 60 // begins (or would begin). If |restored| is true, this is calculated as if 61 // we were in restored mode regardless of the current mode. 62 int GetHorizontalTabStripVerticalOffset(bool restored) const; 63 64 // Tells the frame to update the throbber. 65 void UpdateThrobber(bool running); 66 67 // Returns the theme provider for this frame. 68 ui::ThemeProvider* GetThemeProviderForFrame() const; 69 70 // Returns true if the window should use the native frame view. This is true 71 // if there are no themes applied on Vista, or if there are themes applied and 72 // this browser window is an app or popup. 73 bool AlwaysUseNativeFrame() const; 74 75 // Returns the NonClientFrameView of this frame. 76 views::View* GetFrameView() const; 77 78 // Notifies the frame that the tab strip display mode changed so it can update 79 // its frame treatment if necessary. 80 void TabStripDisplayModeChanged(); 81 82 protected: 83 // Overridden from NativeBrowserFrameDelegate: 84 virtual views::RootView* DelegateCreateRootView() OVERRIDE; 85 virtual views::NonClientFrameView* DelegateCreateFrameViewForWindow() 86 OVERRIDE; 87 88 // TODO(beng): Temporarily provided as a way to associate the subclass' 89 // implementation of NativeBrowserFrame with this. set_native_browser_frame(NativeBrowserFrame * native_browser_frame)90 void set_native_browser_frame(NativeBrowserFrame* native_browser_frame) { 91 native_browser_frame_ = native_browser_frame; 92 } 93 94 explicit BrowserFrame(BrowserView* browser_view); 95 96 private: 97 NativeBrowserFrame* native_browser_frame_; 98 99 // A weak reference to the root view associated with the window. We save a 100 // copy as a BrowserRootView to avoid evil casting later, when we need to call 101 // functions that only exist on BrowserRootView (versus RootView). 102 BrowserRootView* root_view_; 103 104 // A pointer to our NonClientFrameView as a BrowserNonClientFrameView. 105 BrowserNonClientFrameView* browser_frame_view_; 106 107 // The BrowserView is our ClientView. This is a pointer to it. 108 BrowserView* browser_view_; 109 110 DISALLOW_COPY_AND_ASSIGN(BrowserFrame); 111 }; 112 113 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_ 114