OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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 #include "components/dom_distiller/webui/dom_distiller_handler.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/values.h" |
| 9 #include "content/public/browser/web_ui.h" |
| 10 |
| 11 namespace dom_distiller { |
| 12 |
| 13 DomDistillerHandler::DomDistillerHandler() |
| 14 : weak_ptr_factory_(this) { |
| 15 } |
| 16 |
| 17 DomDistillerHandler::~DomDistillerHandler() {} |
| 18 |
| 19 void DomDistillerHandler::RegisterMessages() { |
| 20 web_ui()->RegisterMessageCallback( |
| 21 "requestEntries", |
| 22 base::Bind(&DomDistillerHandler::HandleRequestEntries, |
| 23 base::Unretained(this))); |
| 24 } |
| 25 |
| 26 void DomDistillerHandler::HandleRequestEntries(const ListValue* args) { |
| 27 base::ListValue entries; |
| 28 |
| 29 // Add some temporary placeholder entries. |
| 30 scoped_ptr<base::DictionaryValue> entry1(new base::DictionaryValue()); |
| 31 entry1->SetString("title", "Google"); |
| 32 entry1->SetString("url", "http://www.google.com/"); |
| 33 entries.Append(entry1.release()); |
| 34 scoped_ptr<base::DictionaryValue> entry2(new base::DictionaryValue()); |
| 35 entry2->SetString("title", "Chrome"); |
| 36 entry2->SetString("url", "http://www.chrome.com/"); |
| 37 entries.Append(entry2.release()); |
| 38 |
| 39 web_ui()->CallJavascriptFunction("onGotEntries", entries); |
| 40 } |
| 41 |
| 42 } // namespace dom_distiller |
OLD | NEW |