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" |
11 #include "ui/views/controls/button/button.h" | 11 #include "ui/views/controls/button/button.h" |
12 #include "ui/views/controls/button/label_button.h" | 12 #include "ui/views/controls/button/label_button.h" |
13 | 13 |
14 class LocationBarView; | 14 class LocationBarView; |
15 class OriginChipExtensionIcon; | 15 class OriginChipExtensionIcon; |
16 class Profile; | 16 class Profile; |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 class WebContents; | 19 class WebContents; |
20 } | 20 } |
21 | 21 |
22 namespace gfx { | 22 namespace gfx { |
23 class Canvas; | 23 class Canvas; |
24 class FontList; | 24 class FontList; |
| 25 class SlideAnimation; |
25 } | 26 } |
26 | 27 |
27 namespace views { | 28 namespace views { |
28 class Button; | 29 class Button; |
29 class Label; | 30 class Label; |
30 } | 31 } |
31 | 32 |
32 class OriginChipView : public views::LabelButton, | 33 class OriginChipView : public views::LabelButton, |
33 public views::ButtonListener, | 34 public views::ButtonListener, |
34 public SafeBrowsingUIManager::Observer { | 35 public SafeBrowsingUIManager::Observer { |
(...skipping 23 matching lines...) Expand all Loading... |
58 } | 59 } |
59 const views::ImageView* location_icon_view() const { | 60 const views::ImageView* location_icon_view() const { |
60 return location_icon_view_; | 61 return location_icon_view_; |
61 } | 62 } |
62 | 63 |
63 // Elides the hostname shown to the indicated width, if needed. Returns the | 64 // Elides the hostname shown to the indicated width, if needed. Returns the |
64 // final width of the origin chip. Note: this may be more than the target | 65 // final width of the origin chip. Note: this may be more than the target |
65 // width, since the hostname will not be elided past the TLD+1. | 66 // width, since the hostname will not be elided past the TLD+1. |
66 int ElideDomainTarget(int target_max_width); | 67 int ElideDomainTarget(int target_max_width); |
67 | 68 |
| 69 // Starts an animation that fades in the border. |
| 70 void FadeIn(); |
| 71 |
| 72 // Returns the current X position of the host label. |
| 73 int LabelPosition(); |
| 74 |
68 // views::LabelButton: | 75 // views::LabelButton: |
| 76 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 77 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
69 virtual gfx::Size GetPreferredSize() OVERRIDE; | 78 virtual gfx::Size GetPreferredSize() OVERRIDE; |
70 virtual void Layout() OVERRIDE; | 79 virtual void Layout() OVERRIDE; |
| 80 virtual void OnPaintBorder(gfx::Canvas* canvas) OVERRIDE; |
71 | 81 |
72 // views::ButtonListener: | 82 // views::ButtonListener: |
73 virtual void ButtonPressed(views::Button* sender, | 83 virtual void ButtonPressed(views::Button* sender, |
74 const ui::Event& event) OVERRIDE; | 84 const ui::Event& event) OVERRIDE; |
75 | 85 |
76 // SafeBrowsingUIManager::Observer: | 86 // SafeBrowsingUIManager::Observer: |
77 virtual void OnSafeBrowsingHit( | 87 virtual void OnSafeBrowsingHit( |
78 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE; | 88 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE; |
79 virtual void OnSafeBrowsingMatch( | 89 virtual void OnSafeBrowsingMatch( |
80 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE; | 90 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE; |
81 | 91 |
82 private: | 92 private: |
83 // Sets an image grid to represent the current security state. | 93 // Sets an image grid to represent the current security state. |
84 void SetBorderImages(const int images[3][9]); | 94 void SetBorderImages(const int images[3][9]); |
85 | 95 |
86 LocationBarView* location_bar_view_; | 96 LocationBarView* location_bar_view_; |
87 Profile* profile_; | 97 Profile* profile_; |
88 views::Label* host_label_; | 98 views::Label* host_label_; |
89 LocationIconView* location_icon_view_; | 99 LocationIconView* location_icon_view_; |
90 bool showing_16x16_icon_; | 100 bool showing_16x16_icon_; |
91 scoped_ptr<OriginChipExtensionIcon> extension_icon_; | 101 scoped_ptr<OriginChipExtensionIcon> extension_icon_; |
92 GURL url_displayed_; | 102 GURL url_displayed_; |
93 ToolbarModel::SecurityLevel security_level_; | 103 ToolbarModel::SecurityLevel security_level_; |
94 bool url_malware_; | 104 bool url_malware_; |
| 105 scoped_ptr<gfx::SlideAnimation> fade_in_animation_; |
95 | 106 |
96 DISALLOW_COPY_AND_ASSIGN(OriginChipView); | 107 DISALLOW_COPY_AND_ASSIGN(OriginChipView); |
97 }; | 108 }; |
98 | 109 |
99 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_ | 110 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_ |
OLD | NEW |