Revert "Only store leading 13 bits of password hash."
[chromium-blink-merge.git] / chrome / browser / ui / views / location_bar / origin_chip_view.h
blobb0e154404abb2515b5e6f1b4b028db5a37db9310
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/gfx/animation/slide_animation.h"
12 #include "ui/views/controls/button/button.h"
13 #include "ui/views/controls/button/label_button.h"
15 class LocationBarView;
16 class OriginChipExtensionIcon;
17 class Profile;
19 namespace content {
20 class WebContents;
23 namespace gfx {
24 class FontList;
27 namespace views {
28 class Label;
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.
37 class OriginChipView : public views::LabelButton,
38 public views::ButtonListener,
39 public SafeBrowsingUIManager::Observer {
40 public:
41 OriginChipView(LocationBarView* location_bar_view,
42 Profile* profile,
43 const gfx::FontList& font_list);
44 ~OriginChipView() override;
46 SkColor pressed_text_color() const { return pressed_text_color_; }
47 SkColor pressed_background_color() const {
48 return background_colors_[Button::STATE_PRESSED];
50 const base::string16& host_label_text() const { return host_label_->text(); }
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.
54 void OnChanged();
56 // Starts/stops a fade-in animation for the border.
57 void FadeIn();
58 void CancelFade();
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;
62 // otherwise, it's a positive value equal to the width of the cert name plus
63 // the space between the labels.
64 int HostLabelOffset() const;
66 // Returns the width of the origin chip from the start of the first label to
67 // the trailing edge of the chip.
68 int WidthFromStartOfLabels() const;
70 // views::LabelButton:
71 gfx::Size GetPreferredSize() const override;
72 void Layout() override;
74 private:
75 // Returns the X coordinate the first label should be placed at.
76 int GetLabelX() const;
78 // Sets an image grid to represent the current security state.
79 void SetBorderImages(const int images[3][9]);
81 // views::LabelButton:
82 void AnimationProgressed(const gfx::Animation* animation) override;
83 void AnimationEnded(const gfx::Animation* animation) override;
84 void OnPaintBorder(gfx::Canvas* canvas) override;
85 void StateChanged() override;
87 // views::ButtonListener:
88 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
90 // SafeBrowsingUIManager::Observer:
91 void OnSafeBrowsingHit(
92 const SafeBrowsingUIManager::UnsafeResource& resource) override;
93 void OnSafeBrowsingMatch(
94 const SafeBrowsingUIManager::UnsafeResource& resource) override;
96 LocationBarView* location_bar_view_;
97 Profile* profile_;
98 SkColor pressed_text_color_;
99 SkColor background_colors_[3];
100 views::Label* ev_label_;
101 views::Label* host_label_;
102 LocationIconView* location_icon_view_;
103 bool showing_16x16_icon_;
104 scoped_ptr<OriginChipExtensionIcon> extension_icon_;
105 gfx::SlideAnimation fade_in_animation_;
106 GURL url_displayed_;
107 ToolbarModel::SecurityLevel security_level_;
108 bool url_malware_;
110 DISALLOW_COPY_AND_ASSIGN(OriginChipView);
113 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ORIGIN_CHIP_VIEW_H_