[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / views / location_bar / origin_chip_view.h
bloba6cfa14b8d88f5e91d7503bbdbd7b39bdd9f70f7
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_
8 #include "chrome/browser/safe_browsing/ui_manager.h"
9 #include "chrome/browser/ui/toolbar/toolbar_model.h"
10 #include "chrome/browser/ui/views/location_bar/location_icon_view.h"
11 #include "ui/views/controls/button/button.h"
12 #include "ui/views/controls/button/label_button.h"
14 class LocationBarView;
15 class OriginChipExtensionIcon;
16 class Profile;
18 namespace content {
19 class WebContents;
22 namespace gfx {
23 class Canvas;
24 class FontList;
25 class SlideAnimation;
28 namespace views {
29 class Button;
30 class Label;
33 class OriginChipView : public views::LabelButton,
34 public views::ButtonListener,
35 public SafeBrowsingUIManager::Observer {
36 public:
37 OriginChipView(LocationBarView* location_bar_view,
38 Profile* profile,
39 const gfx::FontList& font_list);
40 virtual ~OriginChipView();
42 // Recalculates the contents of the Origin Chip based on the displayed tab.
43 void Update(content::WebContents* tab);
45 // 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 void OnChanged();
49 views::ImageView* location_icon_view() {
50 return location_icon_view_;
52 const views::ImageView* location_icon_view() const {
53 return location_icon_view_;
56 // Elides the hostname shown to the indicated width, if needed. Returns the
57 // final width of the origin chip. Note: this may be more than the target
58 // width, since the hostname will not be elided past the TLD+1.
59 int ElideDomainTarget(int target_max_width);
61 // Starts an animation that fades in the border.
62 void FadeIn();
64 // Returns the current X position of the host label.
65 int host_label_x() const { return host_label_->x(); }
67 // views::LabelButton:
68 virtual gfx::Size GetPreferredSize() const OVERRIDE;
70 private:
71 // Sets an image grid to represent the current security state.
72 void SetBorderImages(const int images[3][9]);
74 // views::LabelButton:
75 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
76 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
77 virtual void Layout() OVERRIDE;
78 virtual void OnPaintBorder(gfx::Canvas* canvas) OVERRIDE;
80 // views::ButtonListener:
81 virtual void ButtonPressed(views::Button* sender,
82 const ui::Event& event) OVERRIDE;
84 // SafeBrowsingUIManager::Observer:
85 virtual void OnSafeBrowsingHit(
86 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE;
87 virtual void OnSafeBrowsingMatch(
88 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE;
90 LocationBarView* location_bar_view_;
91 Profile* profile_;
92 views::Label* host_label_;
93 LocationIconView* location_icon_view_;
94 bool showing_16x16_icon_;
95 scoped_ptr<OriginChipExtensionIcon> extension_icon_;
96 GURL url_displayed_;
97 ToolbarModel::SecurityLevel security_level_;
98 bool url_malware_;
99 scoped_ptr<gfx::SlideAnimation> fade_in_animation_;
101 DISALLOW_COPY_AND_ASSIGN(OriginChipView);
104 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_