| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_COOKIES_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_OPTIONS_COOKIES_VIEW_H_ |
| 6 #define CHROME_BROWSER_VIEWS_OPTIONS_COOKIES_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_OPTIONS_COOKIES_VIEW_H_ |
| 7 | 7 |
| 8 #include <string> |
| 9 |
| 8 #include "base/task.h" | 10 #include "base/task.h" |
| 11 #include "net/base/cookie_monster.h" |
| 9 #include "views/controls/button/button.h" | 12 #include "views/controls/button/button.h" |
| 10 #include "views/controls/table/table_view_observer.h" | 13 #include "views/controls/tree/tree_view.h" |
| 11 #include "views/controls/textfield/textfield.h" | 14 #include "views/controls/textfield/textfield.h" |
| 12 #include "views/view.h" | 15 #include "views/view.h" |
| 13 #include "views/window/dialog_delegate.h" | 16 #include "views/window/dialog_delegate.h" |
| 14 #include "views/window/window.h" | 17 #include "views/window/window.h" |
| 15 | 18 |
| 16 namespace views { | 19 namespace views { |
| 17 | 20 |
| 18 class Label; | 21 class Label; |
| 19 class NativeButton; | 22 class NativeButton; |
| 20 class TableView; | |
| 21 | 23 |
| 22 } // namespace views | 24 } // namespace views |
| 23 | 25 |
| 26 |
| 24 class CookieInfoView; | 27 class CookieInfoView; |
| 25 class CookiesTableModel; | 28 class CookiesTreeModel; |
| 26 class CookiesTableView; | 29 class CookiesTreeView; |
| 27 class Profile; | 30 class Profile; |
| 28 class Timer; | 31 class Timer; |
| 29 | 32 |
| 33 |
| 30 class CookiesView : public views::View, | 34 class CookiesView : public views::View, |
| 31 public views::DialogDelegate, | 35 public views::DialogDelegate, |
| 32 public views::ButtonListener, | 36 public views::ButtonListener, |
| 33 public views::TableViewObserver, | 37 public views::TreeViewController { |
| 34 public views::Textfield::Controller { | |
| 35 public: | 38 public: |
| 36 // Show the Cookies Window, creating one if necessary. | 39 // Show the Cookies Window, creating one if necessary. |
| 37 static void ShowCookiesWindow(Profile* profile); | 40 static void ShowCookiesWindow(Profile* profile); |
| 38 | 41 |
| 39 virtual ~CookiesView(); | 42 virtual ~CookiesView(); |
| 40 | 43 |
| 41 // Updates the display to show only the search results. | |
| 42 void UpdateSearchResults(); | |
| 43 | |
| 44 // views::ButtonListener implementation. | 44 // views::ButtonListener implementation. |
| 45 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | 45 virtual void ButtonPressed(views::Button* sender, const views::Event& event); |
| 46 | 46 |
| 47 // views::TableViewObserver implementation. | 47 // views::TreeViewController implementation. |
| 48 virtual void OnSelectionChanged(); | 48 virtual void OnTreeViewSelectionChanged(views::TreeView* tree_view); |
| 49 | 49 |
| 50 // Invoked when the user presses the delete key. Deletes the selected | 50 // views::TreeViewController implementation. |
| 51 // cookies. | 51 virtual void OnTreeViewKeyDown(base::KeyboardCode keycode); |
| 52 virtual void OnTableViewDelete(views::TableView* table_view); | |
| 53 | |
| 54 // views::Textfield::Controller implementation. | |
| 55 virtual void ContentsChanged(views::Textfield* sender, | |
| 56 const std::wstring& new_contents); | |
| 57 virtual bool HandleKeystroke(views::Textfield* sender, | |
| 58 const views::Textfield::Keystroke& key); | |
| 59 | 52 |
| 60 // views::WindowDelegate implementation. | 53 // views::WindowDelegate implementation. |
| 61 virtual int GetDialogButtons() const { | 54 virtual int GetDialogButtons() const { |
| 62 return MessageBoxFlags::DIALOGBUTTON_CANCEL; | 55 return MessageBoxFlags::DIALOGBUTTON_CANCEL; |
| 63 } | 56 } |
| 64 virtual views::View* GetInitiallyFocusedView() { | 57 virtual views::View* GetInitiallyFocusedView(); |
| 65 return search_field_; | 58 |
| 66 } | |
| 67 virtual bool CanResize() const { return true; } | 59 virtual bool CanResize() const { return true; } |
| 68 virtual std::wstring GetWindowTitle() const; | 60 virtual std::wstring GetWindowTitle() const; |
| 69 virtual void WindowClosing(); | 61 virtual void WindowClosing(); |
| 70 virtual views::View* GetContentsView(); | 62 virtual views::View* GetContentsView(); |
| 71 | 63 |
| 72 // views::View overrides: | 64 // views::View overrides: |
| 73 virtual void Layout(); | 65 virtual void Layout(); |
| 74 virtual gfx::Size GetPreferredSize(); | 66 virtual gfx::Size GetPreferredSize(); |
| 75 | 67 |
| 76 protected: | 68 protected: |
| 77 // views::View overrides: | 69 // views::View overrides: |
| 78 virtual void ViewHierarchyChanged(bool is_add, | 70 virtual void ViewHierarchyChanged(bool is_add, |
| 79 views::View* parent, | 71 views::View* parent, |
| 80 views::View* child); | 72 views::View* child); |
| 81 | 73 |
| 82 private: | 74 private: |
| 83 // Use the static factory method to show. | 75 // Use the static factory method to show. |
| 84 explicit CookiesView(Profile* profile); | 76 explicit CookiesView(Profile* profile); |
| 85 | 77 |
| 86 // Initialize the dialog contents and layout. | 78 // Initialize the dialog contents and layout. |
| 87 void Init(); | 79 void Init(); |
| 88 | 80 |
| 89 // Resets the display to what it would be if there were no search query. | |
| 90 void ResetSearchQuery(); | |
| 91 | |
| 92 // Update the UI when there are no cookies. | 81 // Update the UI when there are no cookies. |
| 93 void UpdateForEmptyState(); | 82 void UpdateForEmptyState(); |
| 94 | 83 |
| 95 // Assorted dialog controls | 84 // Assorted dialog controls |
| 96 views::Label* search_label_; | |
| 97 views::Textfield* search_field_; | |
| 98 views::NativeButton* clear_search_button_; | |
| 99 views::Label* description_label_; | 85 views::Label* description_label_; |
| 100 CookiesTableView* cookies_table_; | 86 CookiesTreeView* cookies_tree_; |
| 101 CookieInfoView* info_view_; | 87 CookieInfoView* info_view_; |
| 102 views::NativeButton* remove_button_; | 88 views::NativeButton* remove_button_; |
| 103 views::NativeButton* remove_all_button_; | 89 views::NativeButton* remove_all_button_; |
| 104 | 90 |
| 105 // The Cookies Table model | 91 // The Cookies Tree model |
| 106 scoped_ptr<CookiesTableModel> cookies_table_model_; | 92 scoped_ptr<CookiesTreeModel> cookies_tree_model_; |
| 107 | 93 |
| 108 // The Profile for which Cookies are displayed | 94 // The Profile for which Cookies are displayed |
| 109 Profile* profile_; | 95 Profile* profile_; |
| 110 | 96 |
| 111 // A factory to construct Runnable Methods so that we can be called back to | |
| 112 // re-evaluate the model after the search query string changes. | |
| 113 ScopedRunnableMethodFactory<CookiesView> search_update_factory_; | |
| 114 | |
| 115 // Our containing window. If this is non-NULL there is a visible Cookies | 97 // Our containing window. If this is non-NULL there is a visible Cookies |
| 116 // window somewhere. | 98 // window somewhere. |
| 117 static views::Window* instance_; | 99 static views::Window* instance_; |
| 118 | 100 |
| 119 DISALLOW_COPY_AND_ASSIGN(CookiesView); | 101 DISALLOW_COPY_AND_ASSIGN(CookiesView); |
| 120 }; | 102 }; |
| 121 | 103 |
| 104 /////////////////////////////////////////////////////////////////////////////// |
| 105 // CookieInfoView |
| 106 // |
| 107 // Responsible for displaying a tabular grid of Cookie information. |
| 108 class CookieInfoView : public views::View { |
| 109 public: |
| 110 CookieInfoView(); |
| 111 virtual ~CookieInfoView(); |
| 112 |
| 113 // Update the display from the specified CookieNode. |
| 114 void SetCookie(const std::string& domain, |
| 115 const net::CookieMonster::CanonicalCookie& cookie_node); |
| 116 |
| 117 // Clears the cookie display to indicate that no or multiple cookies are |
| 118 // selected. |
| 119 void ClearCookieDisplay(); |
| 120 |
| 121 // Enables or disables the cookie proerty text fields. |
| 122 void EnableCookieDisplay(bool enabled); |
| 123 |
| 124 protected: |
| 125 // views::View overrides: |
| 126 virtual void ViewHierarchyChanged(bool is_add, |
| 127 views::View* parent, |
| 128 views::View* child); |
| 129 |
| 130 private: |
| 131 // Set up the view layout |
| 132 void Init(); |
| 133 |
| 134 // Individual property labels |
| 135 views::Label* name_label_; |
| 136 views::Textfield* name_value_field_; |
| 137 views::Label* content_label_; |
| 138 views::Textfield* content_value_field_; |
| 139 views::Label* domain_label_; |
| 140 views::Textfield* domain_value_field_; |
| 141 views::Label* path_label_; |
| 142 views::Textfield* path_value_field_; |
| 143 views::Label* send_for_label_; |
| 144 views::Textfield* send_for_value_field_; |
| 145 views::Label* created_label_; |
| 146 views::Textfield* created_value_field_; |
| 147 views::Label* expires_label_; |
| 148 views::Textfield* expires_value_field_; |
| 149 |
| 150 DISALLOW_COPY_AND_ASSIGN(CookieInfoView); |
| 151 }; |
| 152 |
| 122 #endif // CHROME_BROWSER_VIEWS_OPTIONS_COOKIES_VIEW_H_ | 153 #endif // CHROME_BROWSER_VIEWS_OPTIONS_COOKIES_VIEW_H_ |
| OLD | NEW |