| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "components/dom_distiller/webui/dom_distiller_handler.h" | 5 #include "components/dom_distiller/webui/dom_distiller_handler.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 "viewUrl", | 58 "viewUrl", |
| 59 base::Bind(&DomDistillerHandler::HandleViewUrl, base::Unretained(this))); | 59 base::Bind(&DomDistillerHandler::HandleViewUrl, base::Unretained(this))); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void DomDistillerHandler::HandleAddArticle(const base::ListValue* args) { | 62 void DomDistillerHandler::HandleAddArticle(const base::ListValue* args) { |
| 63 std::string url; | 63 std::string url; |
| 64 args->GetString(0, &url); | 64 args->GetString(0, &url); |
| 65 GURL gurl(url); | 65 GURL gurl(url); |
| 66 if (gurl.is_valid()) { | 66 if (gurl.is_valid()) { |
| 67 service_->AddToList( | 67 service_->AddToList( |
| 68 gurl, | 68 gurl, service_->CreateDefaultDistillerPage( |
| 69 service_->CreateDefaultDistillerPage( | 69 web_ui()->GetWebContents()->GetContainerBounds().size()), |
| 70 web_ui()->GetWebContents()->GetContainerBounds().size()), | 70 base::Bind(&DomDistillerHandler::OnArticleAdded, |
| 71 base::Bind(base::Bind(&DomDistillerHandler::OnArticleAdded, | 71 base::Unretained(this))); |
| 72 base::Unretained(this)))); | |
| 73 } else { | 72 } else { |
| 74 web_ui()->CallJavascriptFunctionUnsafe("domDistiller.onArticleAddFailed"); | 73 web_ui()->CallJavascriptFunctionUnsafe("domDistiller.onArticleAddFailed"); |
| 75 } | 74 } |
| 76 } | 75 } |
| 77 | 76 |
| 78 void DomDistillerHandler::HandleViewUrl(const base::ListValue* args) { | 77 void DomDistillerHandler::HandleViewUrl(const base::ListValue* args) { |
| 79 GURL view_url = GetViewUrlFromArgs(article_scheme_, args); | 78 GURL view_url = GetViewUrlFromArgs(article_scheme_, args); |
| 80 if (view_url.is_valid()) { | 79 if (view_url.is_valid()) { |
| 81 web_ui()->GetWebContents()->GetController().LoadURL( | 80 web_ui()->GetWebContents()->GetController().LoadURL( |
| 82 view_url, | 81 view_url, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 void DomDistillerHandler::OnArticleAdded(bool article_available) { | 124 void DomDistillerHandler::OnArticleAdded(bool article_available) { |
| 126 // TODO(nyquist): Update this function. | 125 // TODO(nyquist): Update this function. |
| 127 if (article_available) { | 126 if (article_available) { |
| 128 HandleRequestEntries(NULL); | 127 HandleRequestEntries(NULL); |
| 129 } else { | 128 } else { |
| 130 web_ui()->CallJavascriptFunctionUnsafe("domDistiller.onArticleAddFailed"); | 129 web_ui()->CallJavascriptFunctionUnsafe("domDistiller.onArticleAddFailed"); |
| 131 } | 130 } |
| 132 } | 131 } |
| 133 | 132 |
| 134 } // namespace dom_distiller | 133 } // namespace dom_distiller |
| OLD | NEW |