| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/webui/cookies_tree_model_adapter.h" | 5 #include "chrome/browser/ui/webui/cookies_tree_model_adapter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
| 7 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 9 #include "base/values.h" | 11 #include "base/values.h" |
| 10 #include "chrome/browser/ui/webui/cookies_tree_model_util.h" | 12 #include "chrome/browser/ui/webui/cookies_tree_model_util.h" |
| 11 #include "content/browser/webui/web_ui.h" | 13 #include "content/browser/webui/web_ui.h" |
| 12 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 14 | 16 |
| 15 namespace { | 17 namespace { |
| 16 | 18 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 31 | 33 |
| 32 CookiesTreeModelAdapter::~CookiesTreeModelAdapter() { | 34 CookiesTreeModelAdapter::~CookiesTreeModelAdapter() { |
| 33 if (model_) | 35 if (model_) |
| 34 model_->RemoveCookiesTreeObserver(this); | 36 model_->RemoveCookiesTreeObserver(this); |
| 35 } | 37 } |
| 36 | 38 |
| 37 void CookiesTreeModelAdapter::Init(WebUI* web_ui) { | 39 void CookiesTreeModelAdapter::Init(WebUI* web_ui) { |
| 38 web_ui_ = web_ui; | 40 web_ui_ = web_ui; |
| 39 | 41 |
| 40 web_ui_->RegisterMessageCallback(GetRequestChildrenCallbackName(this), | 42 web_ui_->RegisterMessageCallback(GetRequestChildrenCallbackName(this), |
| 41 NewCallback(this, &CookiesTreeModelAdapter::RequestChildren)); | 43 base::Bind(&CookiesTreeModelAdapter::RequestChildren, |
| 44 base::Unretained(this))); |
| 42 } | 45 } |
| 43 | 46 |
| 44 void CookiesTreeModelAdapter::Bind(const std::string& tree_id, | 47 void CookiesTreeModelAdapter::Bind(const std::string& tree_id, |
| 45 CookiesTreeModel* model) { | 48 CookiesTreeModel* model) { |
| 46 DCHECK(web_ui_); // We should have been initialized. | 49 DCHECK(web_ui_); // We should have been initialized. |
| 47 DCHECK(tree_id_.empty() && !model_); // No existing bindings. | 50 DCHECK(tree_id_.empty() && !model_); // No existing bindings. |
| 48 | 51 |
| 49 tree_id_ = tree_id; | 52 tree_id_ = tree_id; |
| 50 model_ = model; | 53 model_ = model; |
| 51 model_->AddCookiesTreeObserver(this); | 54 model_->AddCookiesTreeObserver(this); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 tree_id, *parend_id.get(), children); | 129 tree_id, *parend_id.get(), children); |
| 127 } | 130 } |
| 128 | 131 |
| 129 Value* CookiesTreeModelAdapter::GetTreeNodeId(CookieTreeNode* node) { | 132 Value* CookiesTreeModelAdapter::GetTreeNodeId(CookieTreeNode* node) { |
| 130 if (node == model_->GetRoot()) | 133 if (node == model_->GetRoot()) |
| 131 return Value::CreateNullValue(); | 134 return Value::CreateNullValue(); |
| 132 | 135 |
| 133 return Value::CreateStringValue( | 136 return Value::CreateStringValue( |
| 134 cookies_tree_model_util::GetTreeNodeId(node)); | 137 cookies_tree_model_util::GetTreeNodeId(node)); |
| 135 } | 138 } |
| OLD | NEW |