collected_cookies_gtk.h revision dc0f95d653279beabeb9817299e2902918ba123e
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// This is the Gtk implementation of the collected Cookies dialog. 6 7#ifndef CHROME_BROWSER_UI_GTK_COLLECTED_COOKIES_GTK_H_ 8#define CHROME_BROWSER_UI_GTK_COLLECTED_COOKIES_GTK_H_ 9#pragma once 10 11#include <gtk/gtk.h> 12 13#include "base/scoped_ptr.h" 14#include "chrome/browser/ui/gtk/constrained_window_gtk.h" 15#include "chrome/browser/ui/gtk/gtk_tree.h" 16#include "chrome/common/content_settings.h" 17#include "content/common/notification_observer.h" 18#include "content/common/notification_registrar.h" 19#include "ui/base/gtk/gtk_signal.h" 20 21class CookiesTreeModel; 22 23// CollectedCookiesGtk is a dialog that displays the allowed and blocked 24// cookies of the current tab contents. To display the dialog, invoke 25// ShowCollectedCookiesDialog() on the delegate of the tab contents. 26 27class CollectedCookiesGtk : public ConstrainedDialogDelegate, 28 gtk_tree::TreeAdapter::Delegate, 29 NotificationObserver { 30 public: 31 CollectedCookiesGtk(GtkWindow* parent, TabContents* tab_contents); 32 33 // ConstrainedDialogDelegate methods. 34 virtual GtkWidget* GetWidgetRoot(); 35 virtual GtkWidget* GetFocusWidget(); 36 virtual void DeleteDelegate(); 37 38 private: 39 virtual ~CollectedCookiesGtk(); 40 41 // Initialize all widgets of this dialog. 42 void Init(); 43 44 // True if the selection contains at least one origin node. 45 bool SelectionContainsOriginNode(GtkTreeSelection* selection, 46 gtk_tree::TreeAdapter* adapter); 47 48 // Enable the allow/block buttons if at least one origin node is selected. 49 void EnableControls(); 50 51 // Add exceptions for all origin nodes within the selection. 52 void AddExceptions(GtkTreeSelection* selection, 53 gtk_tree::TreeAdapter* adapter, 54 ContentSetting setting); 55 56 // Notification Observer implementation. 57 virtual void Observe(NotificationType type, 58 const NotificationSource& source, 59 const NotificationDetails& details); 60 61 // Callbacks. 62 CHROMEGTK_CALLBACK_2(CollectedCookiesGtk, void, OnTreeViewRowExpanded, 63 GtkTreeIter*, GtkTreePath*); 64 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnTreeViewSelectionChange); 65 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnClose); 66 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnBlockAllowedButtonClicked); 67 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnAllowBlockedButtonClicked); 68 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, 69 OnForSessionBlockedButtonClicked); 70 71 NotificationRegistrar registrar_; 72 73 ConstrainedWindow* window_; 74 75 // Widgets of the dialog. 76 GtkWidget* dialog_; 77 78 GtkWidget* allowed_description_label_; 79 GtkWidget* blocked_description_label_; 80 81 GtkWidget* block_allowed_cookie_button_; 82 83 GtkWidget* allow_blocked_cookie_button_; 84 GtkWidget* for_session_blocked_cookie_button_; 85 GtkWidget* close_button_; 86 87 // The table listing the cookies. 88 GtkWidget* allowed_tree_; 89 GtkWidget* blocked_tree_; 90 91 GtkTreeSelection* allowed_selection_; 92 GtkTreeSelection* blocked_selection_; 93 94 // The infobar widget. 95 GtkWidget* infobar_; 96 GtkWidget* infobar_label_; 97 98 // The tab contents. 99 TabContents* tab_contents_; 100 101 // The Cookies Table model. 102 scoped_ptr<CookiesTreeModel> allowed_cookies_tree_model_; 103 scoped_ptr<CookiesTreeModel> blocked_cookies_tree_model_; 104 scoped_ptr<gtk_tree::TreeAdapter> allowed_cookies_tree_adapter_; 105 scoped_ptr<gtk_tree::TreeAdapter> blocked_cookies_tree_adapter_; 106 107 DISALLOW_COPY_AND_ASSIGN(CollectedCookiesGtk); 108}; 109 110#endif // CHROME_BROWSER_UI_GTK_COLLECTED_COOKIES_GTK_H_ 111