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_VIEWS_OPTIONS_SIMPLE_CONTENT_EXCEPTIONS_VIEW_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_OPTIONS_SIMPLE_CONTENT_EXCEPTIONS_VIEW_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 | |
11 #include "chrome/browser/remove_rows_table_model.h" | |
12 #include "chrome/common/content_settings.h" | |
13 #include "views/controls/button/button.h" | |
14 #include "views/controls/table/table_view_observer.h" | |
15 #include "views/window/dialog_delegate.h" | |
16 | |
17 namespace views { | |
18 class NativeButton; | |
19 class TableView; | |
20 } | |
21 | |
22 // SimpleContentExceptionsView is responsible for showing the user the set of | |
23 // site-specific permissions. The exceptions are shown in a table view by way | |
24 // of a RemoveRowsTableModel. The user can remove exceptions. | |
25 // Use the ShowExceptionsWindow method to create and show a | |
26 // SimpleContentExceptionsView, which is deleted when the window closes. | |
27 class SimpleContentExceptionsView : public views::View, | |
28 public views::ButtonListener, | |
29 public views::DialogDelegate, | |
30 public views::TableViewObserver { | |
31 public: | |
32 // Shows the Exceptions window. Takes ownership of |model|. | |
33 static void ShowExceptionsWindow(gfx::NativeWindow parent, | |
34 RemoveRowsTableModel* model, | |
35 int title_message_id); | |
36 | |
37 virtual ~SimpleContentExceptionsView(); | |
38 | |
39 // TableViewObserver overrides: | |
40 virtual void OnSelectionChanged(); | |
41 virtual void OnTableViewDelete(views::TableView* table_view); | |
42 | |
43 // views::ButtonListener implementation. | |
44 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | |
45 | |
46 // views::View overrides: | |
47 virtual void Layout(); | |
48 virtual gfx::Size GetPreferredSize(); | |
49 virtual void ViewHierarchyChanged(bool is_add, | |
50 views::View* parent, | |
51 views::View* child); | |
52 | |
53 // views::WindowDelegate implementation. | |
54 virtual int GetDialogButtons() const { | |
55 return MessageBoxFlags::DIALOGBUTTON_CANCEL; | |
56 } | |
57 virtual bool CanResize() const { return true; } | |
58 virtual std::wstring GetWindowTitle() const; | |
59 virtual views::View* GetContentsView() { return this; } | |
60 | |
61 private: | |
62 // Takes ownership of |model|. | |
63 explicit SimpleContentExceptionsView(RemoveRowsTableModel* model, | |
64 int title_message_id); | |
65 | |
66 void Init(); | |
67 | |
68 // Resets the enabled state of the buttons from the model. | |
69 void UpdateButtonState(); | |
70 | |
71 // Returns the set of selected rows. | |
72 RemoveRowsTableModel::Rows GetSelectedRows() const; | |
73 | |
74 // Removes the selected item. | |
75 void Remove(); | |
76 | |
77 // Removes all. | |
78 void RemoveAll(); | |
79 | |
80 // The model displayed in the table. | |
81 scoped_ptr<RemoveRowsTableModel> model_; | |
82 | |
83 views::TableView* table_; | |
84 | |
85 views::NativeButton* remove_button_; | |
86 views::NativeButton* remove_all_button_; | |
87 | |
88 // The message id of the window title. | |
89 int title_message_id_; | |
90 | |
91 DISALLOW_COPY_AND_ASSIGN(SimpleContentExceptionsView); | |
92 }; | |
93 | |
94 #endif // CHROME_BROWSER_UI_VIEWS_OPTIONS_SIMPLE_CONTENT_EXCEPTIONS_VIEW_H_ | |
95 | |
OLD | NEW |