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 "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"
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 virtual base::string16
GetWindowTitle() const OVERRIDE
;
49 virtual int GetDialogButtons() const OVERRIDE
;
50 virtual base::string16
GetDialogButtonLabel(
51 ui::DialogButton button
) const OVERRIDE
;
52 virtual void DeleteDelegate() OVERRIDE
;
53 virtual bool Cancel() OVERRIDE
;
54 virtual ui::ModalType
GetModalType() const OVERRIDE
;
56 // views::ButtonListener:
57 virtual void ButtonPressed(views::Button
* sender
,
58 const ui::Event
& event
) OVERRIDE
;
60 // views::TabbedPaneListener:
61 virtual void TabSelectedAt(int index
) OVERRIDE
;
63 // views::TreeViewController:
64 virtual void OnTreeViewSelectionChanged(views::TreeView
* tree_view
) OVERRIDE
;
67 virtual gfx::Size
GetMinimumSize() const OVERRIDE
;
68 virtual void ViewHierarchyChanged(
69 const ViewHierarchyChangedDetails
& details
) OVERRIDE
;
72 virtual ~CollectedCookiesViews();
76 views::View
* CreateAllowedPane();
78 views::View
* CreateBlockedPane();
80 // Creates and returns a containing ScrollView around the given tree view.
81 views::View
* CreateScrollView(views::TreeView
* pane
);
83 void EnableControls();
85 void ShowCookieInfo();
87 void AddContentException(views::TreeView
* tree_view
, ContentSetting setting
);
89 // content::NotificationObserver:
90 virtual void Observe(int type
,
91 const content::NotificationSource
& source
,
92 const content::NotificationDetails
& details
) OVERRIDE
;
94 content::NotificationRegistrar registrar_
;
96 views::Widget
* window_
;
99 content::WebContents
* web_contents_
;
102 views::Label
* allowed_label_
;
103 views::Label
* blocked_label_
;
105 views::TreeView
* allowed_cookies_tree_
;
106 views::TreeView
* blocked_cookies_tree_
;
108 views::LabelButton
* block_allowed_button_
;
109 views::LabelButton
* delete_allowed_button_
;
110 views::LabelButton
* allow_blocked_button_
;
111 views::LabelButton
* for_session_blocked_button_
;
113 scoped_ptr
<CookiesTreeModel
> allowed_cookies_tree_model_
;
114 scoped_ptr
<CookiesTreeModel
> blocked_cookies_tree_model_
;
116 CookieInfoView
* cookie_info_view_
;
118 InfobarView
* infobar_
;
120 bool status_changed_
;
122 DISALLOW_COPY_AND_ASSIGN(CollectedCookiesViews
);
125 #endif // CHROME_BROWSER_UI_VIEWS_COLLECTED_COOKIES_VIEWS_H_