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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_COOKIES_VIEW_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_COOKIES_VIEW_HANDLER_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/browsing_data/cookies_tree_model.h"
11 #include "chrome/browser/ui/webui/options/options_ui.h"
13 class CookiesTreeModelUtil;
17 class CookiesViewHandler : public OptionsPageUIHandler,
18 public CookiesTreeModel::Observer {
21 virtual ~CookiesViewHandler();
23 // OptionsPageUIHandler implementation.
24 virtual void GetLocalizedValues(
25 base::DictionaryValue* localized_strings) OVERRIDE;
26 virtual void RegisterMessages() OVERRIDE;
28 // CookiesTreeModel::Observer implementation.
29 virtual void TreeNodesAdded(ui::TreeModel* model,
30 ui::TreeModelNode* parent,
33 virtual void TreeNodesRemoved(ui::TreeModel* model,
34 ui::TreeModelNode* parent,
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;
43 // Creates the CookiesTreeModel if neccessary.
44 void EnsureCookiesTreeModelCreated();
46 // Updates search filter for cookies tree model.
47 void UpdateSearchResults(const base::ListValue* args);
49 // Remove all sites data.
50 void RemoveAll(const base::ListValue* args);
52 // Remove selected sites data.
53 void Remove(const base::ListValue* args);
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);
59 // Get children nodes data and pass it to 'CookiesView.loadChildren' to
61 void SendChildren(const CookieTreeNode* parent);
63 // Reloads the CookiesTreeModel and passes the nodes to
64 // 'CookiesView.loadChildren' to update the WebUI.
65 void ReloadCookies(const base::ListValue* args);
67 // The Cookies Tree model
68 scoped_ptr<CookiesTreeModel> cookies_tree_model_;
70 // Flag to indicate whether there is a batch update in progress.
73 scoped_ptr<CookiesTreeModelUtil> model_util_;
75 DISALLOW_COPY_AND_ASSIGN(CookiesViewHandler);
78 } // namespace options
80 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_COOKIES_VIEW_HANDLER_H_