summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/blocked_popup_container_view_win.h
blob: 756a4deab732392156ab569d98d4dd8ab018dd21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright (c) 2009 The Chromium Authors. All rights reserved.  Use of this
// source code is governed by a BSD-style license that can be found in the
// LICENSE file.

#ifndef CHROME_BROWSER_VIEWS_BLOCKED_POPUP_CONTAINER_VIEW_WIN_H_
#define CHROME_BROWSER_VIEWS_BLOCKED_POPUP_CONTAINER_VIEW_WIN_H_

#include <set>
#include <utility>
#include <vector>

#include "app/slide_animation.h"
#include "base/gfx/native_widget_types.h"
#include "base/gfx/rect.h"
#include "chrome/browser/blocked_popup_container.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
#include "views/controls/button/button.h"
#include "views/controls/button/menu_button.h"
#include "views/controls/menu/menu.h"
#include "views/view.h"
#include "views/widget/widget_win.h"

class BlockedPopupContainerInternalView;
class PrefService;
class Profile;
class TabContents;
class TextButton;

namespace views {
class ImageButton;
}

// Takes ownership of TabContents that are unrequested popup windows and
// presents an interface to the user for launching them. (Or never showing them
// again).
class BlockedPopupContainerViewWin : public BlockedPopupContainerView,
                                     public AnimationDelegate,
                                     public views::WidgetWin {
 public:
  virtual ~BlockedPopupContainerViewWin();

  // Returns the URL and title for popup |index|, used to construct a string for
  // display.
  void GetURLAndTitleForPopup(size_t index,
                              std::wstring* url,
                              std::wstring* title) const;

  // Returns the names of hosts showing popups.
  std::vector<std::wstring> GetHosts() const;

  // Returns the number of blocked popups from the model
  size_t GetBlockedPopupCount() const;

  // Returns the number of blocked notices from the model
  size_t GetBlockedNoticeCount() const;

  // Returns the model that owns us.
  BlockedPopupContainer* GetModel() const { return container_model_; }

  // Overridden from AnimationDelegate:
  virtual void AnimationStarted(const Animation* animation);
  virtual void AnimationEnded(const Animation* animation);
  virtual void AnimationProgressed(const Animation* animation);

  // Overridden from BlockedPopupContainerView:
  virtual void SetPosition();
  virtual void ShowView();
  virtual void UpdateLabel();
  virtual void HideView();
  virtual void Destroy();

 private:
  // For the static constructor BlockedPopupContainerView::Create().
  friend class BlockedPopupContainerView;

  // Creates a container for a certain TabContents.
  explicit BlockedPopupContainerViewWin(BlockedPopupContainer* container);

  // Overridden from views::WidgetWin:

  // Makes the top corners of the window rounded during resizing events.
  virtual void OnSize(UINT param, const CSize& size);

  // Our model; calling the shots.
  BlockedPopupContainer* container_model_;

  // Our associated view object.
  BlockedPopupContainerInternalView* container_view_;

  // The animation that slides us up and down.
  scoped_ptr<SlideAnimation> slide_animation_;

  DISALLOW_COPY_AND_ASSIGN(BlockedPopupContainerViewWin);
};

#endif  // CHROME_BROWSER_VIEWS_BLOCKED_POPUP_CONTAINER_VIEW_WIN_H_