Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(835)

Unified Diff: chrome/browser/ui/webui/cookies_tree_model_adapter.h

Issue 6644002: [ChromeOS] Implement collected cookies in webui. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync, address evan and oshima's comemnts #1 Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/cookies_tree_model_adapter.h
diff --git a/chrome/browser/ui/webui/cookies_tree_model_adapter.h b/chrome/browser/ui/webui/cookies_tree_model_adapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..f80312d9ed6b9e60acc876c76a6407874a748e3b
--- /dev/null
+++ b/chrome/browser/ui/webui/cookies_tree_model_adapter.h
@@ -0,0 +1,66 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_ADAPTER_H_
+#define CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_ADAPTER_H_
+#pragma once
+
+#include "chrome/browser/cookies_tree_model.h"
+
+class ListValue;
+class WebUI;
+
+// CookiesTreeModelAdapter binds a CookiesTreeModel with a JS tree. It observes
+// tree model changes and forwards them to JS tree. It also provides a
+// a callback for JS tree to load children of a specific node.
+class CookiesTreeModelAdapter : public CookiesTreeModel::Observer {
+ public:
+ CookiesTreeModelAdapter();
+ virtual ~CookiesTreeModelAdapter();
+
+ // Initializes with given WebUI.
+ void Init(WebUI* web_ui);
+
+ // Sets up the bindings between js tree and |model|.
+ // Note that this class does not take ownership of the model.
+ void Bind(const std::string& tree_id, CookiesTreeModel* model);
+
+ private:
+ // CookiesTreeModel::Observer implementation.
+ virtual void TreeNodesAdded(ui::TreeModel* model,
+ ui::TreeModelNode* parent,
+ int start,
+ int count);
+ virtual void TreeNodesRemoved(ui::TreeModel* model,
+ ui::TreeModelNode* parent,
+ int start,
+ int count);
+ virtual void TreeNodeChanged(ui::TreeModel* model, ui::TreeModelNode* node) {}
+ virtual void TreeModelBeginBatch(CookiesTreeModel* model);
+ virtual void TreeModelEndBatch(CookiesTreeModel* model);
+
+ // JS callback that gets the tree node using the tree path info in |args| and
+ // call SendChildren to pass back children nodes data to WebUI.
+ void LoadChildren(const ListValue* args);
+
+ // Get children nodes data and pass it to 'CookiesTree.loadChildren' to
+ // update the WebUI.
+ void SendChildren(CookieTreeNode* parent);
+
+ // Hosting WebUI of the js tree.
+ WebUI* web_ui_;
+
+ // Id of JS tree that is managed by this handler.
+ std::string tree_id_;
+
+ // The Cookies Tree model. Note that we are not owning the model.
+ CookiesTreeModel* model_;
+
+ // Flag to indicate whether there is a batch update in progress.
+ bool batch_update_;
+
+ DISALLOW_COPY_AND_ASSIGN(CookiesTreeModelAdapter);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_ADAPTER_H_

Powered by Google App Engine
This is Rietveld 408576698