Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Side by Side Diff: components/dom_distiller/ios/distiller_page_ios.mm

Issue 1004223002: Pass more information by argument to the dom_distiller script. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/javascript/JavaScript Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/dom_distiller/ios/distiller_page_ios.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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.
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
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
OLDNEW
« no previous file with comments | « components/dom_distiller/ios/distiller_page_ios.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698