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

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: Fix test failure by checking for NULL extension 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
31 // A button visible at the beginning of the omnibox which contains the location
32 // icon, an optional EV cert name, and a hostname. The hostname is normally the
33 // hostname for the current page with any leading "www." removed, though for
34 // special built-in pages (e.g. chrome://settings), it can be a descriptive
35 // string. The EV cert name is the organization name of the EV cert holder and
36 // is only present when the current page's security status is EV_SECURE.
33 class OriginChipView : public views::LabelButton, 37 class OriginChipView : public views::LabelButton,
34 public views::ButtonListener, 38 public views::ButtonListener,
35 public SafeBrowsingUIManager::Observer { 39 public SafeBrowsingUIManager::Observer {
36 public: 40 public:
37 OriginChipView(LocationBarView* location_bar_view, 41 OriginChipView(LocationBarView* location_bar_view,
38 Profile* profile, 42 Profile* profile,
39 const gfx::FontList& font_list); 43 const gfx::FontList& font_list);
40 virtual ~OriginChipView(); 44 virtual ~OriginChipView();
41 45
42 // Recalculates the contents of the Origin Chip based on the displayed tab. 46 SkColor pressed_text_color() const { return pressed_text_color_; }
43 void Update(content::WebContents* tab); 47 SkColor pressed_background_color() const {
48 return background_colors_[Button::STATE_PRESSED];
49 }
50 const base::string16& host_label_text() const { return host_label_->text(); }
44 51
45 // Called to signal that the contents of the tab being shown has changed, so 52 // 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. 53 // the origin chip needs to update itself to the new state.
47 void OnChanged(); 54 void OnChanged();
48 55
49 views::ImageView* location_icon_view() { 56 // Starts/stops a fade-in animation for the border.
50 return location_icon_view_; 57 void FadeIn();
51 } 58 void CancelFade();
52 const views::ImageView* location_icon_view() const {
53 return location_icon_view_;
54 }
55 59
56 // Elides the hostname shown to the indicated width, if needed. Returns the 60 // Returns the offset of the host label, relative to where the first label
57 // final width of the origin chip. Note: this may be more than the target 61 // starts. When the EV cert name is not visible, this will always be 0;
58 // width, since the hostname will not be elided past the TLD+1. 62 // otherwise, it's a positive value equal to the width of the cert name plus
59 int ElideDomainTarget(int target_max_width); 63 // the space between the labels.
64 int HostLabelOffset() const;
60 65
61 // Starts an animation that fades in the border. 66 // Returns the width of the origin chip from the start of the first label to
62 void FadeIn(); 67 // the trailing edge of the chip.
63 68 int WidthFromStartOfLabels() const;
64 // Returns the current X position of the host label.
65 int host_label_x() const { return host_label_->x(); }
66 69
67 // views::LabelButton: 70 // views::LabelButton:
68 virtual gfx::Size GetPreferredSize() const OVERRIDE; 71 virtual gfx::Size GetPreferredSize() const OVERRIDE;
72 virtual void Layout() OVERRIDE;
69 73
70 private: 74 private:
75 // Returns the X coordinate the first label should be placed at.
76 int GetLabelX() const;
77
71 // Sets an image grid to represent the current security state. 78 // Sets an image grid to represent the current security state.
72 void SetBorderImages(const int images[3][9]); 79 void SetBorderImages(const int images[3][9]);
73 80
74 // views::LabelButton: 81 // views::LabelButton:
75 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; 82 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
76 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; 83 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
77 virtual void Layout() OVERRIDE;
78 virtual void OnPaintBorder(gfx::Canvas* canvas) OVERRIDE; 84 virtual void OnPaintBorder(gfx::Canvas* canvas) OVERRIDE;
85 virtual void StateChanged() OVERRIDE;
79 86
80 // views::ButtonListener: 87 // views::ButtonListener:
81 virtual void ButtonPressed(views::Button* sender, 88 virtual void ButtonPressed(views::Button* sender,
82 const ui::Event& event) OVERRIDE; 89 const ui::Event& event) OVERRIDE;
83 90
84 // SafeBrowsingUIManager::Observer: 91 // SafeBrowsingUIManager::Observer:
85 virtual void OnSafeBrowsingHit( 92 virtual void OnSafeBrowsingHit(
86 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE; 93 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE;
87 virtual void OnSafeBrowsingMatch( 94 virtual void OnSafeBrowsingMatch(
88 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE; 95 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE;
89 96
90 LocationBarView* location_bar_view_; 97 LocationBarView* location_bar_view_;
91 Profile* profile_; 98 Profile* profile_;
99 SkColor pressed_text_color_;
100 SkColor background_colors_[3];
101 views::Label* ev_label_;
92 views::Label* host_label_; 102 views::Label* host_label_;
93 LocationIconView* location_icon_view_; 103 LocationIconView* location_icon_view_;
94 bool showing_16x16_icon_; 104 bool showing_16x16_icon_;
95 scoped_ptr<OriginChipExtensionIcon> extension_icon_; 105 scoped_ptr<OriginChipExtensionIcon> extension_icon_;
106 gfx::SlideAnimation fade_in_animation_;
96 GURL url_displayed_; 107 GURL url_displayed_;
97 ToolbarModel::SecurityLevel security_level_; 108 ToolbarModel::SecurityLevel security_level_;
98 bool url_malware_; 109 bool url_malware_;
99 scoped_ptr<gfx::SlideAnimation> fade_in_animation_;
100 110
101 DISALLOW_COPY_AND_ASSIGN(OriginChipView); 111 DISALLOW_COPY_AND_ASSIGN(OriginChipView);
102 }; 112 };
103 113
104 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_ 114 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698