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