| Index: chrome/browser/ui/cocoa/location_bar/security_state_bubble_decoration.h
|
| diff --git a/chrome/browser/ui/cocoa/location_bar/security_state_bubble_decoration.h b/chrome/browser/ui/cocoa/location_bar/security_state_bubble_decoration.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fffec2a1282990b50b7f10ee6e549facbd2e0421
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/cocoa/location_bar/security_state_bubble_decoration.h
|
| @@ -0,0 +1,103 @@
|
| +// 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_SECURITY_STATE_BUBBLE_DECORATION_H_
|
| +#define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SECURITY_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 SecurityStateAnimation;
|
| +
|
| +class SecurityStateBubbleDecoration : public BubbleDecoration {
|
| + public:
|
| + SecurityStateBubbleDecoration(LocationIconDecoration* location_icon,
|
| + LocationBarViewMac* owner);
|
| + ~SecurityStateBubbleDecoration() 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 SecurityStateAnimation 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;
|
| +
|
| + protected:
|
| + NSColor* GetDarkModeTextColor() 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<SecurityStateAnimation> 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(SecurityStateBubbleDecoration);
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SECURITY_STATE_BUBBLE_DECORATION_H_
|
|
|