collected_cookies_views.h revision a93a17c8d99d686bd4a1511e5504e5e6cc9fcadf
1// Copyright (c) 2012 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_COLLECTED_COOKIES_VIEWS_H_
6#define CHROME_BROWSER_UI_VIEWS_COLLECTED_COOKIES_VIEWS_H_
7
8#include "base/compiler_specific.h"
9#include "chrome/common/content_settings.h"
10#include "content/public/browser/notification_observer.h"
11#include "content/public/browser/notification_registrar.h"
12#include "ui/views/controls/button/button.h"
13#include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h"
14#include "ui/views/controls/tree/tree_view_controller.h"
15#include "ui/views/window/dialog_delegate.h"
16
17class CookieInfoView;
18class CookiesTreeModel;
19class InfobarView;
20
21namespace content {
22class WebContents;
23}
24
25namespace views {
26class Label;
27class LabelButton;
28class TreeView;
29class Widget;
30}
31
32// This is the Views implementation of the collected cookies dialog.
33//
34// CollectedCookiesViews is a dialog that displays the allowed and blocked
35// cookies of the current tab contents. To display the dialog, invoke
36// ShowCollectedCookiesDialog() on the delegate of the WebContents's
37// content settings tab helper.
38class CollectedCookiesViews : public views::DialogDelegateView,
39                              public content::NotificationObserver,
40                              public views::ButtonListener,
41                              public views::TabbedPaneListener,
42                              public views::TreeViewController {
43 public:
44  // Use BrowserWindow::ShowCollectedCookiesDialog to show.
45  explicit CollectedCookiesViews(content::WebContents* web_contents);
46
47  // views::DialogDelegate:
48  virtual string16 GetWindowTitle() const OVERRIDE;
49  virtual int GetDialogButtons() const OVERRIDE;
50  virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE;
51  virtual void DeleteDelegate() OVERRIDE;
52  virtual bool Cancel() OVERRIDE;
53  virtual views::NonClientFrameView* CreateNonClientFrameView(
54      views::Widget* widget) OVERRIDE;
55  virtual ui::ModalType GetModalType() const OVERRIDE;
56
57  // views::ButtonListener:
58  virtual void ButtonPressed(views::Button* sender,
59                             const ui::Event& event) OVERRIDE;
60
61  // views::TabbedPaneListener:
62  virtual void TabSelectedAt(int index) OVERRIDE;
63
64  // views::TreeViewController:
65  virtual void OnTreeViewSelectionChanged(views::TreeView* tree_view) OVERRIDE;
66
67  // views::View:
68  virtual void ViewHierarchyChanged(
69      const ViewHierarchyChangedDetails& details) OVERRIDE;
70
71 private:
72  virtual ~CollectedCookiesViews();
73
74  void Init();
75
76  views::View* CreateAllowedPane();
77
78  views::View* CreateBlockedPane();
79
80  void EnableControls();
81
82  void ShowCookieInfo();
83
84  void AddContentException(views::TreeView* tree_view, ContentSetting setting);
85
86  // content::NotificationObserver:
87  virtual void Observe(int type,
88                       const content::NotificationSource& source,
89                       const content::NotificationDetails& details) OVERRIDE;
90
91  content::NotificationRegistrar registrar_;
92
93  views::Widget* window_;
94
95  // The web contents.
96  content::WebContents* web_contents_;
97
98  // Assorted views.
99  views::Label* allowed_label_;
100  views::Label* blocked_label_;
101
102  views::TreeView* allowed_cookies_tree_;
103  views::TreeView* blocked_cookies_tree_;
104
105  views::LabelButton* block_allowed_button_;
106  views::LabelButton* allow_blocked_button_;
107  views::LabelButton* for_session_blocked_button_;
108
109  scoped_ptr<CookiesTreeModel> allowed_cookies_tree_model_;
110  scoped_ptr<CookiesTreeModel> blocked_cookies_tree_model_;
111
112  CookieInfoView* cookie_info_view_;
113
114  InfobarView* infobar_;
115
116  bool status_changed_;
117
118  DISALLOW_COPY_AND_ASSIGN(CollectedCookiesViews);
119};
120
121#endif  // CHROME_BROWSER_UI_VIEWS_COLLECTED_COOKIES_VIEWS_H_
122