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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_COOKIES_VIEW_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_COOKIES_VIEW_HANDLER_H_ 7 #pragma once 8 9 #include "base/memory/scoped_ptr.h" 10 #include "chrome/browser/cookies_tree_model.h" 11 #include "chrome/browser/ui/webui/options/options_ui.h" 12 13 class CookiesViewHandler : public OptionsPageUIHandler, 14 public CookiesTreeModel::Observer { 15 public: 16 CookiesViewHandler(); 17 virtual ~CookiesViewHandler(); 18 19 // OptionsPageUIHandler implementation. 20 virtual void GetLocalizedValues(DictionaryValue* localized_strings); 21 virtual void RegisterMessages(); 22 23 // ui::TreeModel::Observer implementation. 24 virtual void TreeNodesAdded(ui::TreeModel* model, 25 ui::TreeModelNode* parent, 26 int start, 27 int count); 28 virtual void TreeNodesRemoved(ui::TreeModel* model, 29 ui::TreeModelNode* parent, 30 int start, 31 int count); 32 virtual void TreeNodeChanged(ui::TreeModel* model, ui::TreeModelNode* node) {} 33 virtual void TreeModelBeginBatch(CookiesTreeModel* model); 34 virtual void TreeModelEndBatch(CookiesTreeModel* model); 35 36 private: 37 // Creates the CookiesTreeModel if neccessary. 38 void EnsureCookiesTreeModelCreated(); 39 40 // Updates search filter for cookies tree model. 41 void UpdateSearchResults(const ListValue* args); 42 43 // Remove all sites data. 44 void RemoveAll(const ListValue* args); 45 46 // Remove selected sites data. 47 void Remove(const ListValue* args); 48 49 // Get the tree node using the tree path info in |args| and call 50 // SendChildren to pass back children nodes data to WebUI. 51 void LoadChildren(const ListValue* args); 52 53 // Get children nodes data and pass it to 'CookiesView.loadChildren' to 54 // update the WebUI. 55 void SendChildren(CookieTreeNode* parent); 56 57 // The Cookies Tree model 58 scoped_ptr<CookiesTreeModel> cookies_tree_model_; 59 60 // Flag to indicate whether there is a batch update in progress. 61 bool batch_update_; 62 63 DISALLOW_COPY_AND_ASSIGN(CookiesViewHandler); 64 }; 65 66 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_COOKIES_VIEW_HANDLER_H_ 67