| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_CLEAR_BROWSING_DATA_H__ | 5 #ifndef CHROME_BROWSER_VIEWS_CLEAR_BROWSING_DATA_H__ |
| 6 #define CHROME_BROWSER_VIEWS_CLEAR_BROWSING_DATA_H__ | 6 #define CHROME_BROWSER_VIEWS_CLEAR_BROWSING_DATA_H__ |
| 7 | 7 |
| 8 #include "chrome/browser/browsing_data_remover.h" | 8 #include "chrome/browser/browsing_data_remover.h" |
| 9 #include "views/controls/button/button.h" | 9 #include "views/controls/button/button.h" |
| 10 #include "views/controls/combo_box.h" | 10 #include "views/controls/combobox/combobox.h" |
| 11 #include "views/controls/label.h" | 11 #include "views/controls/label.h" |
| 12 #include "views/view.h" | 12 #include "views/view.h" |
| 13 #include "views/window/dialog_delegate.h" | 13 #include "views/window/dialog_delegate.h" |
| 14 | 14 |
| 15 namespace views { | 15 namespace views { |
| 16 class Checkbox; | 16 class Checkbox; |
| 17 class Label; | 17 class Label; |
| 18 class Throbber; | 18 class Throbber; |
| 19 class Window; | 19 class Window; |
| 20 } | 20 } |
| 21 | 21 |
| 22 class Profile; | 22 class Profile; |
| 23 class MessageLoop; | 23 class MessageLoop; |
| 24 | 24 |
| 25 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
| 26 // | 26 // |
| 27 // The ClearBrowsingData class is responsible for drawing the UI controls of the | 27 // The ClearBrowsingData class is responsible for drawing the UI controls of the |
| 28 // dialog that allows the user to select what to delete (history, downloads, | 28 // dialog that allows the user to select what to delete (history, downloads, |
| 29 // etc). | 29 // etc). |
| 30 // | 30 // |
| 31 //////////////////////////////////////////////////////////////////////////////// | 31 //////////////////////////////////////////////////////////////////////////////// |
| 32 class ClearBrowsingDataView : public views::View, | 32 class ClearBrowsingDataView : public views::View, |
| 33 public views::DialogDelegate, | 33 public views::DialogDelegate, |
| 34 public views::ComboBox::Model, | |
| 35 public views::ButtonListener, | 34 public views::ButtonListener, |
| 36 public views::ComboBox::Listener, | 35 public views::Combobox::Model, |
| 36 public views::Combobox::Listener, |
| 37 public BrowsingDataRemover::Observer { | 37 public BrowsingDataRemover::Observer { |
| 38 public: | 38 public: |
| 39 explicit ClearBrowsingDataView(Profile* profile); | 39 explicit ClearBrowsingDataView(Profile* profile); |
| 40 virtual ~ClearBrowsingDataView(void); | 40 virtual ~ClearBrowsingDataView(void); |
| 41 | 41 |
| 42 // Initialize the controls on the dialog. | 42 // Initialize the controls on the dialog. |
| 43 void Init(); | 43 void Init(); |
| 44 | 44 |
| 45 // Overridden from views::View: | 45 // Overridden from views::View: |
| 46 virtual gfx::Size GetPreferredSize(); | 46 virtual gfx::Size GetPreferredSize(); |
| 47 virtual void Layout(); | 47 virtual void Layout(); |
| 48 void ViewHierarchyChanged(bool is_add, | 48 void ViewHierarchyChanged(bool is_add, |
| 49 views::View* parent, | 49 views::View* parent, |
| 50 views::View* child); | 50 views::View* child); |
| 51 | 51 |
| 52 // Overridden from views::DialogDelegate: | 52 // Overridden from views::DialogDelegate: |
| 53 virtual std::wstring GetDialogButtonLabel( | 53 virtual std::wstring GetDialogButtonLabel( |
| 54 MessageBoxFlags::DialogButton button) const; | 54 MessageBoxFlags::DialogButton button) const; |
| 55 virtual bool IsDialogButtonEnabled(MessageBoxFlags::DialogButton button) const
; | 55 virtual bool IsDialogButtonEnabled(MessageBoxFlags::DialogButton button) const
; |
| 56 virtual bool CanResize() const; | 56 virtual bool CanResize() const; |
| 57 virtual bool CanMaximize() const; | 57 virtual bool CanMaximize() const; |
| 58 virtual bool IsAlwaysOnTop() const; | 58 virtual bool IsAlwaysOnTop() const; |
| 59 virtual bool HasAlwaysOnTopMenu() const; | 59 virtual bool HasAlwaysOnTopMenu() const; |
| 60 virtual bool IsModal() const; | 60 virtual bool IsModal() const; |
| 61 virtual std::wstring GetWindowTitle() const; | 61 virtual std::wstring GetWindowTitle() const; |
| 62 virtual bool Accept(); | 62 virtual bool Accept(); |
| 63 virtual views::View* GetContentsView(); | 63 virtual views::View* GetContentsView(); |
| 64 | 64 |
| 65 // Overridden from views::ComboBox::Model: | 65 // Overridden from views::Combobox::Model: |
| 66 virtual int GetItemCount(views::ComboBox* source); | 66 virtual int GetItemCount(views::Combobox* source); |
| 67 virtual std::wstring GetItemAt(views::ComboBox* source, int index); | 67 virtual std::wstring GetItemAt(views::Combobox* source, int index); |
| 68 |
| 69 // Overridden from views::Combobox::Listener: |
| 70 virtual void ItemChanged(views::Combobox* sender, int prev_index, |
| 71 int new_index); |
| 68 | 72 |
| 69 // Overridden from views::ButtonListener: | 73 // Overridden from views::ButtonListener: |
| 70 virtual void ButtonPressed(views::Button* sender); | 74 virtual void ButtonPressed(views::Button* sender); |
| 71 | 75 |
| 72 // Overridden from views::ComboBox::Listener: | |
| 73 virtual void ItemChanged(views::ComboBox* sender, int prev_index, | |
| 74 int new_index); | |
| 75 | |
| 76 private: | 76 private: |
| 77 // Adds a new check-box as a child to the view. | 77 // Adds a new check-box as a child to the view. |
| 78 views::Checkbox* AddCheckbox(const std::wstring& text, bool checked); | 78 views::Checkbox* AddCheckbox(const std::wstring& text, bool checked); |
| 79 | 79 |
| 80 // Sets the controls on the UI to be enabled/disabled depending on whether we | 80 // Sets the controls on the UI to be enabled/disabled depending on whether we |
| 81 // have a delete operation in progress or not. | 81 // have a delete operation in progress or not. |
| 82 void UpdateControlEnabledState(); | 82 void UpdateControlEnabledState(); |
| 83 | 83 |
| 84 // Starts the process of deleting the browsing data depending on what the | 84 // Starts the process of deleting the browsing data depending on what the |
| 85 // user selected. | 85 // user selected. |
| 86 void OnDelete(); | 86 void OnDelete(); |
| 87 | 87 |
| 88 // Callback from BrowsingDataRemover. Closes the dialog. | 88 // Callback from BrowsingDataRemover. Closes the dialog. |
| 89 virtual void OnBrowsingDataRemoverDone(); | 89 virtual void OnBrowsingDataRemoverDone(); |
| 90 | 90 |
| 91 // UI elements we add to the parent view. | 91 // UI elements we add to the parent view. |
| 92 scoped_ptr<views::Throbber> throbber_; | 92 scoped_ptr<views::Throbber> throbber_; |
| 93 views::Label status_label_; | 93 views::Label status_label_; |
| 94 // Other UI elements. | 94 // Other UI elements. |
| 95 views::Label* delete_all_label_; | 95 views::Label* delete_all_label_; |
| 96 views::Checkbox* del_history_checkbox_; | 96 views::Checkbox* del_history_checkbox_; |
| 97 views::Checkbox* del_downloads_checkbox_; | 97 views::Checkbox* del_downloads_checkbox_; |
| 98 views::Checkbox* del_cache_checkbox_; | 98 views::Checkbox* del_cache_checkbox_; |
| 99 views::Checkbox* del_cookies_checkbox_; | 99 views::Checkbox* del_cookies_checkbox_; |
| 100 views::Checkbox* del_passwords_checkbox_; | 100 views::Checkbox* del_passwords_checkbox_; |
| 101 views::Checkbox* del_form_data_checkbox_; | 101 views::Checkbox* del_form_data_checkbox_; |
| 102 views::Label* time_period_label_; | 102 views::Label* time_period_label_; |
| 103 views::ComboBox* time_period_combobox_; | 103 views::Combobox* time_period_combobox_; |
| 104 | 104 |
| 105 // Used to signal enabled/disabled state for controls in the UI. | 105 // Used to signal enabled/disabled state for controls in the UI. |
| 106 bool delete_in_progress_; | 106 bool delete_in_progress_; |
| 107 | 107 |
| 108 Profile* profile_; | 108 Profile* profile_; |
| 109 | 109 |
| 110 // If non-null it means removal is in progress. BrowsingDataRemover takes care | 110 // If non-null it means removal is in progress. BrowsingDataRemover takes care |
| 111 // of deleting itself when done. | 111 // of deleting itself when done. |
| 112 BrowsingDataRemover* remover_; | 112 BrowsingDataRemover* remover_; |
| 113 | 113 |
| 114 DISALLOW_EVIL_CONSTRUCTORS(ClearBrowsingDataView); | 114 DISALLOW_EVIL_CONSTRUCTORS(ClearBrowsingDataView); |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 #endif // CHROME_BROWSER_VIEWS_CLEAR_BROWSING_DATA_H__ | 117 #endif // CHROME_BROWSER_VIEWS_CLEAR_BROWSING_DATA_H__ |
| OLD | NEW |