OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/options2/cookies_view_handler.h" | 5 #include "chrome/browser/ui/webui/options2/cookies_view_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 base::Unretained(this))); | 113 base::Unretained(this))); |
114 web_ui()->RegisterMessageCallback("removeCookie", | 114 web_ui()->RegisterMessageCallback("removeCookie", |
115 base::Bind(&CookiesViewHandler::Remove, | 115 base::Bind(&CookiesViewHandler::Remove, |
116 base::Unretained(this))); | 116 base::Unretained(this))); |
117 web_ui()->RegisterMessageCallback("loadCookie", | 117 web_ui()->RegisterMessageCallback("loadCookie", |
118 base::Bind(&CookiesViewHandler::LoadChildren, | 118 base::Bind(&CookiesViewHandler::LoadChildren, |
119 base::Unretained(this))); | 119 base::Unretained(this))); |
120 web_ui()->RegisterMessageCallback("setViewContext", | 120 web_ui()->RegisterMessageCallback("setViewContext", |
121 base::Bind(&CookiesViewHandler::SetViewContext, | 121 base::Bind(&CookiesViewHandler::SetViewContext, |
122 base::Unretained(this))); | 122 base::Unretained(this))); |
| 123 web_ui()->RegisterMessageCallback("reloadCookies", |
| 124 base::Bind(&CookiesViewHandler::ReloadCookies, |
| 125 base::Unretained(this))); |
123 } | 126 } |
124 | 127 |
125 void CookiesViewHandler::TreeNodesAdded(ui::TreeModel* model, | 128 void CookiesViewHandler::TreeNodesAdded(ui::TreeModel* model, |
126 ui::TreeModelNode* parent, | 129 ui::TreeModelNode* parent, |
127 int start, | 130 int start, |
128 int count) { | 131 int count) { |
129 // Skip if there is a batch update in progress. | 132 // Skip if there is a batch update in progress. |
130 if (batch_update_) | 133 if (batch_update_) |
131 return; | 134 return; |
132 | 135 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 web_ui()->CallJavascriptFunction( | 291 web_ui()->CallJavascriptFunction( |
289 GetCallback("loadChildren", GetTreeModel()), args); | 292 GetCallback("loadChildren", GetTreeModel()), args); |
290 } | 293 } |
291 | 294 |
292 void CookiesViewHandler::SetViewContext(const base::ListValue* args) { | 295 void CookiesViewHandler::SetViewContext(const base::ListValue* args) { |
293 bool app_context = false; | 296 bool app_context = false; |
294 if (args->GetBoolean(0, &app_context)) | 297 if (args->GetBoolean(0, &app_context)) |
295 app_context_ = app_context; | 298 app_context_ = app_context; |
296 } | 299 } |
297 | 300 |
| 301 void CookiesViewHandler::ReloadCookies(const base::ListValue* args) { |
| 302 cookies_tree_model_.reset(); |
| 303 app_cookies_tree_model_.reset(); |
| 304 |
| 305 EnsureCookiesTreeModelCreated(); |
| 306 } |
| 307 |
298 CookiesTreeModel* CookiesViewHandler::GetTreeModel() { | 308 CookiesTreeModel* CookiesViewHandler::GetTreeModel() { |
299 CookiesTreeModel* model = app_context_ ? | 309 CookiesTreeModel* model = app_context_ ? |
300 app_cookies_tree_model_.get() : cookies_tree_model_.get(); | 310 app_cookies_tree_model_.get() : cookies_tree_model_.get(); |
301 DCHECK(model); | 311 DCHECK(model); |
302 return model; | 312 return model; |
303 } | 313 } |
304 | 314 |
305 std::string CookiesViewHandler::GetCallback( | 315 std::string CookiesViewHandler::GetCallback( |
306 std::string method, CookiesTreeModel* model) { | 316 std::string method, CookiesTreeModel* model) { |
307 std::string callback("CookiesView"); | 317 std::string callback("CookiesView"); |
308 | 318 |
309 if (model == app_cookies_tree_model_) | 319 if (model == app_cookies_tree_model_) |
310 callback.append("App"); | 320 callback.append("App"); |
311 return callback.append(".").append(method); | 321 return callback.append(".").append(method); |
312 } | 322 } |
313 | 323 |
314 } // namespace options2 | 324 } // namespace options2 |
OLD | NEW |