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