OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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_GTK_OPTIONS_CONTENT_EXCEPTIONS_WINDOW_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_OPTIONS_CONTENT_EXCEPTIONS_WINDOW_GTK_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <gtk/gtk.h> |
| 10 |
| 11 #include <string> |
| 12 |
| 13 #include "app/gtk_signal.h" |
| 14 #include "base/scoped_ptr.h" |
| 15 #include "chrome/browser/content_exceptions_table_model.h" |
| 16 #include "chrome/browser/gtk/gtk_tree.h" |
| 17 #include "chrome/browser/gtk/options/content_exception_editor.h" |
| 18 #include "chrome/common/content_settings.h" |
| 19 #include "chrome/common/content_settings_types.h" |
| 20 |
| 21 class HostContentSettingsMap; |
| 22 |
| 23 // Dialog that lists each of the exceptions to the current content policy, and |
| 24 // has options for adding/editing/removing entries. Modal to parrent. |
| 25 class ContentExceptionsWindowGtk : public gtk_tree::TableAdapter::Delegate, |
| 26 public ContentExceptionEditor::Delegate { |
| 27 public: |
| 28 static void ShowExceptionsWindow(GtkWindow* window, |
| 29 HostContentSettingsMap* map, |
| 30 HostContentSettingsMap* off_the_record_map, |
| 31 ContentSettingsType content_type); |
| 32 |
| 33 ~ContentExceptionsWindowGtk(); |
| 34 |
| 35 // gtk_tree::TableAdapter::Delegate implementation: |
| 36 virtual void SetColumnValues(int row, GtkTreeIter* iter); |
| 37 |
| 38 // ContentExceptionEditor::Delegate implementation: |
| 39 virtual void AcceptExceptionEdit( |
| 40 const ContentSettingsPattern& pattern, |
| 41 ContentSetting setting, |
| 42 bool is_off_the_record, |
| 43 int index, |
| 44 bool is_new); |
| 45 |
| 46 private: |
| 47 // Column ids for |list_store_|. |
| 48 enum { |
| 49 COL_PATTERN, |
| 50 COL_ACTION, |
| 51 COL_OTR, |
| 52 COL_COUNT |
| 53 }; |
| 54 |
| 55 ContentExceptionsWindowGtk(GtkWindow* parent, |
| 56 HostContentSettingsMap* map, |
| 57 HostContentSettingsMap* off_the_record_map, |
| 58 ContentSettingsType type); |
| 59 |
| 60 // Updates which buttons are enabled. |
| 61 void UpdateButtonState(); |
| 62 |
| 63 // Callbacks for the buttons. |
| 64 CHROMEGTK_CALLBACK_0(ContentExceptionsWindowGtk, void, Add); |
| 65 CHROMEGTK_CALLBACK_0(ContentExceptionsWindowGtk, void, Edit); |
| 66 CHROMEGTK_CALLBACK_0(ContentExceptionsWindowGtk, void, Remove); |
| 67 CHROMEGTK_CALLBACK_0(ContentExceptionsWindowGtk, void, RemoveAll); |
| 68 |
| 69 // Returns the title of the window (changes based on what ContentSettingsType |
| 70 // was set to in the constructor). |
| 71 std::string GetWindowTitle() const; |
| 72 |
| 73 // Gets the selected indicies in the two list stores. Indicies are returned |
| 74 // in <list_store_, sort_list_store_> order. |
| 75 void GetSelectedModelIndices(std::set<std::pair<int, int> >* indices); |
| 76 |
| 77 // GTK Callbacks |
| 78 CHROMEGTK_CALLBACK_2(ContentExceptionsWindowGtk, void, |
| 79 OnTreeViewRowActivate, GtkTreePath*, GtkTreeViewColumn*); |
| 80 CHROMEGTK_CALLBACK_0(ContentExceptionsWindowGtk, void, OnWindowDestroy); |
| 81 CHROMEGTK_CALLBACK_0(ContentExceptionsWindowGtk, void, |
| 82 OnTreeSelectionChanged); |
| 83 |
| 84 // The list presented in |treeview_|. Separate from |list_store_|, the list |
| 85 // that backs |sort_model_|. This separation comes so the user can sort the |
| 86 // data on screen without changing the underlying |list_store_|. |
| 87 GtkTreeModel* sort_list_store_; |
| 88 |
| 89 // The backing to |sort_list_store_|. Doesn't change when sorted. |
| 90 GtkListStore* list_store_; |
| 91 |
| 92 // The C++, views-ish, cross-platform model class that actually contains the |
| 93 // gold standard data. |
| 94 scoped_ptr<ContentExceptionsTableModel> model_; |
| 95 |
| 96 // True if we also show exceptions from an OTR profile. |
| 97 bool allow_off_the_record_; |
| 98 |
| 99 // The adapter that ferries data back and forth between |model_| and |
| 100 // |list_store_| whenever either of them change. |
| 101 scoped_ptr<gtk_tree::TableAdapter> model_adapter_; |
| 102 |
| 103 // The exception window. |
| 104 GtkWidget* dialog_; |
| 105 |
| 106 // The treeview that presents the site/action pairs. |
| 107 GtkWidget* treeview_; |
| 108 |
| 109 // The current user selection from |treeview_|. |
| 110 GtkTreeSelection* treeview_selection_; |
| 111 |
| 112 // Buttons. |
| 113 GtkWidget* edit_button_; |
| 114 GtkWidget* remove_button_; |
| 115 GtkWidget* remove_all_button_; |
| 116 |
| 117 friend class ContentExceptionsWindowGtkUnittest; |
| 118 }; |
| 119 |
| 120 #endif // CHROME_BROWSER_UI_GTK_OPTIONS_CONTENT_EXCEPTIONS_WINDOW_GTK_H_ |
OLD | NEW |