• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 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.
4 
5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_
7 #pragma once
8 
9 #include "base/memory/scoped_ptr.h"
10 #include "base/string16.h"
11 #include "chrome/browser/ui/views/bubble/bubble.h"
12 #include "chrome/common/content_settings_types.h"
13 #include "ui/base/animation/linear_animation.h"
14 #include "views/controls/image_view.h"
15 
16 class ContentSettingImageModel;
17 class Bubble;
18 class LocationBarView;
19 class Profile;
20 class TabContents;
21 
22 namespace views {
23 class MouseEvent;
24 }
25 
26 class ContentSettingImageView : public views::ImageView,
27                                 public BubbleDelegate,
28                                 public ui::LinearAnimation {
29  public:
30   ContentSettingImageView(ContentSettingsType content_type,
31                           LocationBarView* parent,
32                           Profile* profile);
33   virtual ~ContentSettingImageView();
34 
set_profile(Profile * profile)35   void set_profile(Profile* profile) { profile_ = profile; }
36   // |new_navigation| true if this is a new navigation, false if the tab was
37   // just switched to.
38   void UpdateFromTabContents(TabContents* tab_contents);
39 
40   // views::View overrides:
41   virtual gfx::Size GetPreferredSize();
42 
43  private:
44   // views::ImageView overrides:
45   virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE;
46   virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
47   virtual void VisibilityChanged(View* starting_from, bool is_visible) OVERRIDE;
48   virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
49   virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE;
50 
51   // BubbleDelegate overrides:
52   virtual void BubbleClosing(Bubble* bubble, bool closed_by_escape) OVERRIDE;
53   virtual bool CloseOnEscape() OVERRIDE;
54   virtual bool FadeInOnShow() OVERRIDE;
55 
56   // ui::LinearAnimation override:
57   virtual void AnimateToState(double state) OVERRIDE;
58 
59   scoped_ptr<ContentSettingImageModel> content_setting_image_model_;
60 
61   // The owning LocationBarView.
62   LocationBarView* parent_;
63 
64   // The currently active profile.
65   Profile* profile_;
66 
67   // The currently shown info bubble if any.
68   Bubble* bubble_;
69 
70   string16 animated_text_;
71   bool animation_in_progress_;
72   int text_size_;
73   int visible_text_size_;
74   gfx::Insets saved_insets_;
75 
76   DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingImageView);
77 };
78 
79 #endif  // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_
80