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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/security_state_bubble_decoration.h

Issue 2119033002: [Material][Mac] Implement Omnibox Verbose State Chips (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes for the fixes Created 4 years, 4 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
OLDNEW
(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 explicit 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 VerboseAnimation when the animation has progressed.
Robert Sesek 2016/08/18 14:43:23 Update comment.
spqchan 2016/08/18 18:37:18 Done.
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 private:
73 // Returns the animation progress. Return 0.0 if |animation_| is empty.
74 // If in MD, the animation progress should always be 1.0.
75 CGFloat GetAnimationProgress() const;
76
77 // Helper method that calculates and returns the width of the label and icon
78 // within |width|.
79 CGFloat GetWidthForText(CGFloat width);
80
81 LocationIconDecoration* location_icon_; // weak, owned by location bar.
82
83 // The real label. BubbleDecoration's label may be elided.
84 base::scoped_nsobject<NSString> full_label_;
85
86 // The animation of the decoration.
87 base::scoped_nsobject<SecurityStateAnimation> animation_;
88
89 // The color of the label's text. The default color is kGoogleGreen700.
90 SkColor label_color_;
91
92 // True if the image should fade when the verbose animates in.
93 bool image_fade_;
94
95 LocationBarViewMac* owner_; // weak
96
97 DISALLOW_COPY_AND_ASSIGN(SecurityStateBubbleDecoration);
98 };
99
100 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SECURITY_STATE_BUBBLE_DECORATION _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698