OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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_WEBUI_OPTIONS2_COOKIES_VIEW_HANDLER_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_COOKIES_VIEW_HANDLER_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "chrome/browser/cookies_tree_model.h" | |
11 #include "chrome/browser/ui/webui/options2/options_ui.h" | |
12 | |
13 class CookiesTreeModelUtil; | |
14 | |
15 namespace options { | |
16 | |
17 class CookiesViewHandler : public OptionsPageUIHandler, | |
18 public CookiesTreeModel::Observer { | |
19 public: | |
20 CookiesViewHandler(); | |
21 virtual ~CookiesViewHandler(); | |
22 | |
23 // OptionsPageUIHandler implementation. | |
24 virtual void GetLocalizedValues( | |
25 base::DictionaryValue* localized_strings) OVERRIDE; | |
26 virtual void RegisterMessages() OVERRIDE; | |
27 | |
28 // CookiesTreeModel::Observer implementation. | |
29 virtual void TreeNodesAdded(ui::TreeModel* model, | |
30 ui::TreeModelNode* parent, | |
31 int start, | |
32 int count) OVERRIDE; | |
33 virtual void TreeNodesRemoved(ui::TreeModel* model, | |
34 ui::TreeModelNode* parent, | |
35 int start, | |
36 int count) OVERRIDE; | |
37 virtual void TreeNodeChanged(ui::TreeModel* model, | |
38 ui::TreeModelNode* node) OVERRIDE {} | |
39 virtual void TreeModelBeginBatch(CookiesTreeModel* model) OVERRIDE; | |
40 virtual void TreeModelEndBatch(CookiesTreeModel* model) OVERRIDE; | |
41 | |
42 private: | |
43 // Creates the CookiesTreeModel if neccessary. | |
44 void EnsureCookiesTreeModelCreated(); | |
45 | |
46 // Updates search filter for cookies tree model. | |
47 void UpdateSearchResults(const base::ListValue* args); | |
48 | |
49 // Remove all sites data. | |
50 void RemoveAll(const base::ListValue* args); | |
51 | |
52 // Remove selected sites data. | |
53 void Remove(const base::ListValue* args); | |
54 | |
55 // Get the tree node using the tree path info in |args| and call | |
56 // SendChildren to pass back children nodes data to WebUI. | |
57 void LoadChildren(const base::ListValue* args); | |
58 | |
59 // Get children nodes data and pass it to 'CookiesView.loadChildren' to | |
60 // update the WebUI. | |
61 void SendChildren(const CookieTreeNode* parent); | |
62 | |
63 // Set the context in which this view is used - regular cookies window or | |
64 // the apps cookies window. | |
65 void SetViewContext(const base::ListValue* args); | |
66 | |
67 // Reloads the CookiesTreeModel and passes the nodes to | |
68 // 'CookiesView.loadChildren' to update the WebUI. | |
69 void ReloadCookies(const base::ListValue* args); | |
70 | |
71 // Return the proper callback string, depending on whether the model is | |
72 // in regular cookies mode or apps cookies mode. | |
73 std::string GetCallback(std::string method, CookiesTreeModel* model); | |
74 | |
75 // Return the proper tree model, depending on the context in which the | |
76 // view operates. | |
77 CookiesTreeModel* GetTreeModel(); | |
78 | |
79 // The Cookies Tree model | |
80 scoped_ptr<CookiesTreeModel> cookies_tree_model_; | |
81 scoped_ptr<CookiesTreeModel> app_cookies_tree_model_; | |
82 | |
83 // Flag to indicate whether there is a batch update in progress. | |
84 bool batch_update_; | |
85 | |
86 // A flag to indicate which view is active - the apps dialog or the regular | |
87 // cookies one. This will cause different JavaScript functions to be called. | |
88 bool app_context_; | |
89 | |
90 scoped_ptr<CookiesTreeModelUtil> model_util_; | |
91 | |
92 DISALLOW_COPY_AND_ASSIGN(CookiesViewHandler); | |
93 }; | |
94 | |
95 } // namespace options | |
96 | |
97 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_COOKIES_VIEW_HANDLER_H_ | |
OLD | NEW |