diff options
author | cevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-10 19:53:29 +0000 |
---|---|---|
committer | cevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-10 19:53:29 +0000 |
commit | 2a3348830f8b1e0f8682abd48e01f1843ff9e463 (patch) | |
tree | 8c933107c507cd21925c72351aa8e25e3fc93b75 | |
parent | 8846f4cb595fc2fb0e9b9771a646e5be6ab9ee0d (diff) | |
download | chromium_src-2a3348830f8b1e0f8682abd48e01f1843ff9e463.zip chromium_src-2a3348830f8b1e0f8682abd48e01f1843ff9e463.tar.gz chromium_src-2a3348830f8b1e0f8682abd48e01f1843ff9e463.tar.bz2 |
Merge 145197 - clean-up: Use an id instead of memory pointer string in webui.
Clean up cookie and cert webui to use id instead of memory pointer hex
string.
BUG=134519
TEST=Verify cookie and cert webui is not using memory pointer hex value as js object id.
Review URL: https://chromiumcodereview.appspot.com/10701029
TBR=xiyuan@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10703127
git-svn-id: svn://svn.chromium.org/chrome/branches/1180/src@145934 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 205 insertions, 151 deletions
diff --git a/chrome/browser/ui/webui/cookies_tree_model_util.cc b/chrome/browser/ui/webui/cookies_tree_model_util.cc index eb44d6e..318148d 100644 --- a/chrome/browser/ui/webui/cookies_tree_model_util.cc +++ b/chrome/browser/ui/webui/cookies_tree_model_util.cc @@ -4,7 +4,10 @@ #include "chrome/browser/ui/webui/cookies_tree_model_util.h" +#include <vector> + #include "base/i18n/time_formatting.h" +#include "base/memory/scoped_ptr.h" #include "base/string_number_conversions.h" #include "base/string_split.h" #include "base/string_util.h" @@ -16,56 +19,40 @@ namespace { -static const char kKeyId[] = "id"; -static const char kKeyTitle[] = "title"; -static const char kKeyIcon[] = "icon"; -static const char kKeyType[] = "type"; -static const char kKeyHasChildren[] = "hasChildren"; - -static const char kKeyName[] = "name"; -static const char kKeyContent[] = "content"; -static const char kKeyDomain[] = "domain"; -static const char kKeyPath[] = "path"; -static const char kKeySendFor[] = "sendfor"; -static const char kKeyAccessibleToScript[] = "accessibleToScript"; -static const char kKeyDesc[] = "desc"; -static const char kKeySize[] = "size"; -static const char kKeyOrigin[] = "origin"; -static const char kKeyManifest[] = "manifest"; -static const char kKeyServerId[] = "serverId"; - -static const char kKeyAccessed[] = "accessed"; -static const char kKeyCreated[] = "created"; -static const char kKeyExpires[] = "expires"; -static const char kKeyModified[] = "modified"; - -static const char kKeyPersistent[] = "persistent"; -static const char kKeyTemporary[] = "temporary"; - -static const char kKeyTotalUsage[] = "totalUsage"; -static const char kKeyTemporaryUsage[] = "temporaryUsage"; -static const char kKeyPersistentUsage[] = "persistentUsage"; -static const char kKeyPersistentQuota[] = "persistentQuota"; - -static const char kKeyCertType[] = "certType"; - -static const int64 kNegligibleUsage = 1024; // 1KiB - -// Encodes a pointer value into a hex string. -std::string PointerToHexString(const void* pointer) { - return base::HexEncode(&pointer, sizeof(pointer)); -} - -// Decodes a pointer from a hex string. -void* HexStringToPointer(const std::string& str) { - std::vector<uint8> buffer; - if (!base::HexStringToBytes(str, &buffer) || - buffer.size() != sizeof(void*)) { - return NULL; - } - - return *reinterpret_cast<void**>(&buffer[0]); -} +const char kKeyId[] = "id"; +const char kKeyTitle[] = "title"; +const char kKeyIcon[] = "icon"; +const char kKeyType[] = "type"; +const char kKeyHasChildren[] = "hasChildren"; + +const char kKeyName[] = "name"; +const char kKeyContent[] = "content"; +const char kKeyDomain[] = "domain"; +const char kKeyPath[] = "path"; +const char kKeySendFor[] = "sendfor"; +const char kKeyAccessibleToScript[] = "accessibleToScript"; +const char kKeyDesc[] = "desc"; +const char kKeySize[] = "size"; +const char kKeyOrigin[] = "origin"; +const char kKeyManifest[] = "manifest"; +const char kKeyServerId[] = "serverId"; + +const char kKeyAccessed[] = "accessed"; +const char kKeyCreated[] = "created"; +const char kKeyExpires[] = "expires"; +const char kKeyModified[] = "modified"; + +const char kKeyPersistent[] = "persistent"; +const char kKeyTemporary[] = "temporary"; + +const char kKeyTotalUsage[] = "totalUsage"; +const char kKeyTemporaryUsage[] = "temporaryUsage"; +const char kKeyPersistentUsage[] = "persistentUsage"; +const char kKeyPersistentQuota[] = "persistentQuota"; + +const char kKeyCertType[] = "certType"; + +const int64 kNegligibleUsage = 1024; // 1KiB std::string ClientCertTypeToString(net::SSLClientCertType type) { switch (type) { @@ -80,16 +67,27 @@ std::string ClientCertTypeToString(net::SSLClientCertType type) { } // namespace -namespace cookies_tree_model_util { +CookiesTreeModelUtil::CookiesTreeModelUtil() { +} + +CookiesTreeModelUtil::~CookiesTreeModelUtil() { +} -std::string GetTreeNodeId(CookieTreeNode* node) { - return PointerToHexString(node); +std::string CookiesTreeModelUtil::GetTreeNodeId(const CookieTreeNode* node) { + CookieTreeNodeMap::const_iterator iter = node_map_.find(node); + if (iter != node_map_.end()) + return base::IntToString(iter->second); + + int32 new_id = id_map_.Add(node); + node_map_[node] = new_id; + return base::IntToString(new_id); } -bool GetCookieTreeNodeDictionary(const CookieTreeNode& node, - DictionaryValue* dict) { +bool CookiesTreeModelUtil::GetCookieTreeNodeDictionary( + const CookieTreeNode& node, + base::DictionaryValue* dict) { // Use node's address as an id for WebUI to look it up. - dict->SetString(kKeyId, PointerToHexString(&node)); + dict->SetString(kKeyId, GetTreeNodeId(&node)); dict->SetString(kKeyTitle, node.GetTitle()); dict->SetBoolean(kKeyHasChildren, !node.empty()); @@ -261,32 +259,35 @@ bool GetCookieTreeNodeDictionary(const CookieTreeNode& node, return true; } -void GetChildNodeList(CookieTreeNode* parent, int start, int count, - ListValue* nodes) { +void CookiesTreeModelUtil::GetChildNodeList(const CookieTreeNode* parent, + int start, + int count, + base::ListValue* nodes) { for (int i = 0; i < count; ++i) { - DictionaryValue* dict = new DictionaryValue; - CookieTreeNode* child = parent->GetChild(start + i); - if (GetCookieTreeNodeDictionary(*child, dict)) - nodes->Append(dict); - else - delete dict; + scoped_ptr<base::DictionaryValue> dict(new DictionaryValue); + const CookieTreeNode* child = parent->GetChild(start + i); + if (GetCookieTreeNodeDictionary(*child, dict.get())) + nodes->Append(dict.release()); } } -CookieTreeNode* GetTreeNodeFromPath(CookieTreeNode* root, - const std::string& path) { +const CookieTreeNode* CookiesTreeModelUtil::GetTreeNodeFromPath( + const CookieTreeNode* root, + const std::string& path) { std::vector<std::string> node_ids; base::SplitString(path, ',', &node_ids); - CookieTreeNode* child = NULL; - CookieTreeNode* parent = root; + const CookieTreeNode* child = NULL; + const CookieTreeNode* parent = root; int child_index = -1; // Validate the tree path and get the node pointer. for (size_t i = 0; i < node_ids.size(); ++i) { - child = reinterpret_cast<CookieTreeNode*>( - HexStringToPointer(node_ids[i])); + int32 node_id = 0; + if (!base::StringToInt(node_ids[i], &node_id)) + break; + child = id_map_.Lookup(node_id); child_index = parent->GetIndexOf(child); if (child_index == -1) break; @@ -296,5 +297,3 @@ CookieTreeNode* GetTreeNodeFromPath(CookieTreeNode* root, return child_index >= 0 ? child : NULL; } - -} // namespace cookies_tree_model_util diff --git a/chrome/browser/ui/webui/cookies_tree_model_util.h b/chrome/browser/ui/webui/cookies_tree_model_util.h index 2331292..9b40e74 100644 --- a/chrome/browser/ui/webui/cookies_tree_model_util.h +++ b/chrome/browser/ui/webui/cookies_tree_model_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -6,8 +6,12 @@ #define CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_UTIL_H_ #pragma once +#include <map> #include <string> +#include "base/basictypes.h" +#include "base/id_map.h" + class CookieTreeNode; namespace base { @@ -15,24 +19,43 @@ class DictionaryValue; class ListValue; } -namespace cookies_tree_model_util { +class CookiesTreeModelUtil { + public: + CookiesTreeModelUtil(); + ~CookiesTreeModelUtil(); + + // Finds or creates an ID for given |node| and returns it as string. + std::string GetTreeNodeId(const CookieTreeNode* node); + + // Append the children nodes of |parent| in specified range to |nodes| list. + void GetChildNodeList(const CookieTreeNode* parent, + int start, + int count, + base::ListValue* nodes); + + // Gets tree node from |path| under |root|. |path| is comma separated list of + // ids. |id_map| translates ids into object pointers. Return NULL if |path| + // is not valid. + const CookieTreeNode* GetTreeNodeFromPath(const CookieTreeNode* root, + const std::string& path); -// Returns tree node id. Currently use hex string of node pointer as id. -std::string GetTreeNodeId(CookieTreeNode* node); + private: + typedef IDMap<const CookieTreeNode> CookiesTreeNodeIdMap; + typedef std::map<const CookieTreeNode*, int32> CookieTreeNodeMap; -// Populate given |dict| with cookie tree node properties. -// Returns false if the |node| does not need to be shown. -bool GetCookieTreeNodeDictionary(const CookieTreeNode& node, - base::DictionaryValue* dict); + // Populate given |dict| with cookie tree node properties. |id_map| maps + // a CookieTreeNode to an ID and creates a new ID if |node| is not in the + // maps. Returns false if the |node| does not need to be shown. + bool GetCookieTreeNodeDictionary(const CookieTreeNode& node, + base::DictionaryValue* dict); -// Append the children nodes of |parent| in specified range to |nodes| list. -void GetChildNodeList(CookieTreeNode* parent, int start, int count, - base::ListValue* nodes); + // IDMap to create unique ID and look up the object for an ID. + CookiesTreeNodeIdMap id_map_; -// Gets tree node from |path| under |root|. Return NULL if |path| is not valid. -CookieTreeNode* GetTreeNodeFromPath(CookieTreeNode* root, - const std::string& path); + // Reverse look up map to find the ID for a node. + CookieTreeNodeMap node_map_; -} // namespace cookies_tree_model_util + DISALLOW_COPY_AND_ASSIGN(CookiesTreeModelUtil); +}; #endif // CHROME_BROWSER_UI_WEBUI_COOKIES_TREE_MODEL_UTIL_H_ diff --git a/chrome/browser/ui/webui/options2/certificate_manager_handler2.cc b/chrome/browser/ui/webui/options2/certificate_manager_handler2.cc index 707ea97..45a7f63 100644 --- a/chrome/browser/ui/webui/options2/certificate_manager_handler2.cc +++ b/chrome/browser/ui/webui/options2/certificate_manager_handler2.cc @@ -4,9 +4,13 @@ #include "chrome/browser/ui/webui/options2/certificate_manager_handler2.h" +#include <algorithm> +#include <map> + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/file_util.h" // for FileAccessProvider +#include "base/id_map.h" #include "base/memory/scoped_vector.h" #include "base/safe_strerror_posix.h" #include "base/string_number_conversions.h" @@ -52,51 +56,10 @@ enum { IMPORT_CA_FILE_SELECTED, }; -// TODO(mattm): These are duplicated from cookies_view_handler.cc -// Encodes a pointer value into a hex string. -std::string PointerToHexString(const void* pointer) { - return base::HexEncode(&pointer, sizeof(pointer)); -} - -// Decodes a pointer from a hex string. -void* HexStringToPointer(const std::string& str) { - std::vector<uint8> buffer; - if (!base::HexStringToBytes(str, &buffer) || - buffer.size() != sizeof(void*)) { - return NULL; - } - - return *reinterpret_cast<void**>(&buffer[0]); -} - std::string OrgNameToId(const std::string& org) { return "org-" + org; } -std::string CertToId(const net::X509Certificate& cert) { - return "cert-" + PointerToHexString(&cert); -} - -net::X509Certificate* IdToCert(const std::string& id) { - if (!StartsWithASCII(id, "cert-", true)) - return NULL; - return reinterpret_cast<net::X509Certificate*>( - HexStringToPointer(id.substr(5))); -} - -net::X509Certificate* CallbackArgsToCert(const ListValue* args) { - std::string node_id; - if (!args->GetString(0, &node_id)){ - return NULL; - } - net::X509Certificate* cert = IdToCert(node_id); - if (!cert) { - NOTREACHED(); - return NULL; - } - return cert; -} - bool CallbackArgsToBool(const ListValue* args, int index, bool* result) { std::string string_value; if (!args->GetString(index, &string_value)) @@ -148,6 +111,63 @@ std::string NetErrorToString(int net_error) { namespace options2 { /////////////////////////////////////////////////////////////////////////////// +// CertIdMap + +class CertIdMap { + public: + CertIdMap() {} + ~CertIdMap() {} + + std::string CertToId(net::X509Certificate* cert); + net::X509Certificate* IdToCert(const std::string& id); + net::X509Certificate* CallbackArgsToCert(const base::ListValue* args); + + private: + typedef std::map<net::X509Certificate*, int32> CertMap; + + // Creates an ID for cert and looks up the cert for an ID. + IDMap<net::X509Certificate>id_map_; + + // Finds the ID for a cert. + CertMap cert_map_; + + DISALLOW_COPY_AND_ASSIGN(CertIdMap); +}; + +std::string CertIdMap::CertToId(net::X509Certificate* cert) { + CertMap::const_iterator iter = cert_map_.find(cert); + if (iter != cert_map_.end()) + return base::IntToString(iter->second); + + int32 new_id = id_map_.Add(cert); + cert_map_[cert] = new_id; + return base::IntToString(new_id); +} + +net::X509Certificate* CertIdMap::IdToCert(const std::string& id) { + int32 cert_id = 0; + if (!base::StringToInt(id, &cert_id)) + return NULL; + + return id_map_.Lookup(cert_id); +} + +net::X509Certificate* CertIdMap::CallbackArgsToCert( + const ListValue* args) { + std::string node_id; + if (!args->GetString(0, &node_id)) + return NULL; + + net::X509Certificate* cert = IdToCert(node_id); + if (!cert) { + NOTREACHED(); + return NULL; + } + + return cert; +} + +/////////////////////////////////////////////////////////////////////////////// // FileAccessProvider // TODO(mattm): Move to some shared location? @@ -254,7 +274,8 @@ void FileAccessProvider::DoWrite( CertificateManagerHandler::CertificateManagerHandler() : file_access_provider_(new FileAccessProvider()), - ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { + ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), + cert_id_map_(new CertIdMap) { certificate_manager_model_.reset(new CertificateManagerModel(this)); } @@ -490,14 +511,14 @@ void CertificateManagerHandler::FileSelectionCanceled(void* params) { } void CertificateManagerHandler::View(const ListValue* args) { - net::X509Certificate* cert = CallbackArgsToCert(args); + net::X509Certificate* cert = cert_id_map_->CallbackArgsToCert(args); if (!cert) return; ShowCertificateViewer(GetParentWindow(), cert); } void CertificateManagerHandler::GetCATrust(const ListValue* args) { - net::X509Certificate* cert = CallbackArgsToCert(args); + net::X509Certificate* cert = cert_id_map_->CallbackArgsToCert(args); if (!cert) { web_ui()->CallJavascriptFunction("CertificateEditCaTrustOverlay.dismiss"); return; @@ -517,7 +538,7 @@ void CertificateManagerHandler::GetCATrust(const ListValue* args) { } void CertificateManagerHandler::EditCATrust(const ListValue* args) { - net::X509Certificate* cert = CallbackArgsToCert(args); + net::X509Certificate* cert = cert_id_map_->CallbackArgsToCert(args); bool fail = !cert; bool trust_ssl = false; bool trust_email = false; @@ -551,7 +572,7 @@ void CertificateManagerHandler::EditServer(const ListValue* args) { } void CertificateManagerHandler::ExportPersonal(const ListValue* args) { - net::X509Certificate* cert = CallbackArgsToCert(args); + net::X509Certificate* cert = cert_id_map_->CallbackArgsToCert(args); if (!cert) return; @@ -584,7 +605,7 @@ void CertificateManagerHandler::ExportPersonalFileSelected( void CertificateManagerHandler::ExportPersonalPasswordSelected( const ListValue* args) { - if (!args->GetString(0, &password_)){ + if (!args->GetString(0, &password_)) { web_ui()->CallJavascriptFunction("CertificateRestoreOverlay.dismiss"); ImportExportCleanup(); return; @@ -640,7 +661,7 @@ void CertificateManagerHandler::ExportPersonalFileWritten(int write_errno, void CertificateManagerHandler::StartImportPersonal(const ListValue* args) { SelectFileDialog::FileTypeInfo file_type_info; - if (!args->GetBoolean(0, &use_hardware_backed_)){ + if (!args->GetBoolean(0, &use_hardware_backed_)) { // Unable to retrieve the hardware backed attribute from the args, // so bail. web_ui()->CallJavascriptFunction("CertificateRestoreOverlay.dismiss"); @@ -669,7 +690,7 @@ void CertificateManagerHandler::ImportPersonalFileSelected( void CertificateManagerHandler::ImportPersonalPasswordSelected( const ListValue* args) { - if (!args->GetString(0, &password_)){ + if (!args->GetString(0, &password_)) { web_ui()->CallJavascriptFunction("CertificateRestoreOverlay.dismiss"); ImportExportCleanup(); return; @@ -915,7 +936,7 @@ void CertificateManagerHandler::ImportCATrustSelected(const ListValue* args) { } void CertificateManagerHandler::Export(const ListValue* args) { - net::X509Certificate* cert = CallbackArgsToCert(args); + net::X509Certificate* cert = cert_id_map_->CallbackArgsToCert(args); if (!cert) return; ShowCertExportDialog(web_ui()->GetWebContents(), GetParentWindow(), @@ -923,7 +944,7 @@ void CertificateManagerHandler::Export(const ListValue* args) { } void CertificateManagerHandler::Delete(const ListValue* args) { - net::X509Certificate* cert = CallbackArgsToCert(args); + net::X509Certificate* cert = cert_id_map_->CallbackArgsToCert(args); if (!cert) return; bool result = certificate_manager_model_->Delete(cert); @@ -971,7 +992,7 @@ void CertificateManagerHandler::PopulateTree(const std::string& tab_name, org_cert_it != i->second.end(); ++org_cert_it) { DictionaryValue* cert_dict = new DictionaryValue; net::X509Certificate* cert = org_cert_it->get(); - cert_dict->SetString(kKeyId, CertToId(*cert)); + cert_dict->SetString(kKeyId, cert_id_map_->CertToId(cert)); cert_dict->SetString(kNameId, certificate_manager_model_->GetColumnText( *cert, CertificateManagerModel::COL_SUBJECT_NAME)); cert_dict->SetBoolean( diff --git a/chrome/browser/ui/webui/options2/certificate_manager_handler2.h b/chrome/browser/ui/webui/options2/certificate_manager_handler2.h index f3d5ffd1..4bc61cd 100644 --- a/chrome/browser/ui/webui/options2/certificate_manager_handler2.h +++ b/chrome/browser/ui/webui/options2/certificate_manager_handler2.h @@ -24,6 +24,7 @@ namespace options2 { +class CertIdMap; class FileAccessProvider; class CertificateManagerHandler : public OptionsPageUIHandler, @@ -177,6 +178,8 @@ class CertificateManagerHandler : public OptionsPageUIHandler, base::WeakPtrFactory<CertificateManagerHandler> weak_ptr_factory_; + scoped_ptr<CertIdMap> cert_id_map_; + DISALLOW_COPY_AND_ASSIGN(CertificateManagerHandler); }; diff --git a/chrome/browser/ui/webui/options2/cookies_view_handler2.cc b/chrome/browser/ui/webui/options2/cookies_view_handler2.cc index e37cbd3..e781371 100644 --- a/chrome/browser/ui/webui/options2/cookies_view_handler2.cc +++ b/chrome/browser/ui/webui/options2/cookies_view_handler2.cc @@ -4,6 +4,8 @@ #include "chrome/browser/ui/webui/options2/cookies_view_handler2.h" +#include <string> + #include "base/bind.h" #include "base/bind_helpers.h" #include "base/utf_string_conversions.h" @@ -24,7 +26,9 @@ namespace options2 { -CookiesViewHandler::CookiesViewHandler() : batch_update_(false) { +CookiesViewHandler::CookiesViewHandler() + : batch_update_(false), + model_util_(new CookiesTreeModelUtil) { } CookiesViewHandler::~CookiesViewHandler() { @@ -116,14 +120,14 @@ void CookiesViewHandler::TreeNodesAdded(ui::TreeModel* model, CookieTreeNode* parent_node = cookies_tree_model_->AsNode(parent); ListValue* children = new ListValue; - cookies_tree_model_util::GetChildNodeList(parent_node, start, count, + model_util_->GetChildNodeList(parent_node, start, count, children); ListValue args; args.Append(parent == cookies_tree_model_->GetRoot() ? Value::CreateNullValue() : Value::CreateStringValue( - cookies_tree_model_util::GetTreeNodeId(parent_node))); + model_util_->GetTreeNodeId(parent_node))); args.Append(Value::CreateIntegerValue(start)); args.Append(children); web_ui()->CallJavascriptFunction("CookiesView.onTreeItemAdded", args); @@ -140,7 +144,7 @@ void CookiesViewHandler::TreeNodesRemoved(ui::TreeModel* model, ListValue args; args.Append(parent == cookies_tree_model_->GetRoot() ? Value::CreateNullValue() : - Value::CreateStringValue(cookies_tree_model_util::GetTreeNodeId( + Value::CreateStringValue(model_util_->GetTreeNodeId( cookies_tree_model_->AsNode(parent)))); args.Append(Value::CreateIntegerValue(start)); args.Append(Value::CreateIntegerValue(count)); @@ -201,10 +205,10 @@ void CookiesViewHandler::Remove(const ListValue* args) { EnsureCookiesTreeModelCreated(); - CookieTreeNode* node = cookies_tree_model_util::GetTreeNodeFromPath( + const CookieTreeNode* node = model_util_->GetTreeNodeFromPath( cookies_tree_model_->GetRoot(), node_path); if (node) - cookies_tree_model_->DeleteCookieNode(node); + cookies_tree_model_->DeleteCookieNode(const_cast<CookieTreeNode*>(node)); } void CookiesViewHandler::LoadChildren(const ListValue* args) { @@ -215,21 +219,21 @@ void CookiesViewHandler::LoadChildren(const ListValue* args) { EnsureCookiesTreeModelCreated(); - CookieTreeNode* node = cookies_tree_model_util::GetTreeNodeFromPath( + const CookieTreeNode* node = model_util_->GetTreeNodeFromPath( cookies_tree_model_->GetRoot(), node_path); if (node) SendChildren(node); } -void CookiesViewHandler::SendChildren(CookieTreeNode* parent) { +void CookiesViewHandler::SendChildren(const CookieTreeNode* parent) { ListValue* children = new ListValue; - cookies_tree_model_util::GetChildNodeList(parent, 0, parent->child_count(), + model_util_->GetChildNodeList(parent, 0, parent->child_count(), children); ListValue args; args.Append(parent == cookies_tree_model_->GetRoot() ? Value::CreateNullValue() : - Value::CreateStringValue(cookies_tree_model_util::GetTreeNodeId(parent))); + Value::CreateStringValue(model_util_->GetTreeNodeId(parent))); args.Append(children); web_ui()->CallJavascriptFunction("CookiesView.loadChildren", args); diff --git a/chrome/browser/ui/webui/options2/cookies_view_handler2.h b/chrome/browser/ui/webui/options2/cookies_view_handler2.h index 19e4110..fe36cc5 100644 --- a/chrome/browser/ui/webui/options2/cookies_view_handler2.h +++ b/chrome/browser/ui/webui/options2/cookies_view_handler2.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -11,6 +11,8 @@ #include "chrome/browser/cookies_tree_model.h" #include "chrome/browser/ui/webui/options2/options_ui2.h" +class CookiesTreeModelUtil; + namespace options2 { class CookiesViewHandler : public OptionsPageUIHandler, @@ -57,7 +59,7 @@ class CookiesViewHandler : public OptionsPageUIHandler, // Get children nodes data and pass it to 'CookiesView.loadChildren' to // update the WebUI. - void SendChildren(CookieTreeNode* parent); + void SendChildren(const CookieTreeNode* parent); // The Cookies Tree model scoped_ptr<CookiesTreeModel> cookies_tree_model_; @@ -65,6 +67,8 @@ class CookiesViewHandler : public OptionsPageUIHandler, // Flag to indicate whether there is a batch update in progress. bool batch_update_; + scoped_ptr<CookiesTreeModelUtil> model_util_; + DISALLOW_COPY_AND_ASSIGN(CookiesViewHandler); }; |