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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_COLLECTED_COOKIES_VIEWS_H_
6 #define CHROME_BROWSER_UI_VIEWS_COLLECTED_COOKIES_VIEWS_H_
8 #include "base/compiler_specific.h"
9 #include "components/content_settings/core/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"
18 class CookiesTreeModel
;
32 // This is the Views implementation of the collected cookies dialog.
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.
38 class CollectedCookiesViews
: public views::DialogDelegateView
,
39 public content::NotificationObserver
,
40 public views::ButtonListener
,
41 public views::TabbedPaneListener
,
42 public views::TreeViewController
{
44 // Use BrowserWindow::ShowCollectedCookiesDialog to show.
45 explicit CollectedCookiesViews(content::WebContents
* web_contents
);
47 // views::DialogDelegate:
48 base::string16
GetWindowTitle() const override
;
49 int GetDialogButtons() const override
;
50 base::string16
GetDialogButtonLabel(ui::DialogButton button
) const override
;
51 bool Cancel() override
;
52 ui::ModalType
GetModalType() const override
;
54 // views::ButtonListener:
55 void ButtonPressed(views::Button
* sender
, const ui::Event
& event
) override
;
57 // views::TabbedPaneListener:
58 void TabSelectedAt(int index
) override
;
60 // views::TreeViewController:
61 void OnTreeViewSelectionChanged(views::TreeView
* tree_view
) override
;
64 gfx::Size
GetMinimumSize() const override
;
65 void ViewHierarchyChanged(
66 const ViewHierarchyChangedDetails
& details
) override
;
69 friend class CollectedCookiesViewsTest
;
71 ~CollectedCookiesViews() override
;
75 views::View
* CreateAllowedPane();
77 views::View
* CreateBlockedPane();
79 // Creates and returns a containing ScrollView around the given tree view.
80 views::View
* CreateScrollView(views::TreeView
* pane
);
82 void EnableControls();
84 void ShowCookieInfo();
86 void AddContentException(views::TreeView
* tree_view
, ContentSetting setting
);
88 // content::NotificationObserver:
89 void Observe(int type
,
90 const content::NotificationSource
& source
,
91 const content::NotificationDetails
& details
) override
;
93 content::NotificationRegistrar registrar_
;
96 content::WebContents
* web_contents_
;
99 views::Label
* allowed_label_
;
100 views::Label
* blocked_label_
;
102 views::TreeView
* allowed_cookies_tree_
;
103 views::TreeView
* blocked_cookies_tree_
;
105 views::LabelButton
* block_allowed_button_
;
106 views::LabelButton
* delete_allowed_button_
;
107 views::LabelButton
* allow_blocked_button_
;
108 views::LabelButton
* for_session_blocked_button_
;
110 scoped_ptr
<CookiesTreeModel
> allowed_cookies_tree_model_
;
111 scoped_ptr
<CookiesTreeModel
> blocked_cookies_tree_model_
;
113 CookieInfoView
* cookie_info_view_
;
115 InfobarView
* infobar_
;
117 bool status_changed_
;
119 DISALLOW_COPY_AND_ASSIGN(CollectedCookiesViews
);
122 #endif // CHROME_BROWSER_UI_VIEWS_COLLECTED_COOKIES_VIEWS_H_