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

Side by Side Diff: chrome/browser/ui/views/location_bar/origin_chip_view.h

Issue 302453002: New animation for the origin chip URL showing/hiding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bugfixes and more animations Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_
7 7
8 #include "chrome/browser/safe_browsing/ui_manager.h" 8 #include "chrome/browser/safe_browsing/ui_manager.h"
9 #include "chrome/browser/ui/toolbar/toolbar_model.h" 9 #include "chrome/browser/ui/toolbar/toolbar_model.h"
10 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" 10 #include "chrome/browser/ui/views/location_bar/location_icon_view.h"
11 #include "ui/gfx/animation/slide_animation.h"
11 #include "ui/views/controls/button/button.h" 12 #include "ui/views/controls/button/button.h"
12 #include "ui/views/controls/button/label_button.h" 13 #include "ui/views/controls/button/label_button.h"
13 14
14 class LocationBarView; 15 class LocationBarView;
15 class OriginChipExtensionIcon; 16 class OriginChipExtensionIcon;
16 class Profile; 17 class Profile;
17 18
18 namespace content { 19 namespace content {
19 class WebContents; 20 class WebContents;
20 } 21 }
21 22
22 namespace gfx { 23 namespace gfx {
23 class Canvas;
24 class FontList; 24 class FontList;
25 class SlideAnimation;
26 } 25 }
27 26
28 namespace views { 27 namespace views {
29 class Button;
30 class Label; 28 class Label;
31 } 29 }
32 30
33 class OriginChipView : public views::LabelButton, 31 class OriginChipView : public views::LabelButton,
34 public views::ButtonListener, 32 public views::ButtonListener,
35 public SafeBrowsingUIManager::Observer { 33 public SafeBrowsingUIManager::Observer {
36 public: 34 public:
37 OriginChipView(LocationBarView* location_bar_view, 35 OriginChipView(LocationBarView* location_bar_view,
38 Profile* profile, 36 Profile* profile,
39 const gfx::FontList& font_list); 37 const gfx::FontList& font_list);
40 virtual ~OriginChipView(); 38 virtual ~OriginChipView();
41 39
42 // Recalculates the contents of the Origin Chip based on the displayed tab. 40 SkColor pressed_text_color() const { return pressed_text_color_; }
43 void Update(content::WebContents* tab); 41 SkColor pressed_background_color() const {
42 return background_colors_[Button::STATE_PRESSED];
43 }
44 const base::string16& host_label_text() const { return host_label_->text(); }
44 45
45 // Called to signal that the contents of the tab being shown has changed, so 46 // Called to signal that the contents of the tab being shown has changed, so
46 // the origin chip needs to update itself to the new state. 47 // the origin chip needs to update itself to the new state.
47 void OnChanged(); 48 void OnChanged();
48 49
49 views::ImageView* location_icon_view() { 50 // Starts/stops a fade-in animation for the border.
50 return location_icon_view_; 51 void FadeIn();
51 } 52 void CancelFade();
52 const views::ImageView* location_icon_view() const {
53 return location_icon_view_;
54 }
55 53
56 // Elides the hostname shown to the indicated width, if needed. Returns the 54 // Returns the offset of the host label, relative to where the first label
Justin Donnelly 2014/05/29 21:37:29 The comments for this method and GetLabelX would m
Peter Kasting 2014/05/29 23:32:16 Done.
57 // final width of the origin chip. Note: this may be more than the target 55 // starts.
58 // width, since the hostname will not be elided past the TLD+1. 56 int HostLabelOffset() const;
59 int ElideDomainTarget(int target_max_width);
60
61 // Starts an animation that fades in the border.
62 void FadeIn();
63
64 // Returns the current X position of the host label.
65 int host_label_x() const { return host_label_->x(); }
66 57
67 // views::LabelButton: 58 // views::LabelButton:
68 virtual gfx::Size GetPreferredSize() const OVERRIDE; 59 virtual gfx::Size GetPreferredSize() const OVERRIDE;
60 virtual void Layout() OVERRIDE;
69 61
70 private: 62 private:
63 // Returns the X coordinate the first label should be placed at.
64 int GetLabelX() const;
65
71 // Sets an image grid to represent the current security state. 66 // Sets an image grid to represent the current security state.
72 void SetBorderImages(const int images[3][9]); 67 void SetBorderImages(const int images[3][9]);
73 68
74 // views::LabelButton: 69 // views::LabelButton:
75 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; 70 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
76 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; 71 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
77 virtual void Layout() OVERRIDE;
78 virtual void OnPaintBorder(gfx::Canvas* canvas) OVERRIDE; 72 virtual void OnPaintBorder(gfx::Canvas* canvas) OVERRIDE;
73 virtual void StateChanged() OVERRIDE;
79 74
80 // views::ButtonListener: 75 // views::ButtonListener:
81 virtual void ButtonPressed(views::Button* sender, 76 virtual void ButtonPressed(views::Button* sender,
82 const ui::Event& event) OVERRIDE; 77 const ui::Event& event) OVERRIDE;
83 78
84 // SafeBrowsingUIManager::Observer: 79 // SafeBrowsingUIManager::Observer:
85 virtual void OnSafeBrowsingHit( 80 virtual void OnSafeBrowsingHit(
86 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE; 81 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE;
87 virtual void OnSafeBrowsingMatch( 82 virtual void OnSafeBrowsingMatch(
88 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE; 83 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE;
89 84
90 LocationBarView* location_bar_view_; 85 LocationBarView* location_bar_view_;
91 Profile* profile_; 86 Profile* profile_;
87 SkColor pressed_text_color_;
88 SkColor background_colors_[3];
89 views::Label* ev_label_;
92 views::Label* host_label_; 90 views::Label* host_label_;
93 LocationIconView* location_icon_view_; 91 LocationIconView* location_icon_view_;
94 bool showing_16x16_icon_; 92 bool showing_16x16_icon_;
95 scoped_ptr<OriginChipExtensionIcon> extension_icon_; 93 scoped_ptr<OriginChipExtensionIcon> extension_icon_;
94 gfx::SlideAnimation fade_in_animation_;
96 GURL url_displayed_; 95 GURL url_displayed_;
97 ToolbarModel::SecurityLevel security_level_; 96 ToolbarModel::SecurityLevel security_level_;
98 bool url_malware_; 97 bool url_malware_;
99 scoped_ptr<gfx::SlideAnimation> fade_in_animation_;
100 98
101 DISALLOW_COPY_AND_ASSIGN(OriginChipView); 99 DISALLOW_COPY_AND_ASSIGN(OriginChipView);
102 }; 100 };
103 101
104 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_ 102 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698