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

Side by Side Diff: chrome/browser/views/toolbar_star_toggle.h

Issue 543215: Added Star button to compact navigation mode.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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
« no previous file with comments | « chrome/browser/views/star_toggle.cc ('k') | chrome/browser/views/toolbar_star_toggle.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_STAR_TOGGLE_H_ 5 #ifndef CHROME_BROWSER_VIEWS_TOOLBAR_STAR_TOGGLE_H_
6 #define CHROME_BROWSER_VIEWS_TOOLBAR_STAR_TOGGLE_H_ 6 #define CHROME_BROWSER_VIEWS_TOOLBAR_STAR_TOGGLE_H_
7 7
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "chrome/browser/views/info_bubble.h" 9 #include "chrome/browser/views/info_bubble.h"
10 #include "views/controls/button/image_button.h" 10 #include "views/controls/button/image_button.h"
11 11
12 class BubblePositioner;
12 class GURL; 13 class GURL;
13 class ToolbarView; 14 class Profile;
15
16 namespace views {
17 class ButtonListener;
18 class View;
19 } // namespace views
14 20
15 // ToolbarStarToggle is used for the star button on the toolbar, allowing the 21 // ToolbarStarToggle is used for the star button on the toolbar, allowing the
16 // user to star the current page. ToolbarStarToggle manages showing the 22 // user to star the current page. ToolbarStarToggle manages showing the
17 // InfoBubble and rendering the appropriate state while the bubble is visible. 23 // InfoBubble and rendering the appropriate state while the bubble is visible.
18
19 class ToolbarStarToggle : public views::ToggleImageButton, 24 class ToolbarStarToggle : public views::ToggleImageButton,
20 public InfoBubbleDelegate { 25 public InfoBubbleDelegate {
21 public: 26 public:
22 ToolbarStarToggle(views::ButtonListener* listener, ToolbarView* host); 27 explicit ToolbarStarToggle(views::ButtonListener* button_listener);
28
29 void set_profile(Profile* profile) { profile_ = profile; }
30 void set_host_view(views::View* host_view) { host_view_ = host_view; }
31 void set_bubble_positioner(BubblePositioner* bubble_positioner) {
32 bubble_positioner_ = bubble_positioner;
33 }
34
35 void Init();
23 36
24 // If the bubble isn't showing, shows it. 37 // If the bubble isn't showing, shows it.
25 void ShowStarBubble(const GURL& url, bool newly_bookmarked); 38 void ShowStarBubble(const GURL& url, bool newly_bookmarked);
26 39
27 // Overridden to update ignore_click_ based on whether the mouse was clicked 40 // Overridden to update ignore_click_ based on whether the mouse was clicked
28 // quickly after the bubble was hidden. 41 // quickly after the bubble was hidden.
29 virtual bool OnMousePressed(const views::MouseEvent& e); 42 virtual bool OnMousePressed(const views::MouseEvent& e);
30 43
31 // Overridden to set ignore_click_ to false. 44 // Overridden to set ignore_click_ to false.
32 virtual void OnMouseReleased(const views::MouseEvent& e, bool canceled); 45 virtual void OnMouseReleased(const views::MouseEvent& e, bool canceled);
33 virtual void OnDragDone(); 46 virtual void OnDragDone();
34 47
35 protected: 48 protected:
36 // Only invokes super if ignore_click_ is true and the bubble isn't showing. 49 // Only invokes super if ignore_click_ is true and the bubble isn't showing.
37 virtual void NotifyClick(const views::Event& event); 50 virtual void NotifyClick(const views::Event& event);
38 51
39 // Overridden to so that we appear pressed while the bubble is showing. 52 // Overridden to so that we appear pressed while the bubble is showing.
40 virtual SkBitmap GetImageToPaint(); 53 virtual SkBitmap GetImageToPaint();
41 54
42 private: 55 private:
43 // InfoBubbleDelegate. 56 // InfoBubbleDelegate.
44 virtual void InfoBubbleClosing(InfoBubble* info_bubble, 57 virtual void InfoBubbleClosing(InfoBubble* info_bubble,
45 bool closed_by_escape); 58 bool closed_by_escape);
46 virtual bool CloseOnEscape(); 59 virtual bool CloseOnEscape();
47 60
48 // Contains us. 61 // Profile with bookmarks info.
49 ToolbarView* host_; 62 Profile* profile_;
63
64 // View that hosts us.
65 views::View* host_view_;
66
67 // Positioner for bookmark bubble.
68 BubblePositioner* bubble_positioner_;
50 69
51 // Time the bubble last closed. 70 // Time the bubble last closed.
52 base::TimeTicks bubble_closed_time_; 71 base::TimeTicks bubble_closed_time_;
53 72
54 // If true NotifyClick does nothing. This is set in OnMousePressed based on 73 // If true NotifyClick does nothing. This is set in OnMousePressed based on
55 // the amount of time between when the bubble clicked and now. 74 // the amount of time between when the bubble clicked and now.
56 bool ignore_click_; 75 bool ignore_click_;
57 76
58 DISALLOW_EVIL_CONSTRUCTORS(ToolbarStarToggle); 77 DISALLOW_COPY_AND_ASSIGN(ToolbarStarToggle);
59 }; 78 };
60 79
61 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_STAR_TOGGLE_H_ 80 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_STAR_TOGGLE_H_
OLDNEW
« no previous file with comments | « chrome/browser/views/star_toggle.cc ('k') | chrome/browser/views/toolbar_star_toggle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698