Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_TOOLBAR_SITE_CHIP_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_SITE_CHIP_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_SITE_CHIP_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_SITE_CHIP_VIEW_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/ui/toolbar/toolbar_model.h" | |
| 8 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 9 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 9 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" | 10 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" |
| 10 #include "ui/views/controls/button/button.h" | 11 #include "ui/views/controls/button/button.h" |
| 12 #include "ui/views/drag_controller.h" | |
| 11 | 13 |
| 14 class SiteChipExtensionIcon; | |
| 12 class ToolbarView; | 15 class ToolbarView; |
| 13 | 16 |
| 14 namespace content { | 17 namespace content { |
| 15 class WebContents; | 18 class WebContents; |
| 16 } | 19 } |
| 17 | 20 |
| 18 namespace gfx { | 21 namespace gfx { |
| 19 class Canvas; | 22 class Canvas; |
| 20 } | 23 } |
| 21 | 24 |
| 22 namespace views { | 25 namespace views { |
| 23 class Button; | 26 class Button; |
| 24 class Label; | 27 class Label; |
| 25 } | 28 } |
| 26 | 29 |
| 27 class SiteChipView : public ToolbarButton, | 30 class SiteChipView : public ToolbarButton, |
| 28 public views::ButtonListener { | 31 public views::ButtonListener, |
| 32 public views::DragController { | |
| 29 public: | 33 public: |
| 30 explicit SiteChipView(ToolbarView* toolbar_view); | 34 explicit SiteChipView(ToolbarView* toolbar_view); |
| 31 virtual ~SiteChipView(); | 35 virtual ~SiteChipView(); |
| 32 | 36 |
| 33 void Init(); | 37 void Init(); |
| 34 | 38 |
| 35 // Returns true if the site chip experiment is enabled and thus the site chip | 39 // Returns true if the site chip experiment is enabled and thus the site chip |
| 36 // should be shown in the toolbar. | 40 // should be shown in the toolbar. |
| 37 bool ShouldShow(); | 41 bool ShouldShow(); |
| 38 | 42 |
| 39 // Recalculates the contents of the Site Chip based on the displayed tab. | 43 // Recalculates the contents of the Site Chip based on the displayed tab. |
| 40 void Update(content::WebContents* tab); | 44 void Update(content::WebContents* tab); |
| 41 | 45 |
| 42 views::ImageView* location_icon_view() { return location_icon_view_; } | 46 void OnChanged(); |
| 47 | |
| 48 views::ImageView* location_icon_view() { | |
| 49 return location_icon_view_; | |
| 50 } | |
| 51 const views::ImageView* location_icon_view() const { | |
| 52 return location_icon_view_; | |
| 53 } | |
| 43 | 54 |
| 44 // ToolbarButton: | 55 // ToolbarButton: |
| 45 virtual gfx::Size GetPreferredSize() OVERRIDE; | 56 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 46 virtual void Layout() OVERRIDE; | 57 virtual void Layout() OVERRIDE; |
| 47 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 58 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 48 | 59 |
| 49 // views::ButtonListener: | 60 // views::ButtonListener: |
| 50 virtual void ButtonPressed(views::Button* sender, | 61 virtual void ButtonPressed(views::Button* sender, |
| 51 const ui::Event& event) OVERRIDE; | 62 const ui::Event& event) OVERRIDE; |
| 52 | 63 |
| 64 // views::DragController:: | |
|
Peter Kasting
2013/12/10 03:28:39
Nit: Extra trailing ':'
Greg Billock
2013/12/10 17:37:59
Done.
| |
| 65 virtual void WriteDragDataForView(View* sender, | |
| 66 const gfx::Point& press_pt, | |
| 67 OSExchangeData* data) OVERRIDE; | |
| 68 virtual int GetDragOperationsForView(View* sender, | |
| 69 const gfx::Point& p) OVERRIDE; | |
| 70 virtual bool CanStartDragForView(View* sender, | |
| 71 const gfx::Point& press_pt, | |
| 72 const gfx::Point& p) OVERRIDE; | |
| 73 | |
| 53 private: | 74 private: |
| 75 string16 SiteLabelFromURL(const GURL& url); | |
| 76 | |
| 54 ToolbarView* toolbar_view_; | 77 ToolbarView* toolbar_view_; |
| 55 views::Label* host_label_; | 78 views::Label* host_label_; |
| 56 LocationIconView* location_icon_view_; | 79 LocationIconView* location_icon_view_; |
| 57 scoped_ptr<views::Painter> background_painter_; | 80 scoped_ptr<views::Painter> ev_background_painter_; |
| 81 scoped_ptr<views::Painter> badssl_background_painter_; | |
|
Peter Kasting
2013/12/10 03:28:39
Nit: badssl -> bad_ssl (or broken_ssl?)
Greg Billock
2013/12/10 17:37:59
Went with broken to match the image constants.
| |
| 82 // Will point to one of the background painters. | |
|
Peter Kasting
2013/12/10 03:28:39
Nit: Or NULL?
Greg Billock
2013/12/10 17:37:59
Done.
| |
| 83 views::Painter* painter_; | |
| 84 bool showing_16x16_icon_; | |
| 85 scoped_ptr<SiteChipExtensionIcon> extension_icon_loader_; | |
|
Peter Kasting
2013/12/10 03:28:39
Nit: This should just be |extension_icon_|, both t
Greg Billock
2013/12/10 17:37:59
ok, but I think that the base class is named "Icon
| |
| 86 GURL url_displayed_; | |
| 87 string16 host_; | |
| 88 ToolbarModel::SecurityLevel security_level_; | |
| 58 | 89 |
| 59 DISALLOW_COPY_AND_ASSIGN(SiteChipView); | 90 DISALLOW_COPY_AND_ASSIGN(SiteChipView); |
| 60 }; | 91 }; |
| 61 | 92 |
| 62 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_SITE_CHIP_VIEW_H_ | 93 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_SITE_CHIP_VIEW_H_ |
| OLD | NEW |