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