| 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_COOKIES_TREE_MODEL_ADAPTER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_ADAPTER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_ADAPTER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_ADAPTER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "chrome/browser/cookies_tree_model.h" | 10 #include "chrome/browser/cookies_tree_model.h" |
| 11 | 11 |
| 12 class WebUI; |
| 13 |
| 14 namespace base { |
| 12 class ListValue; | 15 class ListValue; |
| 13 class Value; | 16 class Value; |
| 14 class WebUI; | 17 } |
| 15 | 18 |
| 16 // CookiesTreeModelAdapter binds a CookiesTreeModel with a JS tree. It observes | 19 // CookiesTreeModelAdapter binds a CookiesTreeModel with a JS tree. It observes |
| 17 // tree model changes and forwards them to JS tree. It also provides a | 20 // tree model changes and forwards them to JS tree. It also provides a |
| 18 // a callback for JS tree to load children of a specific node. | 21 // a callback for JS tree to load children of a specific node. |
| 19 class CookiesTreeModelAdapter : public CookiesTreeModel::Observer { | 22 class CookiesTreeModelAdapter : public CookiesTreeModel::Observer { |
| 20 public: | 23 public: |
| 21 CookiesTreeModelAdapter(); | 24 CookiesTreeModelAdapter(); |
| 22 virtual ~CookiesTreeModelAdapter(); | 25 virtual ~CookiesTreeModelAdapter(); |
| 23 | 26 |
| 24 // Initializes with given WebUI. | 27 // Initializes with given WebUI. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 38 ui::TreeModelNode* parent, | 41 ui::TreeModelNode* parent, |
| 39 int start, | 42 int start, |
| 40 int count) OVERRIDE; | 43 int count) OVERRIDE; |
| 41 virtual void TreeNodeChanged(ui::TreeModel* model, | 44 virtual void TreeNodeChanged(ui::TreeModel* model, |
| 42 ui::TreeModelNode* node) OVERRIDE {} | 45 ui::TreeModelNode* node) OVERRIDE {} |
| 43 virtual void TreeModelBeginBatch(CookiesTreeModel* model) OVERRIDE; | 46 virtual void TreeModelBeginBatch(CookiesTreeModel* model) OVERRIDE; |
| 44 virtual void TreeModelEndBatch(CookiesTreeModel* model) OVERRIDE; | 47 virtual void TreeModelEndBatch(CookiesTreeModel* model) OVERRIDE; |
| 45 | 48 |
| 46 // JS callback that gets the tree node using the tree path info in |args| and | 49 // JS callback that gets the tree node using the tree path info in |args| and |
| 47 // call SendChildren to pass back children nodes data to WebUI. | 50 // call SendChildren to pass back children nodes data to WebUI. |
| 48 void RequestChildren(const ListValue* args); | 51 void RequestChildren(const base::ListValue* args); |
| 49 | 52 |
| 50 // Get children nodes data and pass it to 'CookiesTree.loadChildren' to | 53 // Get children nodes data and pass it to 'CookiesTree.loadChildren' to |
| 51 // update the WebUI. | 54 // update the WebUI. |
| 52 void SendChildren(CookieTreeNode* parent); | 55 void SendChildren(CookieTreeNode* parent); |
| 53 | 56 |
| 54 // Helper function to get a Value* representing id of |node|. | 57 // Helper function to get a Value* representing id of |node|. |
| 55 // Caller needs to free the returned Value. | 58 // Caller needs to free the returned Value. |
| 56 Value* GetTreeNodeId(CookieTreeNode* node); | 59 base::Value* GetTreeNodeId(CookieTreeNode* node); |
| 57 | 60 |
| 58 // Hosting WebUI of the js tree. | 61 // Hosting WebUI of the js tree. |
| 59 WebUI* web_ui_; | 62 WebUI* web_ui_; |
| 60 | 63 |
| 61 // Id of JS tree that is managed by this handler. | 64 // Id of JS tree that is managed by this handler. |
| 62 std::string tree_id_; | 65 std::string tree_id_; |
| 63 | 66 |
| 64 // The Cookies Tree model. Note that we are not owning the model. | 67 // The Cookies Tree model. Note that we are not owning the model. |
| 65 CookiesTreeModel* model_; | 68 CookiesTreeModel* model_; |
| 66 | 69 |
| 67 // Flag to indicate whether there is a batch update in progress. | 70 // Flag to indicate whether there is a batch update in progress. |
| 68 bool batch_update_; | 71 bool batch_update_; |
| 69 | 72 |
| 70 DISALLOW_COPY_AND_ASSIGN(CookiesTreeModelAdapter); | 73 DISALLOW_COPY_AND_ASSIGN(CookiesTreeModelAdapter); |
| 71 }; | 74 }; |
| 72 | 75 |
| 73 #endif // CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_ADAPTER_H_ | 76 #endif // CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_ADAPTER_H_ |
| OLD | NEW |