Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: libadblockplus-android/src/org/adblockplus/android/AndroidWebRequest.java

Issue 29351744: Issue 4399 - Add WebView inheritor with ad blocking (Closed)
Patch Set: supporting api 21 with referer and pre-21 with no referer Created Sept. 30, 2016, 1:28 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 connection.connect(); 85 connection.connect();
86 86
87 final ServerResponse response = new ServerResponse(); 87 final ServerResponse response = new ServerResponse();
88 response.setResponseStatus(connection.getResponseCode()); 88 response.setResponseStatus(connection.getResponseCode());
89 89
90 if (response.getResponseStatus() == 200) 90 if (response.getResponseStatus() == 200)
91 { 91 {
92 final BufferedReader reader = new BufferedReader(new InputStreamReader(c onnection.getInputStream(), "UTF-8")); 92 final BufferedReader reader = new BufferedReader(new InputStreamReader(c onnection.getInputStream(), "UTF-8"));
93 final StringBuilder sb = new StringBuilder(); 93 final StringBuilder sb = new StringBuilder();
94 94
95 if (!this.elemhideEnabled && isListedSubscriptionUrl(url)) 95 String line;
96 while ((line = reader.readLine()) != null)
96 { 97 {
97 Log.d(TAG, "Removing element hiding rules from: '" + url + "'"); 98 // We're only appending non-element-hiding filters here.
98 99 //
99 String line; 100 // See:
100 while ((line = reader.readLine()) != null) 101 // https://issues.adblockplus.org/ticket/303
102 //
103 // Follow-up issue for removing this hack:
104 // https://issues.adblockplus.org/ticket/1541
105 //
106 if (this.elemhideEnabled || !isListedSubscriptionUrl(url) || line.inde xOf('#') == -1)
101 { 107 {
102 // We're only appending non-element-hiding filters here. 108 sb.append(line);
103 // 109 sb.append('\n');
104 // See:
105 // https://issues.adblockplus.org/ticket/303
106 //
107 // Follow-up issue for removing this hack:
108 // https://issues.adblockplus.org/ticket/1541
109 //
110 if (line.indexOf('#') == -1)
111 {
112 sb.append(line);
113 sb.append('\n');
114 }
115 }
116 }
117 else
118 {
119 int character;
120
121 while ((character = reader.read()) != -1)
122 {
123 sb.append((char) character);
124 } 110 }
125 } 111 }
126 112
127 connection.disconnect(); 113 connection.disconnect();
128 114
129 response.setStatus(NsStatus.OK); 115 response.setStatus(NsStatus.OK);
130 response.setResponse(sb.toString()); 116 response.setResponse(sb.toString());
131 } 117 }
132 else 118 else
133 { 119 {
134 response.setStatus(NsStatus.ERROR_FAILURE); 120 response.setStatus(NsStatus.ERROR_FAILURE);
135 } 121 }
122 Log.d(TAG, "Downloading finished");
136 return response; 123 return response;
137 } 124 }
138 catch (final Throwable t) 125 catch (final Throwable t)
139 { 126 {
127 Log.e(TAG, "WebRequest failed", t);
140 throw new AdblockPlusException("WebRequest failed", t); 128 throw new AdblockPlusException("WebRequest failed", t);
141 } 129 }
142 } 130 }
143 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld