OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_UI_WEBUI_OPTIONS2_COOKIES_VIEW_HANDLER2_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_COOKIES_VIEW_HANDLER2_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_COOKIES_VIEW_HANDLER2_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_COOKIES_VIEW_HANDLER2_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 virtual void TreeNodesRemoved(ui::TreeModel* model, | 32 virtual void TreeNodesRemoved(ui::TreeModel* model, |
33 ui::TreeModelNode* parent, | 33 ui::TreeModelNode* parent, |
34 int start, | 34 int start, |
35 int count) OVERRIDE; | 35 int count) OVERRIDE; |
36 virtual void TreeNodeChanged(ui::TreeModel* model, | 36 virtual void TreeNodeChanged(ui::TreeModel* model, |
37 ui::TreeModelNode* node) OVERRIDE {} | 37 ui::TreeModelNode* node) OVERRIDE {} |
38 virtual void TreeModelBeginBatch(CookiesTreeModel* model) OVERRIDE; | 38 virtual void TreeModelBeginBatch(CookiesTreeModel* model) OVERRIDE; |
39 virtual void TreeModelEndBatch(CookiesTreeModel* model) OVERRIDE; | 39 virtual void TreeModelEndBatch(CookiesTreeModel* model) OVERRIDE; |
40 | 40 |
41 private: | 41 private: |
| 42 enum CookiesViewCallback { |
| 43 onTreeItemAdded, |
| 44 onTreeItemRemoved, |
| 45 loadChildren |
| 46 }; |
| 47 |
42 // Creates the CookiesTreeModel if neccessary. | 48 // Creates the CookiesTreeModel if neccessary. |
43 void EnsureCookiesTreeModelCreated(); | 49 void EnsureCookiesTreeModelCreated(); |
44 | 50 |
45 // Updates search filter for cookies tree model. | 51 // Updates search filter for cookies tree model. |
46 void UpdateSearchResults(const base::ListValue* args); | 52 void UpdateSearchResults(const base::ListValue* args); |
47 | 53 |
48 // Remove all sites data. | 54 // Remove all sites data. |
49 void RemoveAll(const base::ListValue* args); | 55 void RemoveAll(const base::ListValue* args); |
50 | 56 |
51 // Remove selected sites data. | 57 // Remove selected sites data. |
52 void Remove(const base::ListValue* args); | 58 void Remove(const base::ListValue* args); |
53 | 59 |
54 // Get the tree node using the tree path info in |args| and call | 60 // Get the tree node using the tree path info in |args| and call |
55 // SendChildren to pass back children nodes data to WebUI. | 61 // SendChildren to pass back children nodes data to WebUI. |
56 void LoadChildren(const base::ListValue* args); | 62 void LoadChildren(const base::ListValue* args); |
57 | 63 |
58 // Get children nodes data and pass it to 'CookiesView.loadChildren' to | 64 // Get children nodes data and pass it to 'CookiesView.loadChildren' to |
59 // update the WebUI. | 65 // update the WebUI. |
60 void SendChildren(CookieTreeNode* parent); | 66 void SendChildren(CookieTreeNode* parent); |
61 | 67 |
| 68 // Set the context in which this view is used - regular cookies window or |
| 69 // the apps cookies window. |
| 70 void SetViewContext(const base::ListValue* args); |
| 71 |
| 72 // Return the proper callback string, depending on the context in which the |
| 73 // view operates. |
| 74 const std::string GetCallback(CookiesViewCallback callback); |
| 75 |
| 76 // Return the proper tree model, depending on the context in which the |
| 77 // view operates. |
| 78 CookiesTreeModel* GetTreeModel(); |
| 79 |
62 // The Cookies Tree model | 80 // The Cookies Tree model |
63 scoped_ptr<CookiesTreeModel> cookies_tree_model_; | 81 scoped_ptr<CookiesTreeModel> cookies_tree_model_; |
| 82 scoped_ptr<CookiesTreeModel> app_cookies_tree_model_; |
64 | 83 |
65 // Flag to indicate whether there is a batch update in progress. | 84 // Flag to indicate whether there is a batch update in progress. |
66 bool batch_update_; | 85 bool batch_update_; |
67 | 86 |
| 87 // Flag to indicate whether the view is used in the apps dialog context or |
| 88 // the regular cookies context. This will cause different callbacks into |
| 89 // JavaScript to be called. |
| 90 bool app_context_; |
| 91 |
68 DISALLOW_COPY_AND_ASSIGN(CookiesViewHandler); | 92 DISALLOW_COPY_AND_ASSIGN(CookiesViewHandler); |
69 }; | 93 }; |
70 | 94 |
71 } // namespace options2 | 95 } // namespace options2 |
72 | 96 |
73 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_COOKIES_VIEW_HANDLER2_H_ | 97 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_COOKIES_VIEW_HANDLER2_H_ |
OLD | NEW |