| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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_COOKIES_VIEW_H_ | |
| 6 #define CHROME_BROWSER_UI_VIEWS_OPTIONS_COOKIES_VIEW_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/task.h" | |
| 12 #include "chrome/browser/cookies_tree_model.h" | |
| 13 #include "net/base/cookie_monster.h" | |
| 14 #include "views/controls/button/button.h" | |
| 15 #include "views/controls/textfield/textfield_controller.h" | |
| 16 #include "views/controls/tree/tree_view.h" | |
| 17 #include "views/view.h" | |
| 18 #include "views/window/dialog_delegate.h" | |
| 19 #include "views/window/window.h" | |
| 20 | |
| 21 class AppCacheInfoView; | |
| 22 class CookieInfoView; | |
| 23 class CookiesTreeView; | |
| 24 class DatabaseInfoView; | |
| 25 class IndexedDBInfoView; | |
| 26 class LocalStorageInfoView; | |
| 27 class Profile; | |
| 28 class Timer; | |
| 29 | |
| 30 namespace ui { | |
| 31 class TreeModel; | |
| 32 class TreeModelNode; | |
| 33 } // namespace ui | |
| 34 | |
| 35 namespace views { | |
| 36 class Label; | |
| 37 class NativeButton; | |
| 38 } // namespace views | |
| 39 | |
| 40 class CookiesView : public CookiesTreeModel::Observer, | |
| 41 public views::View, | |
| 42 public views::DialogDelegate, | |
| 43 public views::ButtonListener, | |
| 44 public views::TreeViewController, | |
| 45 public views::TextfieldController { | |
| 46 public: | |
| 47 // Show the Cookies Window, creating one if necessary. | |
| 48 static void ShowCookiesWindow(Profile* profile); | |
| 49 | |
| 50 virtual ~CookiesView(); | |
| 51 | |
| 52 // Updates the display to show only the search results. | |
| 53 void UpdateSearchResults(); | |
| 54 | |
| 55 // Begin TreeModelObserver implementation. | |
| 56 virtual void TreeNodesAdded(ui::TreeModel* model, | |
| 57 ui::TreeModelNode* parent, | |
| 58 int start, | |
| 59 int count); | |
| 60 virtual void TreeNodesRemoved(ui::TreeModel* model, | |
| 61 ui::TreeModelNode* parent, | |
| 62 int start, | |
| 63 int count) {} | |
| 64 virtual void TreeNodeChanged(ui::TreeModel* model, ui::TreeModelNode* node) {} | |
| 65 // End TreeModelObserver implementation. | |
| 66 | |
| 67 // views::ButtonListener: | |
| 68 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | |
| 69 | |
| 70 // views::TreeViewController: | |
| 71 virtual void OnTreeViewSelectionChanged(views::TreeView* tree_view); | |
| 72 virtual void OnTreeViewKeyDown(ui::KeyboardCode keycode); | |
| 73 | |
| 74 // views::TextfieldController: | |
| 75 virtual void ContentsChanged(views::Textfield* sender, | |
| 76 const std::wstring& new_contents); | |
| 77 virtual bool HandleKeyEvent(views::Textfield* sender, | |
| 78 const views::KeyEvent& key); | |
| 79 | |
| 80 // views::WindowDelegate: | |
| 81 virtual int GetDialogButtons() const; | |
| 82 virtual views::View* GetInitiallyFocusedView(); | |
| 83 virtual bool CanResize() const; | |
| 84 virtual std::wstring GetWindowTitle() const; | |
| 85 virtual void WindowClosing(); | |
| 86 virtual views::View* GetContentsView(); | |
| 87 | |
| 88 // views::View: | |
| 89 virtual void Layout(); | |
| 90 virtual gfx::Size GetPreferredSize(); | |
| 91 | |
| 92 protected: | |
| 93 // views::View: | |
| 94 virtual void ViewHierarchyChanged(bool is_add, | |
| 95 views::View* parent, | |
| 96 views::View* child); | |
| 97 | |
| 98 private: | |
| 99 class InfoPanelView; | |
| 100 | |
| 101 // Use the static factory method to show. | |
| 102 explicit CookiesView(Profile* profile); | |
| 103 | |
| 104 // Initialize the dialog contents and layout. | |
| 105 void Init(); | |
| 106 | |
| 107 // Resets the display to what it would be if there were no search query. | |
| 108 void ResetSearchQuery(); | |
| 109 | |
| 110 // Update the UI when there are no cookies. | |
| 111 void UpdateForEmptyState(); | |
| 112 | |
| 113 // Enable or disable the remove and remove all buttons. | |
| 114 void UpdateRemoveButtonsState(); | |
| 115 | |
| 116 // Updates view to be visible inside detailed_info_view_; | |
| 117 void UpdateVisibleDetailedInfo(views::View* view); | |
| 118 | |
| 119 // Assorted dialog controls | |
| 120 views::Label* search_label_; | |
| 121 views::Textfield* search_field_; | |
| 122 views::NativeButton* clear_search_button_; | |
| 123 views::Label* description_label_; | |
| 124 CookiesTreeView* cookies_tree_; | |
| 125 InfoPanelView* info_panel_; | |
| 126 CookieInfoView* cookie_info_view_; | |
| 127 DatabaseInfoView* database_info_view_; | |
| 128 LocalStorageInfoView* local_storage_info_view_; | |
| 129 AppCacheInfoView* appcache_info_view_; | |
| 130 IndexedDBInfoView* indexed_db_info_view_; | |
| 131 views::NativeButton* remove_button_; | |
| 132 views::NativeButton* remove_all_button_; | |
| 133 | |
| 134 // The Cookies Tree model | |
| 135 scoped_ptr<CookiesTreeModel> cookies_tree_model_; | |
| 136 | |
| 137 // The Profile for which Cookies are displayed | |
| 138 Profile* profile_; | |
| 139 | |
| 140 // A factory to construct Runnable Methods so that we can be called back to | |
| 141 // re-evaluate the model after the search query string changes. | |
| 142 ScopedRunnableMethodFactory<CookiesView> search_update_factory_; | |
| 143 | |
| 144 // Our containing window. If this is non-NULL there is a visible Cookies | |
| 145 // window somewhere. | |
| 146 static views::Window* instance_; | |
| 147 | |
| 148 DISALLOW_COPY_AND_ASSIGN(CookiesView); | |
| 149 }; | |
| 150 | |
| 151 #endif // CHROME_BROWSER_UI_VIEWS_OPTIONS_COOKIES_VIEW_H_ | |
| OLD | NEW |