Chromium Code Reviews| Index: chrome/browser/ui/cocoa/location_bar/verbose_state_bubble_decoration.h |
| diff --git a/chrome/browser/ui/cocoa/location_bar/verbose_state_bubble_decoration.h b/chrome/browser/ui/cocoa/location_bar/verbose_state_bubble_decoration.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2c8521352511ebf8a4e8b4bff03ae15ab5fbbee9 |
| --- /dev/null |
| +++ b/chrome/browser/ui/cocoa/location_bar/verbose_state_bubble_decoration.h |
| @@ -0,0 +1,100 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_COCOA_LOCATION_BAR_VERBOSE_STATE_BUBBLE_DECORATION_H_ |
| +#define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_VERBOSE_STATE_BUBBLE_DECORATION_H_ |
| + |
| +#import <Cocoa/Cocoa.h> |
| + |
| +#include "base/macros.h" |
| +#include "chrome/browser/ui/cocoa/location_bar/bubble_decoration.h" |
| + |
| +// Draws the verbose state bubble, which contains the security icon and a label |
| +// describing its security state. If an EV cert is available, the icon will be |
| +// a lock and the label will contain the certificate's name. The |
| +// |location_icon| is used to fulfill drag-related calls. |
| + |
| +class LocationBarViewMac; |
| +class LocationIconDecoration; |
| +@class VerboseAnimation; |
| + |
| +class VerboseStateBubbleDecoration : public BubbleDecoration { |
|
Robert Sesek
2016/08/16 22:25:32
"VerboseState" is kind of a weird name IMO. It's r
spqchan
2016/08/17 00:41:18
That's true, I was using what they used on specs.
|
| + public: |
| + explicit VerboseStateBubbleDecoration(LocationIconDecoration* location_icon, |
|
Robert Sesek
2016/08/16 22:25:32
No explicit since it takes more than one param.
spqchan
2016/08/17 00:41:18
Done.
Robert Sesek
2016/08/18 14:43:23
Not done in latest patchset.
spqchan
2016/08/18 18:37:18
Done.
|
| + LocationBarViewMac* owner); |
| + ~VerboseStateBubbleDecoration() override; |
| + |
| + // |GetWidthForSpace()| will set |full_label| as the label, if it |
| + // fits, else it will set an elided version. |
| + void SetFullLabel(NSString* full_label); |
| + |
| + // Set the color of the label. |
| + void SetLabelColor(SkColor color); |
| + |
| + // Called by VerboseAnimation when the animation has progressed. |
| + void OnAnimationProgressed(); |
| + |
| + // Methods that animate in and out the chip. |
| + void AnimateIn(bool image_fade = true); |
| + void AnimateOut(); |
| + |
| + // Returns true if the chip has fully animated in. |
| + bool HasAnimatedIn() const; |
| + |
| + // Returns true if the chip has fully animated out. |
| + bool HasAnimatedOut() const; |
| + |
| + // Returns true if the chip is in the process of animating out. |
| + bool AnimatingOut() const; |
| + |
| + // Resets the animation and set the visibility to be false. |
| + void ResetAndHide(); |
| + |
| + // LocationBarDecoration: |
| + CGFloat GetWidthForSpace(CGFloat width) override; |
| + void DrawInFrame(NSRect frame, NSView* control_view) override; |
| + void DrawWithBackgroundInFrame(NSRect background_frame, |
| + NSRect frame, |
| + NSView* control_view) override; |
| + bool IsDraggable() override; |
| + NSPasteboard* GetDragPasteboard() override; |
| + NSImage* GetDragImage() override; |
| + NSRect GetDragImageFrame(NSRect frame) override; |
| + bool OnMousePressed(NSRect frame, NSPoint location) override; |
| + bool AcceptsMousePress() override; |
| + NSPoint GetBubblePointInFrame(NSRect frame) override; |
| + |
| + // BubbleDecoration: |
| + NSColor* GetBackgroundBorderColor() override; |
| + ui::NinePartImageIds GetBubbleImageIds() override; |
| + |
| + private: |
| + // Returns the animation progress. Return 0.0 if |animation_| is empty. |
| + // If in MD, the animation progress should always be 1.0. |
| + CGFloat GetAnimationProgress() const; |
| + |
| + // Helper method that calculates and returns the width of the label and icon |
| + // within |width|. |
| + CGFloat GetWidthForText(CGFloat width); |
| + |
| + LocationIconDecoration* location_icon_; // weak, owned by location bar. |
| + |
| + // The real label. BubbleDecoration's label may be elided. |
| + base::scoped_nsobject<NSString> full_label_; |
| + |
| + // The animation of the decoration. |
| + base::scoped_nsobject<VerboseAnimation> animation_; |
| + |
| + // The color of the label's text. The default color is kGoogleGreen700. |
| + SkColor label_color_; |
| + |
| + // True if the image should fade when the verbose animates in. |
| + bool image_fade_; |
| + |
| + LocationBarViewMac* owner_; // weak |
| + |
| + DISALLOW_COPY_AND_ASSIGN(VerboseStateBubbleDecoration); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_VERBOSE_STATE_BUBBLE_DECORATION_H_ |