OLD | NEW |
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" |
(...skipping 23 matching lines...) Expand all Loading... |
34 // special built-in pages (e.g. chrome://settings), it can be a descriptive | 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 | 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. | 36 // is only present when the current page's security status is EV_SECURE. |
37 class OriginChipView : public views::LabelButton, | 37 class OriginChipView : public views::LabelButton, |
38 public views::ButtonListener, | 38 public views::ButtonListener, |
39 public SafeBrowsingUIManager::Observer { | 39 public SafeBrowsingUIManager::Observer { |
40 public: | 40 public: |
41 OriginChipView(LocationBarView* location_bar_view, | 41 OriginChipView(LocationBarView* location_bar_view, |
42 Profile* profile, | 42 Profile* profile, |
43 const gfx::FontList& font_list); | 43 const gfx::FontList& font_list); |
44 virtual ~OriginChipView(); | 44 ~OriginChipView() override; |
45 | 45 |
46 SkColor pressed_text_color() const { return pressed_text_color_; } | 46 SkColor pressed_text_color() const { return pressed_text_color_; } |
47 SkColor pressed_background_color() const { | 47 SkColor pressed_background_color() const { |
48 return background_colors_[Button::STATE_PRESSED]; | 48 return background_colors_[Button::STATE_PRESSED]; |
49 } | 49 } |
50 const base::string16& host_label_text() const { return host_label_->text(); } | 50 const base::string16& host_label_text() const { return host_label_->text(); } |
51 | 51 |
52 // 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 |
53 // the origin chip needs to update itself to the new state. | 53 // the origin chip needs to update itself to the new state. |
54 void OnChanged(); | 54 void OnChanged(); |
55 | 55 |
56 // Starts/stops a fade-in animation for the border. | 56 // Starts/stops a fade-in animation for the border. |
57 void FadeIn(); | 57 void FadeIn(); |
58 void CancelFade(); | 58 void CancelFade(); |
59 | 59 |
60 // Returns the offset of the host label, relative to where the first label | 60 // Returns the offset of the host label, relative to where the first label |
61 // starts. When the EV cert name is not visible, this will always be 0; | 61 // starts. When the EV cert name is not visible, this will always be 0; |
62 // otherwise, it's a positive value equal to the width of the cert name plus | 62 // otherwise, it's a positive value equal to the width of the cert name plus |
63 // the space between the labels. | 63 // the space between the labels. |
64 int HostLabelOffset() const; | 64 int HostLabelOffset() const; |
65 | 65 |
66 // Returns the width of the origin chip from the start of the first label to | 66 // Returns the width of the origin chip from the start of the first label to |
67 // the trailing edge of the chip. | 67 // the trailing edge of the chip. |
68 int WidthFromStartOfLabels() const; | 68 int WidthFromStartOfLabels() const; |
69 | 69 |
70 // views::LabelButton: | 70 // views::LabelButton: |
71 virtual gfx::Size GetPreferredSize() const override; | 71 gfx::Size GetPreferredSize() const override; |
72 virtual void Layout() override; | 72 void Layout() override; |
73 | 73 |
74 private: | 74 private: |
75 // Returns the X coordinate the first label should be placed at. | 75 // Returns the X coordinate the first label should be placed at. |
76 int GetLabelX() const; | 76 int GetLabelX() const; |
77 | 77 |
78 // Sets an image grid to represent the current security state. | 78 // Sets an image grid to represent the current security state. |
79 void SetBorderImages(const int images[3][9]); | 79 void SetBorderImages(const int images[3][9]); |
80 | 80 |
81 // views::LabelButton: | 81 // views::LabelButton: |
82 virtual void AnimationProgressed(const gfx::Animation* animation) override; | 82 void AnimationProgressed(const gfx::Animation* animation) override; |
83 virtual void AnimationEnded(const gfx::Animation* animation) override; | 83 void AnimationEnded(const gfx::Animation* animation) override; |
84 virtual void OnPaintBorder(gfx::Canvas* canvas) override; | 84 void OnPaintBorder(gfx::Canvas* canvas) override; |
85 virtual void StateChanged() override; | 85 void StateChanged() override; |
86 | 86 |
87 // views::ButtonListener: | 87 // views::ButtonListener: |
88 virtual void ButtonPressed(views::Button* sender, | 88 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
89 const ui::Event& event) override; | |
90 | 89 |
91 // SafeBrowsingUIManager::Observer: | 90 // SafeBrowsingUIManager::Observer: |
92 virtual void OnSafeBrowsingHit( | 91 void OnSafeBrowsingHit( |
93 const SafeBrowsingUIManager::UnsafeResource& resource) override; | 92 const SafeBrowsingUIManager::UnsafeResource& resource) override; |
94 virtual void OnSafeBrowsingMatch( | 93 void OnSafeBrowsingMatch( |
95 const SafeBrowsingUIManager::UnsafeResource& resource) override; | 94 const SafeBrowsingUIManager::UnsafeResource& resource) override; |
96 | 95 |
97 LocationBarView* location_bar_view_; | 96 LocationBarView* location_bar_view_; |
98 Profile* profile_; | 97 Profile* profile_; |
99 SkColor pressed_text_color_; | 98 SkColor pressed_text_color_; |
100 SkColor background_colors_[3]; | 99 SkColor background_colors_[3]; |
101 views::Label* ev_label_; | 100 views::Label* ev_label_; |
102 views::Label* host_label_; | 101 views::Label* host_label_; |
103 LocationIconView* location_icon_view_; | 102 LocationIconView* location_icon_view_; |
104 bool showing_16x16_icon_; | 103 bool showing_16x16_icon_; |
105 scoped_ptr<OriginChipExtensionIcon> extension_icon_; | 104 scoped_ptr<OriginChipExtensionIcon> extension_icon_; |
106 gfx::SlideAnimation fade_in_animation_; | 105 gfx::SlideAnimation fade_in_animation_; |
107 GURL url_displayed_; | 106 GURL url_displayed_; |
108 ToolbarModel::SecurityLevel security_level_; | 107 ToolbarModel::SecurityLevel security_level_; |
109 bool url_malware_; | 108 bool url_malware_; |
110 | 109 |
111 DISALLOW_COPY_AND_ASSIGN(OriginChipView); | 110 DISALLOW_COPY_AND_ASSIGN(OriginChipView); |
112 }; | 111 }; |
113 | 112 |
114 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_ | 113 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_ |
OLD | NEW |