| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ |
| 6 #define CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 public views::BaseButton::ButtonListener { | 45 public views::BaseButton::ButtonListener { |
| 46 public: | 46 public: |
| 47 explicit BrowserToolbarView(Browser* browser); | 47 explicit BrowserToolbarView(Browser* browser); |
| 48 virtual ~BrowserToolbarView(); | 48 virtual ~BrowserToolbarView(); |
| 49 | 49 |
| 50 // Create the contents of the Browser Toolbar | 50 // Create the contents of the Browser Toolbar |
| 51 void Init(Profile* profile); | 51 void Init(Profile* profile); |
| 52 | 52 |
| 53 // views::View | 53 // views::View |
| 54 virtual void Layout(); | 54 virtual void Layout(); |
| 55 virtual void Paint(ChromeCanvas* canvas); |
| 55 virtual void DidGainFocus(); | 56 virtual void DidGainFocus(); |
| 56 virtual void WillLoseFocus(); | 57 virtual void WillLoseFocus(); |
| 57 virtual bool OnKeyPressed(const views::KeyEvent& e); | 58 virtual bool OnKeyPressed(const views::KeyEvent& e); |
| 58 virtual bool OnKeyReleased(const views::KeyEvent& e); | 59 virtual bool OnKeyReleased(const views::KeyEvent& e); |
| 59 virtual gfx::Size GetPreferredSize(); | 60 virtual gfx::Size GetPreferredSize(); |
| 60 | 61 |
| 61 // Overridden from EncodingMenuControllerDelegate: | 62 // Overridden from EncodingMenuControllerDelegate: |
| 62 virtual bool IsItemChecked(int id) const; | 63 virtual bool IsItemChecked(int id) const; |
| 63 | 64 |
| 64 // Overridden from Menu::BaseControllerDelegate: | 65 // Overridden from Menu::BaseControllerDelegate: |
| 65 virtual bool GetAcceleratorInfo(int id, views::Accelerator* accel); | 66 virtual bool GetAcceleratorInfo(int id, views::Accelerator* accel); |
| 66 | 67 |
| 67 // views::MenuDelegate | 68 // views::MenuDelegate |
| 68 virtual void RunMenu(views::View* source, const CPoint& pt, HWND hwnd); | 69 virtual void RunMenu(views::View* source, const CPoint& pt, HWND hwnd); |
| 69 | 70 |
| 70 // GetProfilesHelper::Delegate method. | 71 // GetProfilesHelper::Delegate method. |
| 71 virtual void OnGetProfilesDone(const std::vector<std::wstring>& profiles); | 72 virtual void OnGetProfilesDone(const std::vector<std::wstring>& profiles); |
| 72 | 73 |
| 73 // Sets the profile which is active on the currently-active tab. | 74 // Sets the profile which is active on the currently-active tab. |
| 74 void SetProfile(Profile* profile); | 75 void SetProfile(Profile* profile); |
| 75 Profile* profile() { return profile_; } | 76 Profile* profile() { return profile_; } |
| 76 | 77 |
| 77 ToolbarStarToggle* star_button() { return star_; } | 78 ToolbarStarToggle* star_button() { return star_; } |
| 78 | 79 |
| 79 GoButton* GetGoButton() { return go_; } | 80 GoButton* GetGoButton() { return go_; } |
| 80 | 81 |
| 81 LocationBarView* GetLocationBarView() const { return location_bar_; } | 82 LocationBarView* GetLocationBarView() const { return location_bar_; } |
| 82 | 83 |
| 83 bool IsDisplayModeNormal() const { | |
| 84 return display_mode_ == DISPLAYMODE_NORMAL; | |
| 85 } | |
| 86 | |
| 87 // Updates the toolbar (and transitively the location bar) with the states of | 84 // Updates the toolbar (and transitively the location bar) with the states of |
| 88 // the specified |tab|. If |should_restore_state| is true, we're switching | 85 // the specified |tab|. If |should_restore_state| is true, we're switching |
| 89 // (back?) to this tab and should restore any previous location bar state | 86 // (back?) to this tab and should restore any previous location bar state |
| 90 // (such as user editing) as well. | 87 // (such as user editing) as well. |
| 91 void Update(TabContents* tab, bool should_restore_state); | 88 void Update(TabContents* tab, bool should_restore_state); |
| 92 | 89 |
| 93 void OnInputInProgress(bool in_progress); | 90 void OnInputInProgress(bool in_progress); |
| 94 | 91 |
| 95 // Returns the MSAA role of the current view. The role is what assistive | 92 // Returns the MSAA role of the current view. The role is what assistive |
| 96 // technologies (ATs) use to determine what behavior to expect from a given | 93 // technologies (ATs) use to determine what behavior to expect from a given |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // Overridden from views::BaseButton::ButtonListener: | 125 // Overridden from views::BaseButton::ButtonListener: |
| 129 virtual void ButtonPressed(views::BaseButton* sender); | 126 virtual void ButtonPressed(views::BaseButton* sender); |
| 130 | 127 |
| 131 private: | 128 private: |
| 132 // Types of display mode this toolbar can have. | 129 // Types of display mode this toolbar can have. |
| 133 enum DisplayMode { | 130 enum DisplayMode { |
| 134 DISPLAYMODE_NORMAL, | 131 DISPLAYMODE_NORMAL, |
| 135 DISPLAYMODE_LOCATION | 132 DISPLAYMODE_LOCATION |
| 136 }; | 133 }; |
| 137 | 134 |
| 135 // Returns the number of pixels above the location bar in non-normal display. |
| 136 static int PopupTopSpacing(); |
| 137 |
| 138 // NotificationObserver | 138 // NotificationObserver |
| 139 virtual void Observe(NotificationType type, | 139 virtual void Observe(NotificationType type, |
| 140 const NotificationSource& source, | 140 const NotificationSource& source, |
| 141 const NotificationDetails& details); | 141 const NotificationDetails& details); |
| 142 | 142 |
| 143 // DragController methods for the star button. These allow the drag if the | 143 // DragController methods for the star button. These allow the drag if the |
| 144 // user hasn't edited the text, the url is valid and should be displayed. | 144 // user hasn't edited the text, the url is valid and should be displayed. |
| 145 virtual void WriteDragData(View* sender, | 145 virtual void WriteDragData(View* sender, |
| 146 int press_x, | 146 int press_x, |
| 147 int press_y, | 147 int press_y, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 161 void RunPageMenu(const CPoint& pt, HWND hwnd); | 161 void RunPageMenu(const CPoint& pt, HWND hwnd); |
| 162 | 162 |
| 163 // Show the app menu. | 163 // Show the app menu. |
| 164 void RunAppMenu(const CPoint& pt, HWND hwnd); | 164 void RunAppMenu(const CPoint& pt, HWND hwnd); |
| 165 | 165 |
| 166 // Overridden from View, to pass keyboard triggering of the right-click | 166 // Overridden from View, to pass keyboard triggering of the right-click |
| 167 // context menu on to the toolbar child view that currently has the | 167 // context menu on to the toolbar child view that currently has the |
| 168 // accessibility focus. | 168 // accessibility focus. |
| 169 virtual void ShowContextMenu(int x, int y, bool is_mouse_gesture); | 169 virtual void ShowContextMenu(int x, int y, bool is_mouse_gesture); |
| 170 | 170 |
| 171 bool IsDisplayModeNormal() const { |
| 172 return display_mode_ == DISPLAYMODE_NORMAL; |
| 173 } |
| 174 |
| 171 scoped_ptr<BackForwardMenuModelWin> back_menu_model_; | 175 scoped_ptr<BackForwardMenuModelWin> back_menu_model_; |
| 172 scoped_ptr<BackForwardMenuModelWin> forward_menu_model_; | 176 scoped_ptr<BackForwardMenuModelWin> forward_menu_model_; |
| 173 | 177 |
| 174 // The model that contains the security level, text, icon to display... | 178 // The model that contains the security level, text, icon to display... |
| 175 ToolbarModel* model_; | 179 ToolbarModel* model_; |
| 176 | 180 |
| 177 // Storage of strings needed for accessibility. | 181 // Storage of strings needed for accessibility. |
| 178 std::wstring accessible_name_; | 182 std::wstring accessible_name_; |
| 179 // Child view currently having MSAA focus (location bar excluded from arrow | 183 // Child view currently having MSAA focus (location bar excluded from arrow |
| 180 // navigation). | 184 // navigation). |
| (...skipping 22 matching lines...) Expand all Loading... |
| 203 scoped_refptr<GetProfilesHelper> profiles_helper_; | 207 scoped_refptr<GetProfilesHelper> profiles_helper_; |
| 204 | 208 |
| 205 // Controls whether or not a home button should be shown on the toolbar. | 209 // Controls whether or not a home button should be shown on the toolbar. |
| 206 BooleanPrefMember show_home_button_; | 210 BooleanPrefMember show_home_button_; |
| 207 | 211 |
| 208 // The display mode used when laying out the toolbar. | 212 // The display mode used when laying out the toolbar. |
| 209 DisplayMode display_mode_; | 213 DisplayMode display_mode_; |
| 210 }; | 214 }; |
| 211 | 215 |
| 212 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ | 216 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ |
| OLD | NEW |