OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ios/distiller_page_ios.h" | 5 #include "components/dom_distiller/ios/distiller_page_ios.h" |
6 | 6 |
7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 | 44 |
45 #pragma mark - | 45 #pragma mark - |
46 | 46 |
47 DistillerPageIOS::DistillerPageIOS(web::BrowserState* browser_state) | 47 DistillerPageIOS::DistillerPageIOS(web::BrowserState* browser_state) |
48 : browser_state_(browser_state), weak_ptr_factory_(this) { | 48 : browser_state_(browser_state), weak_ptr_factory_(this) { |
49 } | 49 } |
50 | 50 |
51 DistillerPageIOS::~DistillerPageIOS() { | 51 DistillerPageIOS::~DistillerPageIOS() { |
52 } | 52 } |
53 | 53 |
54 bool DistillerPageIOS::StringifyOutput() { | |
55 // UIWebView requires javascript to return a single string value. | |
nyquist
2015/03/16 20:39:03
Nit: JavaScript
noyau (Ping after 24h)
2015/03/17 10:35:39
Done.
| |
56 return true; | |
57 } | |
58 | |
59 bool DistillerPageIOS::CreateNewContext() { | |
60 // UIWebView's JavaScript engine has a bug that causes crashes when | |
61 // creating a separate window object, so allow the script to run directly | |
62 // in the window until a better solution is created. | |
63 // TODO(kkhorimoto): investigate whether this is necessary for WKWebView. | |
64 return false; | |
65 } | |
66 | |
54 void DistillerPageIOS::DistillPageImpl(const GURL& url, | 67 void DistillerPageIOS::DistillPageImpl(const GURL& url, |
55 const std::string& script) { | 68 const std::string& script) { |
56 if (!url.is_valid() || !script.length()) | 69 if (!url.is_valid() || !script.length()) |
57 return; | 70 return; |
58 url_ = url; | 71 url_ = url; |
59 script_ = script; | 72 script_ = script; |
60 | 73 |
61 // Lazily create provider. | 74 // Lazily create provider. |
62 if (!provider_) { | 75 if (!provider_) { |
63 if (ios::GetWebControllerProviderFactory()) { | 76 if (ios::GetWebControllerProviderFactory()) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 base::JSONReader::Read(base::SysNSStringToUTF8(result))); | 115 base::JSONReader::Read(base::SysNSStringToUTF8(result))); |
103 if (dictionaryValue && | 116 if (dictionaryValue && |
104 dictionaryValue->IsType(base::Value::TYPE_DICTIONARY)) { | 117 dictionaryValue->IsType(base::Value::TYPE_DICTIONARY)) { |
105 resultValue = dictionaryValue.Pass(); | 118 resultValue = dictionaryValue.Pass(); |
106 } | 119 } |
107 } | 120 } |
108 OnDistillationDone(url_, resultValue.get()); | 121 OnDistillationDone(url_, resultValue.get()); |
109 } | 122 } |
110 | 123 |
111 } // namespace dom_distiller | 124 } // namespace dom_distiller |
OLD | NEW |