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_EXCEPTION_EDITOR_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_OPTIONS_CONTENT_EXCEPTION_EDITOR_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <gtk/gtk.h> |
| 10 |
| 11 #include "app/gtk_signal.h" |
| 12 #include "chrome/browser/content_exceptions_table_model.h" |
| 13 #include "chrome/browser/content_setting_combo_model.h" |
| 14 #include "chrome/common/content_settings.h" |
| 15 #include "chrome/common/content_settings_types.h" |
| 16 |
| 17 // An editor which lets the user create or edit an individual exception to the |
| 18 // current content setting policy. (i.e. let www.google.com always show |
| 19 // images). Modal to parent. |
| 20 class ContentExceptionEditor { |
| 21 public: |
| 22 class Delegate { |
| 23 public: |
| 24 // Invoked when the user accepts the edit. |
| 25 virtual void AcceptExceptionEdit( |
| 26 const ContentSettingsPattern& pattern, |
| 27 ContentSetting setting, |
| 28 bool is_off_the_record, |
| 29 int index, |
| 30 bool is_new) = 0; |
| 31 |
| 32 protected: |
| 33 virtual ~Delegate() {} |
| 34 }; |
| 35 |
| 36 ContentExceptionEditor(GtkWindow* parent, |
| 37 Delegate* delegate, |
| 38 ContentExceptionsTableModel* model, |
| 39 bool allow_off_the_record, |
| 40 int index, |
| 41 const ContentSettingsPattern& pattern, |
| 42 ContentSetting setting, |
| 43 bool is_off_the_record); |
| 44 virtual ~ContentExceptionEditor() {} |
| 45 |
| 46 private: |
| 47 // Returns true if we're adding a new item. |
| 48 bool is_new() const { return index_ == -1; } |
| 49 |
| 50 bool IsPatternValid(const ContentSettingsPattern& pattern, |
| 51 bool is_off_the_record) const; |
| 52 |
| 53 void UpdateImage(GtkWidget* image, bool is_valid); |
| 54 |
| 55 // GTK callbacks |
| 56 CHROMEGTK_CALLBACK_0(ContentExceptionEditor, void, OnEntryChanged); |
| 57 CHROMEGTK_CALLBACK_1(ContentExceptionEditor, void, OnResponse, int); |
| 58 CHROMEGTK_CALLBACK_0(ContentExceptionEditor, void, OnWindowDestroy); |
| 59 |
| 60 Delegate* delegate_; |
| 61 ContentExceptionsTableModel* model_; |
| 62 |
| 63 // The model for Combobox widget. |
| 64 ContentSettingComboModel cb_model_; |
| 65 |
| 66 // Index of the item being edited. If -1, indicates this is a new entry. |
| 67 const int index_; |
| 68 const ContentSettingsPattern pattern_; |
| 69 const ContentSetting setting_; |
| 70 |
| 71 // UI widgets. |
| 72 GtkWidget* dialog_; |
| 73 GtkWidget* entry_; |
| 74 GtkWidget* pattern_image_; |
| 75 GtkWidget* action_combo_; |
| 76 GtkWidget* otr_checkbox_; |
| 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(ContentExceptionEditor); |
| 79 }; |
| 80 |
| 81 #endif // CHROME_BROWSER_UI_GTK_OPTIONS_CONTENT_EXCEPTION_EDITOR_H_ |
OLD | NEW |