OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_VIEWS_OPTIONS_EXCEPTION_EDITOR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_OPTIONS_EXCEPTION_EDITOR_VIEW_H_ |
6 #define CHROME_BROWSER_VIEWS_OPTIONS_EXCEPTION_EDITOR_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_OPTIONS_EXCEPTION_EDITOR_VIEW_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "chrome/browser/content_setting_combo_model.h" | 10 #include "chrome/browser/content_setting_combo_model.h" |
11 #include "chrome/browser/host_content_settings_map.h" | 11 #include "chrome/browser/host_content_settings_map.h" |
12 #include "chrome/common/content_settings.h" | 12 #include "chrome/common/content_settings.h" |
13 #include "chrome/common/content_settings_types.h" | 13 #include "chrome/common/content_settings_types.h" |
14 #include "views/window/dialog_delegate.h" | 14 #include "views/window/dialog_delegate.h" |
| 15 #include "views/controls/button/checkbox.h" |
15 #include "views/controls/combobox/combobox.h" | 16 #include "views/controls/combobox/combobox.h" |
16 #include "views/controls/textfield/textfield.h" | 17 #include "views/controls/textfield/textfield.h" |
17 | 18 |
18 namespace views { | 19 namespace views { |
19 class ImageView; | 20 class ImageView; |
20 class Label; | 21 class Label; |
21 } | 22 } |
22 | 23 |
23 class ContentExceptionsTableModel; | 24 class ContentExceptionsTableModel; |
24 | 25 |
25 // ExceptionEditorView is responsible for showing a dialog that allows the user | 26 // ExceptionEditorView is responsible for showing a dialog that allows the user |
26 // to create or edit a single content exception. If the user clicks ok the | 27 // to create or edit a single content exception. If the user clicks ok the |
27 // delegate is notified and completes the edit. | 28 // delegate is notified and completes the edit. |
28 // | 29 // |
29 // To use an ExceptionEditorView create one and invoke Show on it. | 30 // To use an ExceptionEditorView create one and invoke Show on it. |
30 // ExceptionEditorView is deleted when the dialog closes. | 31 // ExceptionEditorView is deleted when the dialog closes. |
31 class ExceptionEditorView : public views::View, | 32 class ExceptionEditorView : public views::View, |
32 public views::Textfield::Controller, | 33 public views::Textfield::Controller, |
33 public views::DialogDelegate { | 34 public views::DialogDelegate { |
34 public: | 35 public: |
35 class Delegate { | 36 class Delegate { |
36 public: | 37 public: |
37 // Invoked when the user accepts the edit. | 38 // Invoked when the user accepts the edit. |
38 virtual void AcceptExceptionEdit( | 39 virtual void AcceptExceptionEdit( |
39 const HostContentSettingsMap::Pattern& pattern, | 40 const HostContentSettingsMap::Pattern& pattern, |
40 ContentSetting setting, | 41 ContentSetting setting, |
| 42 bool is_off_the_record, |
41 int index, | 43 int index, |
42 bool is_new) = 0; | 44 bool is_new) = 0; |
43 | 45 |
44 protected: | 46 protected: |
45 virtual ~Delegate() {} | 47 virtual ~Delegate() {} |
46 }; | 48 }; |
47 | 49 |
48 // Creates a new ExceptionEditorView with the supplied args. |index| is the | 50 // Creates a new ExceptionEditorView with the supplied args. |index| is the |
49 // index into the ContentExceptionsTableModel of the exception. This is not | 51 // index into the ContentExceptionsTableModel of the exception. This is not |
50 // used by ExceptionEditorView but instead passed to the delegate. | 52 // used by ExceptionEditorView but instead passed to the delegate. |
51 ExceptionEditorView(Delegate* delegate, | 53 ExceptionEditorView(Delegate* delegate, |
52 ContentExceptionsTableModel* model, | 54 ContentExceptionsTableModel* model, |
| 55 bool allow_off_the_record, |
53 int index, | 56 int index, |
54 const HostContentSettingsMap::Pattern& pattern, | 57 const HostContentSettingsMap::Pattern& pattern, |
55 ContentSetting setting); | 58 ContentSetting setting, |
| 59 bool is_off_the_record); |
56 virtual ~ExceptionEditorView() {} | 60 virtual ~ExceptionEditorView() {} |
57 | 61 |
58 void Show(gfx::NativeWindow parent); | 62 void Show(gfx::NativeWindow parent); |
59 | 63 |
60 // views::DialogDelegate overrides. | 64 // views::DialogDelegate overrides. |
61 virtual bool IsModal() const; | 65 virtual bool IsModal() const; |
62 virtual std::wstring GetWindowTitle() const; | 66 virtual std::wstring GetWindowTitle() const; |
63 virtual bool IsDialogButtonEnabled( | 67 virtual bool IsDialogButtonEnabled( |
64 MessageBoxFlags::DialogButton button) const; | 68 MessageBoxFlags::DialogButton button) const; |
65 virtual bool Cancel(); | 69 virtual bool Cancel(); |
66 virtual bool Accept(); | 70 virtual bool Accept(); |
67 virtual views::View* GetContentsView(); | 71 virtual views::View* GetContentsView(); |
68 | 72 |
69 // views::Textfield::Controller overrides. Updates whether the user can | 73 // views::Textfield::Controller overrides. Updates whether the user can |
70 // accept the dialog as well as updating image views showing whether value is | 74 // accept the dialog as well as updating image views showing whether value is |
71 // valid. | 75 // valid. |
72 virtual void ContentsChanged(views::Textfield* sender, | 76 virtual void ContentsChanged(views::Textfield* sender, |
73 const std::wstring& new_contents); | 77 const std::wstring& new_contents); |
74 virtual bool HandleKeystroke(views::Textfield* sender, | 78 virtual bool HandleKeystroke(views::Textfield* sender, |
75 const views::Textfield::Keystroke& key); | 79 const views::Textfield::Keystroke& key); |
76 | 80 |
77 private: | 81 private: |
78 void Init(); | 82 void Init(); |
79 | 83 |
80 views::Label* CreateLabel(int message_id); | 84 views::Label* CreateLabel(int message_id); |
81 | 85 |
82 // Returns true if we're adding a new item. | 86 // Returns true if we're adding a new item. |
83 bool is_new() const { return index_ == -1; } | 87 bool is_new() const { return index_ == -1; } |
84 | 88 |
85 bool IsPatternValid(const HostContentSettingsMap::Pattern& pattern) const; | 89 bool IsPatternValid(const HostContentSettingsMap::Pattern& pattern, |
| 90 bool is_off_the_record) const; |
86 | 91 |
87 void UpdateImageView(views::ImageView* image_view, bool is_valid); | 92 void UpdateImageView(views::ImageView* image_view, bool is_valid); |
88 | 93 |
89 Delegate* delegate_; | 94 Delegate* delegate_; |
90 ContentExceptionsTableModel* model_; | 95 ContentExceptionsTableModel* model_; |
91 ContentSettingComboModel cb_model_; | 96 ContentSettingComboModel cb_model_; |
92 | 97 |
93 // Index of the item being edited. If -1, indices this is a new entry. | 98 // Index of the item being edited. If -1, indices this is a new entry. |
| 99 const bool allow_off_the_record_; |
94 const int index_; | 100 const int index_; |
95 const HostContentSettingsMap::Pattern pattern_; | 101 const HostContentSettingsMap::Pattern pattern_; |
96 const ContentSetting setting_; | 102 const ContentSetting setting_; |
| 103 const bool is_off_the_record_; |
97 | 104 |
98 views::Textfield* pattern_tf_; | 105 views::Textfield* pattern_tf_; |
99 views::ImageView* pattern_iv_; | 106 views::ImageView* pattern_iv_; |
100 views::Combobox* action_cb_; | 107 views::Combobox* action_cb_; |
| 108 views::Checkbox* incognito_cb_; |
101 | 109 |
102 DISALLOW_COPY_AND_ASSIGN(ExceptionEditorView); | 110 DISALLOW_COPY_AND_ASSIGN(ExceptionEditorView); |
103 }; | 111 }; |
104 | 112 |
105 #endif // CHROME_BROWSER_VIEWS_OPTIONS_EXCEPTION_EDITOR_VIEW_H_ | 113 #endif // CHROME_BROWSER_VIEWS_OPTIONS_EXCEPTION_EDITOR_VIEW_H_ |
OLD | NEW |