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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewClient.java

Issue 2448363003: Add scheme whitelist for content intents (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.content.ActivityNotFoundException; 7 import android.content.ActivityNotFoundException;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.view.KeyEvent; 10 import android.view.KeyEvent;
11 import android.view.View.MeasureSpec; 11 import android.view.View.MeasureSpec;
12 12
13 import org.chromium.base.Log; 13 import org.chromium.base.Log;
14 14
15 /** 15 /**
16 * Main callback class used by ContentView. 16 * Main callback class used by ContentView.
17 * 17 *
18 * This contains the superset of callbacks required to implement the browser UI and the callbacks 18 * This contains the superset of callbacks required to implement the browser UI and the callbacks
19 * required to implement the WebView API. 19 * required to implement the WebView API.
20 * The memory and reference ownership of this class is unusual - see the .cc fi le and ContentView 20 * The memory and reference ownership of this class is unusual - see the .cc fi le and ContentView
21 * for more details. 21 * for more details.
22 * 22 *
23 * TODO(mkosiba): Rid this guy of default implementations. This class is used b y both WebView and 23 * TODO(mkosiba): Rid this guy of default implementations. This class is used b y both WebView and
24 * the browser and we don't want a the browser-specific default implementation to accidentally leak 24 * the browser and we don't want a the browser-specific default implementation to accidentally leak
25 * over to WebView. 25 * over to WebView.
26 */ 26 */
27 public class ContentViewClient { 27 public class ContentViewClient {
28 // Tag used for logging. 28 // Tag used for logging.
29 private static final String TAG = "cr.ContentViewClient"; 29 private static final String TAG = "cr_ContentViewClient";
Theresa 2016/10/26 17:08:09 Changed to pass a presubmit warning: Dot in log ta
30 30
31 // Default value to signal that the ContentView's size should not be overrid den. 31 // Default value to signal that the ContentView's size should not be overrid den.
32 private static final int UNSPECIFIED_MEASURE_SPEC = 32 private static final int UNSPECIFIED_MEASURE_SPEC =
33 MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); 33 MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
34 34
35 private static final String GEO_SCHEME = "geo";
36 private static final String TEL_SCHEME = "tel";
37 private static final String MAILTO_SCHEME = "mailto";
38
35 public void onUpdateTitle(String title) { 39 public void onUpdateTitle(String title) {
36 } 40 }
37 41
38 /** 42 /**
39 * Called whenever the background color of the page changes as notified by W ebKit. 43 * Called whenever the background color of the page changes as notified by W ebKit.
40 * @param color The new ARGB color of the page background. 44 * @param color The new ARGB color of the page background.
41 */ 45 */
42 public void onBackgroundColorChanged(int color) { 46 public void onBackgroundColorChanged(int color) {
43 } 47 }
44 48
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 141 }
138 142
139 /** 143 /**
140 * Called when a new content intent is requested to be started. 144 * Called when a new content intent is requested to be started.
141 */ 145 */
142 public void onStartContentIntent(Context context, String intentUrl, boolean isMainFrame) { 146 public void onStartContentIntent(Context context, String intentUrl, boolean isMainFrame) {
143 Intent intent; 147 Intent intent;
144 // Perform generic parsing of the URI to turn it into an Intent. 148 // Perform generic parsing of the URI to turn it into an Intent.
145 try { 149 try {
146 intent = Intent.parseUri(intentUrl, Intent.URI_INTENT_SCHEME); 150 intent = Intent.parseUri(intentUrl, Intent.URI_INTENT_SCHEME);
151
152 String scheme = intent.getScheme();
153 if (!scheme.equals(GEO_SCHEME) && !scheme.equals(TEL_SCHEME)
154 && !scheme.equals(MAILTO_SCHEME)) {
155 Log.w(TAG, "Invalid scheme for URI %s", intentUrl);
156 return;
157 }
158
147 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 159 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
148 } catch (Exception ex) { 160 } catch (Exception ex) {
149 Log.w(TAG, "Bad URI %s", intentUrl, ex); 161 Log.w(TAG, "Bad URI %s", intentUrl, ex);
150 return; 162 return;
151 } 163 }
152 164
153 try { 165 try {
154 context.startActivity(intent); 166 context.startActivity(intent);
155 } catch (ActivityNotFoundException ex) { 167 } catch (ActivityNotFoundException ex) {
156 Log.w(TAG, "No application can handle %s", intentUrl); 168 Log.w(TAG, "No application can handle %s", intentUrl);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 /** 252 /**
241 * Returns the bottom system window inset in pixels. The system window inset represents the area 253 * Returns the bottom system window inset in pixels. The system window inset represents the area
242 * of a full-screen window that is partially or fully obscured by the status bar, navigation 254 * of a full-screen window that is partially or fully obscured by the status bar, navigation
243 * bar, IME or other system windows. 255 * bar, IME or other system windows.
244 * @return The bottom system window inset. 256 * @return The bottom system window inset.
245 */ 257 */
246 public int getSystemWindowInsetBottom() { 258 public int getSystemWindowInsetBottom() {
247 return 0; 259 return 0;
248 } 260 }
249 } 261 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698