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

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: nit Created 4 years, 3 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 #include "ui/compositor/layer_animation_observer.h"
13 #include "ui/gfx/animation/animation_delegate.h"
14 #include "ui/gfx/animation/slide_animation.h"
15
16 // Draws the verbose state bubble, which contains the security icon and a label
17 // describing its security state. If an EV cert is available, the icon will be
18 // a lock and the label will contain the certificate's name. The
19 // |location_icon| is used to fulfill drag-related calls.
20
21 class LocationBarViewMac;
22 class LocationIconDecoration;
23
24 namespace {
25 class SecurityStateBubbleDecorationTest;
26 }
27
28 class SecurityStateBubbleDecoration : public BubbleDecoration,
29 public gfx::AnimationDelegate {
30 public:
31 SecurityStateBubbleDecoration(LocationIconDecoration* location_icon,
32 LocationBarViewMac* owner);
33 ~SecurityStateBubbleDecoration() override;
34
35 // |GetWidthForSpace()| will set |full_label| as the label, if it
36 // fits, else it will set an elided version.
37 void SetFullLabel(NSString* full_label);
38
39 // Set the color of the label.
40 void SetLabelColor(SkColor color);
41
42 // Methods that animate in and out the chip.
43 void AnimateIn(bool image_fade = true);
44 void AnimateOut();
45
46 // Returns true if the chip has fully animated in.
47 bool HasAnimatedIn() const;
48
49 // Returns true if the chip has fully animated out.
50 bool HasAnimatedOut() const;
51
52 // Returns true if the chip is in the process of animating out.
53 bool AnimatingOut() const;
54
55 // LocationBarDecoration:
56 CGFloat GetWidthForSpace(CGFloat width) override;
57 void DrawInFrame(NSRect frame, NSView* control_view) override;
58 void DrawWithBackgroundInFrame(NSRect background_frame,
59 NSRect frame,
60 NSView* control_view) override;
61 bool IsDraggable() override;
62 NSPasteboard* GetDragPasteboard() override;
63 NSImage* GetDragImage() override;
64 NSRect GetDragImageFrame(NSRect frame) override;
65 bool OnMousePressed(NSRect frame, NSPoint location) override;
66 bool AcceptsMousePress() override;
67 NSPoint GetBubblePointInFrame(NSRect frame) override;
68
69 // BubbleDecoration:
70 NSColor* GetBackgroundBorderColor() override;
71 ui::NinePartImageIds GetBubbleImageIds() override;
72
73 // gfx::AnimationDelegate:
74 void AnimationProgressed(const gfx::Animation* animation) override;
75
76 protected:
77 NSColor* GetDarkModeTextColor() override;
78
79 private:
80 friend class ::SecurityStateBubbleDecorationTest;
81
82 // Returns the animation progress. If not in MD, the animation progress
83 // should always be 1.0.
84 CGFloat GetAnimationProgress() const;
85
86 // Helper method that calculates and returns the width of the label and icon
87 // within |width|.
88 CGFloat GetWidthForText(CGFloat width);
89
90 LocationIconDecoration* location_icon_; // weak, owned by location bar.
91
92 // The real label. BubbleDecoration's label may be elided.
93 base::scoped_nsobject<NSString> full_label_;
94
95 // The color of the label's text. The default color is kGoogleGreen700.
96 SkColor label_color_;
97
98 // True if the image should fade when the verbose animates in.
99 bool image_fade_;
100
101 // The animation of the decoration.
102 gfx::SlideAnimation animation_;
103
104 LocationBarViewMac* owner_; // weak
105
106 // Used to disable find bar animations when testing.
107 bool disable_animations_during_testing_;
108
109 DISALLOW_COPY_AND_ASSIGN(SecurityStateBubbleDecoration);
110 };
111
112 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SECURITY_STATE_BUBBLE_DECORATION _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698