| 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_COCOA_LOCATION_BAR_STAR_DECORATION_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_LOCATION_BAR_STAR_DECORATION_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_STAR_DECORATION_H_ | 6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_STAR_DECORATION_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chrome/browser/ui/cocoa/location_bar/image_decoration.h" | 11 #include "chrome/browser/ui/cocoa/location_bar/image_decoration.h" |
| 12 | 12 |
| 13 class CommandUpdater; | 13 class CommandUpdater; |
| 14 | 14 |
| 15 // Star icon on the right side of the field. | 15 // Star icon on the right side of the field. |
| 16 | 16 |
| 17 class StarDecoration : public ImageDecoration { | 17 class StarDecoration : public ImageDecoration { |
| 18 public: | 18 public: |
| 19 explicit StarDecoration(CommandUpdater* command_updater); | 19 explicit StarDecoration(CommandUpdater* command_updater); |
| 20 ~StarDecoration() override; | 20 ~StarDecoration() override; |
| 21 | 21 |
| 22 // Sets the image and tooltip based on |starred|. | 22 // Sets the image and tooltip based on |starred|. |
| 23 void SetStarred(bool starred, bool locationBarIsDark); | 23 void SetStarred(bool starred, bool locationBarIsDark); |
| 24 | 24 |
| 25 // Returns an anchor for GetBubblePointInFrame which points between the star |
| 26 // icon's legs. |
| 27 static NSPoint GetStarBubblePointInFrame(NSRect draw_frame); |
| 28 |
| 25 // Returns true if the star is lit. | 29 // Returns true if the star is lit. |
| 26 bool starred() const { return starred_; } | 30 bool starred() const { return starred_; } |
| 27 | 31 |
| 28 // Implement |LocationBarDecoration|. | 32 // Implement |LocationBarDecoration|. |
| 29 bool AcceptsMousePress() override; | 33 bool AcceptsMousePress() override; |
| 30 bool OnMousePressed(NSRect frame, NSPoint location) override; | 34 bool OnMousePressed(NSRect frame, NSPoint location) override; |
| 31 NSString* GetToolTip() override; | 35 NSString* GetToolTip() override; |
| 32 NSPoint GetBubblePointInFrame(NSRect frame) override; | 36 NSPoint GetBubblePointInFrame(NSRect frame) override; |
| 33 | 37 |
| 34 protected: | 38 protected: |
| 35 // Overridden from LocationBarDecoration: | 39 // Overridden from LocationBarDecoration: |
| 36 SkColor GetMaterialIconColor(bool location_bar_is_dark) const override; | 40 SkColor GetMaterialIconColor(bool location_bar_is_dark) const override; |
| 37 const gfx::VectorIcon* GetMaterialVectorIcon() const override; | 41 const gfx::VectorIcon* GetMaterialVectorIcon() const override; |
| 38 | 42 |
| 39 private: | 43 private: |
| 40 // For bringing up bookmark bar. | 44 // For bringing up bookmark bar. |
| 41 CommandUpdater* command_updater_; // Weak, owned by Browser. | 45 CommandUpdater* command_updater_; // Weak, owned by Browser. |
| 42 | 46 |
| 43 // The string to show for a tooltip. | 47 // The string to show for a tooltip. |
| 44 base::scoped_nsobject<NSString> tooltip_; | 48 base::scoped_nsobject<NSString> tooltip_; |
| 45 | 49 |
| 46 // Whether the star icon is lit. | 50 // Whether the star icon is lit. |
| 47 bool starred_; | 51 bool starred_; |
| 48 | 52 |
| 49 DISALLOW_COPY_AND_ASSIGN(StarDecoration); | 53 DISALLOW_COPY_AND_ASSIGN(StarDecoration); |
| 50 }; | 54 }; |
| 51 | 55 |
| 52 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_STAR_DECORATION_H_ | 56 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_STAR_DECORATION_H_ |
| OLD | NEW |