collected_cookies_views.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
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 ConstrainedWindow; 18class CookieInfoView; 19class CookiesTreeModel; 20class InfobarView; 21 22namespace content { 23class WebContents; 24} 25 26namespace views { 27class Label; 28class TextButton; 29class TreeView; 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::View* GetContentsView() OVERRIDE; 54 55 // views::ButtonListener: 56 virtual void ButtonPressed(views::Button* sender, 57 const ui::Event& event) OVERRIDE; 58 59 // views::TabbedPaneListener: 60 virtual void TabSelectedAt(int index) OVERRIDE; 61 62 // views::TreeViewController: 63 virtual void OnTreeViewSelectionChanged(views::TreeView* tree_view) OVERRIDE; 64 65 // views::View: 66 virtual void ViewHierarchyChanged(bool is_add, 67 views::View* parent, 68 views::View* child) OVERRIDE; 69 70 private: 71 virtual ~CollectedCookiesViews(); 72 73 void Init(); 74 75 views::View* CreateAllowedPane(); 76 77 views::View* CreateBlockedPane(); 78 79 void EnableControls(); 80 81 void ShowCookieInfo(); 82 83 void AddContentException(views::TreeView* tree_view, ContentSetting setting); 84 85 // content::NotificationObserver: 86 virtual void Observe(int type, 87 const content::NotificationSource& source, 88 const content::NotificationDetails& details) OVERRIDE; 89 90 content::NotificationRegistrar registrar_; 91 92 ConstrainedWindow* window_; 93 94 // The web contents. 95 content::WebContents* web_contents_; 96 97 // Assorted views. 98 views::Label* allowed_label_; 99 views::Label* blocked_label_; 100 101 views::TreeView* allowed_cookies_tree_; 102 views::TreeView* blocked_cookies_tree_; 103 104 views::TextButton* block_allowed_button_; 105 views::TextButton* allow_blocked_button_; 106 views::TextButton* for_session_blocked_button_; 107 108 scoped_ptr<CookiesTreeModel> allowed_cookies_tree_model_; 109 scoped_ptr<CookiesTreeModel> blocked_cookies_tree_model_; 110 111 CookieInfoView* cookie_info_view_; 112 113 InfobarView* infobar_; 114 115 bool status_changed_; 116 117 DISALLOW_COPY_AND_ASSIGN(CollectedCookiesViews); 118}; 119 120#endif // CHROME_BROWSER_UI_VIEWS_COLLECTED_COOKIES_VIEWS_H_ 121