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 package org.chromium.chrome.browser; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.app.Dialog; | 7 import android.app.Dialog; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.DialogInterface; | 9 import android.content.DialogInterface; |
10 import android.graphics.Color; | 10 import android.graphics.Color; |
11 import android.graphics.drawable.ColorDrawable; | 11 import android.graphics.drawable.ColorDrawable; |
12 import android.net.Uri; | |
12 import android.text.Layout; | 13 import android.text.Layout; |
13 import android.text.Spannable; | 14 import android.text.Spannable; |
14 import android.text.SpannableStringBuilder; | 15 import android.text.SpannableStringBuilder; |
15 import android.text.style.ForegroundColorSpan; | 16 import android.text.style.ForegroundColorSpan; |
16 import android.text.style.StyleSpan; | 17 import android.text.style.StyleSpan; |
17 import android.util.AttributeSet; | 18 import android.util.AttributeSet; |
18 import android.view.Gravity; | 19 import android.view.Gravity; |
19 import android.view.LayoutInflater; | 20 import android.view.LayoutInflater; |
20 import android.view.View; | 21 import android.view.View; |
21 import android.view.View.OnClickListener; | 22 import android.view.View.OnClickListener; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 if (maxLines != mCurrentMaxLines) { | 158 if (maxLines != mCurrentMaxLines) { |
158 setMaxLines(maxLines); | 159 setMaxLines(maxLines); |
159 return true; | 160 return true; |
160 } | 161 } |
161 return false; | 162 return false; |
162 } | 163 } |
163 } | 164 } |
164 | 165 |
165 private static final int MAX_TABLET_DIALOG_WIDTH_DP = 400; | 166 private static final int MAX_TABLET_DIALOG_WIDTH_DP = 400; |
166 | 167 |
168 // The set of characters which have syntactic meaning in a URL. | |
Matt Giuca
2015/03/19 03:12:57
// This is the "reserved" character set from RFC 3
tsergeant
2015/03/24 05:33:47
Done.
Matt Giuca
2015/03/24 06:28:37
nit: I meant to append my extra comment, not repla
| |
169 private static final String URI_RESERVED_CHARACTERS = "!*'();:@&=+$,/?#[]%"; | |
170 | |
167 private final Context mContext; | 171 private final Context mContext; |
168 private final Profile mProfile; | 172 private final Profile mProfile; |
169 private final WebContents mWebContents; | 173 private final WebContents mWebContents; |
170 | 174 |
171 // A pointer to the C++ object for this UI. | 175 // A pointer to the C++ object for this UI. |
172 private final long mNativeWebsiteSettingsPopup; | 176 private final long mNativeWebsiteSettingsPopup; |
173 | 177 |
174 // The outer container, filled with the layout from website_settings.xml. | 178 // The outer container, filled with the layout from website_settings.xml. |
175 private final LinearLayout mContainer; | 179 private final LinearLayout mContainer; |
176 | 180 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { | 276 mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { |
273 @Override | 277 @Override |
274 public void onDismiss(DialogInterface dialog) { | 278 public void onDismiss(DialogInterface dialog) { |
275 assert mNativeWebsiteSettingsPopup != 0; | 279 assert mNativeWebsiteSettingsPopup != 0; |
276 webContentsObserver.destroy(); | 280 webContentsObserver.destroy(); |
277 nativeDestroy(mNativeWebsiteSettingsPopup); | 281 nativeDestroy(mNativeWebsiteSettingsPopup); |
278 } | 282 } |
279 }); | 283 }); |
280 | 284 |
281 // Work out the URL and connection message. | 285 // Work out the URL and connection message. |
282 mFullUrl = mWebContents.getVisibleUrl(); | 286 // Clean up the URL by percent-encoding anything which is not |
287 // allowed in a URL (spaces, ASCII control characters, non-ASCII Unicode ). | |
Matt Giuca
2015/03/19 03:12:57
You are also allowing the following: "<>\^`{|}
(Th
| |
288 mFullUrl = Uri.encode(mWebContents.getVisibleUrl(), URI_RESERVED_CHARACT ERS); | |
Matt Giuca
2015/03/19 03:12:57
Would it make sense to break this line out into a
tsergeant
2015/03/24 05:33:47
Done.
| |
289 | |
283 try { | 290 try { |
284 mParsedUrl = new URI(mFullUrl); | 291 mParsedUrl = new URI(mFullUrl); |
285 mIsInternalPage = UrlUtilities.isInternalScheme(mParsedUrl); | 292 mIsInternalPage = UrlUtilities.isInternalScheme(mParsedUrl); |
286 } catch (URISyntaxException e) { | 293 } catch (URISyntaxException e) { |
287 mParsedUrl = null; | 294 mParsedUrl = null; |
288 mIsInternalPage = false; | 295 mIsInternalPage = false; |
289 } | 296 } |
290 mSecurityLevel = ToolbarModel.getSecurityLevelForWebContents(mWebContent s); | 297 mSecurityLevel = ToolbarModel.getSecurityLevelForWebContents(mWebContent s); |
291 | 298 |
292 SpannableStringBuilder urlBuilder = new SpannableStringBuilder(mFullUrl) ; | 299 SpannableStringBuilder urlBuilder = new SpannableStringBuilder(mFullUrl) ; |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
536 new WebsiteSettingsPopup(context, profile, webContents); | 543 new WebsiteSettingsPopup(context, profile, webContents); |
537 } | 544 } |
538 | 545 |
539 private static native long nativeInit(WebsiteSettingsPopup popup, WebContent s webContents); | 546 private static native long nativeInit(WebsiteSettingsPopup popup, WebContent s webContents); |
540 | 547 |
541 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid); | 548 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid); |
542 | 549 |
543 private native void nativeOnPermissionSettingChanged(long nativeWebsiteSetti ngsPopupAndroid, | 550 private native void nativeOnPermissionSettingChanged(long nativeWebsiteSetti ngsPopupAndroid, |
544 int type, int setting); | 551 int type, int setting); |
545 } | 552 } |
OLD | NEW |