| 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/core/distiller_page.h" | 5 #include "components/dom_distiller/core/distiller_page.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 std::string script = ResourceBundle::GetSharedInstance() | 33 std::string script = ResourceBundle::GetSharedInstance() |
| 34 .GetRawDataResource(IDR_DISTILLER_JS) | 34 .GetRawDataResource(IDR_DISTILLER_JS) |
| 35 .as_string(); | 35 .as_string(); |
| 36 if (script.empty()) { | 36 if (script.empty()) { |
| 37 return ""; | 37 return ""; |
| 38 } | 38 } |
| 39 | 39 |
| 40 scoped_ptr<base::Value> options_value( | 40 scoped_ptr<base::Value> options_value( |
| 41 dom_distiller::proto::json::DomDistillerOptions::WriteToValue(options)); | 41 dom_distiller::proto::json::DomDistillerOptions::WriteToValue(options)); |
| 42 std::string options_json; | 42 std::string options_json; |
| 43 if (!base::JSONWriter::Write(options_value.get(), &options_json)) { | 43 if (!base::JSONWriter::Write(*options_value, &options_json)) { |
| 44 NOTREACHED(); | 44 NOTREACHED(); |
| 45 } | 45 } |
| 46 size_t options_offset = script.find(kOptionsPlaceholder); | 46 size_t options_offset = script.find(kOptionsPlaceholder); |
| 47 DCHECK_NE(std::string::npos, options_offset); | 47 DCHECK_NE(std::string::npos, options_offset); |
| 48 DCHECK_EQ(std::string::npos, | 48 DCHECK_EQ(std::string::npos, |
| 49 script.find(kOptionsPlaceholder, options_offset + 1)); | 49 script.find(kOptionsPlaceholder, options_offset + 1)); |
| 50 script = | 50 script = |
| 51 script.replace(options_offset, strlen(kOptionsPlaceholder), options_json); | 51 script.replace(options_offset, strlen(kOptionsPlaceholder), options_json); |
| 52 | 52 |
| 53 std::string stringify = stringify_output ? "true" : "false"; | 53 std::string stringify = stringify_output ? "true" : "false"; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 } | 155 } |
| 156 | 156 |
| 157 base::MessageLoop::current()->PostTask( | 157 base::MessageLoop::current()->PostTask( |
| 158 FROM_HERE, | 158 FROM_HERE, |
| 159 base::Bind(distiller_page_callback_, | 159 base::Bind(distiller_page_callback_, |
| 160 base::Passed(&distiller_result), | 160 base::Passed(&distiller_result), |
| 161 found_content)); | 161 found_content)); |
| 162 } | 162 } |
| 163 | 163 |
| 164 } // namespace dom_distiller | 164 } // namespace dom_distiller |
| OLD | NEW |