| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 protected: | 44 protected: |
| 45 static const int kButtonButtonSpacing; | 45 static const int kButtonButtonSpacing; |
| 46 static const int kEndOfLabelSpacing; | 46 static const int kEndOfLabelSpacing; |
| 47 | 47 |
| 48 virtual ~InfoBarView(); | 48 virtual ~InfoBarView(); |
| 49 | 49 |
| 50 // Creates a label with the appropriate font and color for an infobar. | 50 // Creates a label with the appropriate font and color for an infobar. |
| 51 static views::Label* CreateLabel(const string16& text); | 51 static views::Label* CreateLabel(const string16& text); |
| 52 | 52 |
| 53 // Creates a link with the appropriate font and color for an infobar. | 53 // Creates a link with the appropriate font and color for an infobar. |
| 54 // NOTE: Subclasses must ignore link clicks if we're unowned. |
| 54 static views::Link* CreateLink(const string16& text, | 55 static views::Link* CreateLink(const string16& text, |
| 55 views::LinkListener* listener, | 56 views::LinkListener* listener, |
| 56 const SkColor& background_color); | 57 const SkColor& background_color); |
| 57 | 58 |
| 58 // Creates a menu button with an infobar-specific appearance. | 59 // Creates a menu button with an infobar-specific appearance. |
| 60 // NOTE: Subclasses must ignore button presses if we're unowned. |
| 59 static views::MenuButton* CreateMenuButton( | 61 static views::MenuButton* CreateMenuButton( |
| 60 const string16& text, | 62 const string16& text, |
| 61 views::ViewMenuDelegate* menu_delegate); | 63 views::ViewMenuDelegate* menu_delegate); |
| 62 | 64 |
| 63 // Creates a text button with an infobar-specific appearance. | 65 // Creates a text button with an infobar-specific appearance. |
| 66 // NOTE: Subclasses must ignore button presses if we're unowned. |
| 64 static views::TextButton* CreateTextButton(views::ButtonListener* listener, | 67 static views::TextButton* CreateTextButton(views::ButtonListener* listener, |
| 65 const string16& text, | 68 const string16& text, |
| 66 bool needs_elevation); | 69 bool needs_elevation); |
| 67 | 70 |
| 68 // views::View: | 71 // views::View: |
| 69 virtual void Layout() OVERRIDE; | 72 virtual void Layout() OVERRIDE; |
| 70 virtual void ViewHierarchyChanged(bool is_add, | 73 virtual void ViewHierarchyChanged(bool is_add, |
| 71 View* parent, | 74 View* parent, |
| 72 View* child) OVERRIDE; | 75 View* child) OVERRIDE; |
| 73 | 76 |
| 74 // views::ButtonListener: | 77 // views::ButtonListener: |
| 78 // NOTE: This must not be called if we're unowned. (Subclasses should ignore |
| 79 // calls to ButtonPressed() in this case.) |
| 75 virtual void ButtonPressed(views::Button* sender, | 80 virtual void ButtonPressed(views::Button* sender, |
| 76 const views::Event& event) OVERRIDE; | 81 const views::Event& event) OVERRIDE; |
| 77 | 82 |
| 78 // Returns the minimum width the content (that is, everything between the icon | 83 // Returns the minimum width the content (that is, everything between the icon |
| 79 // and the close button) can be shrunk to. This is used to prevent the close | 84 // and the close button) can be shrunk to. This is used to prevent the close |
| 80 // button from overlapping views that cannot be shrunk any further. | 85 // button from overlapping views that cannot be shrunk any further. |
| 81 virtual int ContentMinimumWidth() const; | 86 virtual int ContentMinimumWidth() const; |
| 82 | 87 |
| 83 // These return x coordinates delimiting the usable area for subclasses to lay | 88 // These return x coordinates delimiting the usable area for subclasses to lay |
| 84 // out their controls. | 89 // out their controls. |
| 85 int StartX() const; | 90 int StartX() const; |
| 86 int EndX() const; | 91 int EndX() const; |
| 87 | 92 |
| 88 // Convenience getter. | 93 // Convenience getter. |
| 89 const InfoBarContainer::Delegate* container_delegate() const; | 94 const InfoBarContainer::Delegate* container_delegate() const; |
| 90 | 95 |
| 91 // Show a menu at the specified position. By invoking this InfobarView ensures | 96 // Shows a menu at the specified position. |
| 92 // the menu is destroyed at the appropriate time. | 97 // NOTE: This must not be called if we're unowned. (Subclasses should ignore |
| 98 // calls to RunMenu() in this case.) |
| 93 void RunMenuAt(ui::MenuModel* menu_model, | 99 void RunMenuAt(ui::MenuModel* menu_model, |
| 94 views::MenuButton* button, | 100 views::MenuButton* button, |
| 95 views::MenuItemView::AnchorPosition anchor); | 101 views::MenuItemView::AnchorPosition anchor); |
| 96 | 102 |
| 97 private: | 103 private: |
| 98 static const int kHorizontalPadding; | 104 static const int kHorizontalPadding; |
| 99 | 105 |
| 100 // InfoBar: | 106 // InfoBar: |
| 101 virtual void PlatformSpecificShow(bool animate) OVERRIDE; | 107 virtual void PlatformSpecificShow(bool animate) OVERRIDE; |
| 102 virtual void PlatformSpecificHide(bool animate) OVERRIDE; | 108 virtual void PlatformSpecificHide(bool animate) OVERRIDE; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 126 SkPath fill_path_; | 132 SkPath fill_path_; |
| 127 SkPath stroke_path_; | 133 SkPath stroke_path_; |
| 128 | 134 |
| 129 // Used to run the menu. | 135 // Used to run the menu. |
| 130 scoped_ptr<views::MenuRunner> menu_runner_; | 136 scoped_ptr<views::MenuRunner> menu_runner_; |
| 131 | 137 |
| 132 DISALLOW_COPY_AND_ASSIGN(InfoBarView); | 138 DISALLOW_COPY_AND_ASSIGN(InfoBarView); |
| 133 }; | 139 }; |
| 134 | 140 |
| 135 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ | 141 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ |
| OLD | NEW |