content_setting_image_view.h revision 3f50c38dc070f4bb515c1b64450dae14f316474e
1// Copyright (c) 2010 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/scoped_ptr.h"
10#include "base/string16.h"
11#include "chrome/browser/views/info_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
16class ContentSettingImageModel;
17class InfoBubble;
18class LocationBarView;
19class Profile;
20class TabContents;
21
22namespace views {
23class MouseEvent;
24}
25
26class ContentSettingImageView : public views::ImageView,
27                                public InfoBubbleDelegate,
28                                public ui::LinearAnimation {
29 public:
30  ContentSettingImageView(ContentSettingsType content_type,
31                          LocationBarView* parent,
32                          Profile* profile);
33  virtual ~ContentSettingImageView();
34
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);
46  virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
47  virtual void VisibilityChanged(View* starting_from, bool is_visible);
48  virtual void Paint(gfx::Canvas* canvas);
49  virtual void PaintBackground(gfx::Canvas* canvas);
50
51  // InfoBubbleDelegate overrides:
52  virtual void InfoBubbleClosing(InfoBubble* info_bubble,
53                                 bool closed_by_escape);
54  virtual bool CloseOnEscape();
55  virtual bool FadeInOnShow() { return false; }
56
57  // ui::LinearAnimation override:
58  virtual void AnimateToState(double state);
59
60  scoped_ptr<ContentSettingImageModel> content_setting_image_model_;
61
62  // The owning LocationBarView.
63  LocationBarView* parent_;
64
65  // The currently active profile.
66  Profile* profile_;
67
68  // The currently shown info bubble if any.
69  InfoBubble* info_bubble_;
70
71  string16 animated_text_;
72  bool animation_in_progress_;
73  int text_size_;
74  int visible_text_size_;
75  gfx::Insets saved_insets_;
76
77  DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingImageView);
78};
79
80#endif  // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_CONTENT_SETTING_IMAGE_VIEW_H_
81