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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 163 } |
164 | 164 |
165 base::MessageLoop::current()->PostTask( | 165 base::MessageLoop::current()->PostTask( |
166 FROM_HERE, | 166 FROM_HERE, |
167 base::Bind(distiller_page_callback_, | 167 base::Bind(distiller_page_callback_, |
168 base::Passed(&distiller_result), | 168 base::Passed(&distiller_result), |
169 found_content)); | 169 found_content)); |
170 } | 170 } |
171 | 171 |
172 } // namespace dom_distiller | 172 } // namespace dom_distiller |
OLD | NEW |