OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_COCOA_LOCATION_BAR_SECURITY_STATE_BUBBLE_DECORATION_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SECURITY_STATE_BUBBLE_DECORATION_H_ |
| 7 |
| 8 #import <Cocoa/Cocoa.h> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "chrome/browser/ui/cocoa/location_bar/bubble_decoration.h" |
| 12 |
| 13 // Draws the verbose state bubble, which contains the security icon and a label |
| 14 // describing its security state. If an EV cert is available, the icon will be |
| 15 // a lock and the label will contain the certificate's name. The |
| 16 // |location_icon| is used to fulfill drag-related calls. |
| 17 |
| 18 class LocationBarViewMac; |
| 19 class LocationIconDecoration; |
| 20 @class SecurityStateAnimation; |
| 21 |
| 22 class SecurityStateBubbleDecoration : public BubbleDecoration { |
| 23 public: |
| 24 SecurityStateBubbleDecoration(LocationIconDecoration* location_icon, |
| 25 LocationBarViewMac* owner); |
| 26 ~SecurityStateBubbleDecoration() override; |
| 27 |
| 28 // |GetWidthForSpace()| will set |full_label| as the label, if it |
| 29 // fits, else it will set an elided version. |
| 30 void SetFullLabel(NSString* full_label); |
| 31 |
| 32 // Set the color of the label. |
| 33 void SetLabelColor(SkColor color); |
| 34 |
| 35 // Called by SecurityStateAnimation when the animation has progressed. |
| 36 void OnAnimationProgressed(); |
| 37 |
| 38 // Methods that animate in and out the chip. |
| 39 void AnimateIn(bool image_fade = true); |
| 40 void AnimateOut(); |
| 41 |
| 42 // Returns true if the chip has fully animated in. |
| 43 bool HasAnimatedIn() const; |
| 44 |
| 45 // Returns true if the chip has fully animated out. |
| 46 bool HasAnimatedOut() const; |
| 47 |
| 48 // Returns true if the chip is in the process of animating out. |
| 49 bool AnimatingOut() const; |
| 50 |
| 51 // Resets the animation and set the visibility to be false. |
| 52 void ResetAndHide(); |
| 53 |
| 54 // LocationBarDecoration: |
| 55 CGFloat GetWidthForSpace(CGFloat width) override; |
| 56 void DrawInFrame(NSRect frame, NSView* control_view) override; |
| 57 void DrawWithBackgroundInFrame(NSRect background_frame, |
| 58 NSRect frame, |
| 59 NSView* control_view) override; |
| 60 bool IsDraggable() override; |
| 61 NSPasteboard* GetDragPasteboard() override; |
| 62 NSImage* GetDragImage() override; |
| 63 NSRect GetDragImageFrame(NSRect frame) override; |
| 64 bool OnMousePressed(NSRect frame, NSPoint location) override; |
| 65 bool AcceptsMousePress() override; |
| 66 NSPoint GetBubblePointInFrame(NSRect frame) override; |
| 67 |
| 68 // BubbleDecoration: |
| 69 NSColor* GetBackgroundBorderColor() override; |
| 70 ui::NinePartImageIds GetBubbleImageIds() override; |
| 71 |
| 72 protected: |
| 73 NSColor* GetDarkModeTextColor() override; |
| 74 |
| 75 private: |
| 76 // Returns the animation progress. Return 0.0 if |animation_| is empty. |
| 77 // If in MD, the animation progress should always be 1.0. |
| 78 CGFloat GetAnimationProgress() const; |
| 79 |
| 80 // Helper method that calculates and returns the width of the label and icon |
| 81 // within |width|. |
| 82 CGFloat GetWidthForText(CGFloat width); |
| 83 |
| 84 LocationIconDecoration* location_icon_; // weak, owned by location bar. |
| 85 |
| 86 // The real label. BubbleDecoration's label may be elided. |
| 87 base::scoped_nsobject<NSString> full_label_; |
| 88 |
| 89 // The animation of the decoration. |
| 90 base::scoped_nsobject<SecurityStateAnimation> animation_; |
| 91 |
| 92 // The color of the label's text. The default color is kGoogleGreen700. |
| 93 SkColor label_color_; |
| 94 |
| 95 // True if the image should fade when the verbose animates in. |
| 96 bool image_fade_; |
| 97 |
| 98 LocationBarViewMac* owner_; // weak |
| 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(SecurityStateBubbleDecoration); |
| 101 }; |
| 102 |
| 103 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SECURITY_STATE_BUBBLE_DECORATION
_H_ |
OLD | NEW |