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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/WebsiteSettingsPopup.java

Issue 1124383007: Revert of Revert of Move SecurityLevel into a class of its own (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
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.animation.Animator; 7 import android.animation.Animator;
8 import android.animation.AnimatorListenerAdapter; 8 import android.animation.AnimatorListenerAdapter;
9 import android.animation.AnimatorSet; 9 import android.animation.AnimatorSet;
10 import android.animation.ObjectAnimator; 10 import android.animation.ObjectAnimator;
(...skipping 23 matching lines...) Expand all
34 import android.widget.ImageView; 34 import android.widget.ImageView;
35 import android.widget.LinearLayout; 35 import android.widget.LinearLayout;
36 import android.widget.ScrollView; 36 import android.widget.ScrollView;
37 import android.widget.Spinner; 37 import android.widget.Spinner;
38 import android.widget.TextView; 38 import android.widget.TextView;
39 39
40 import org.chromium.base.CalledByNative; 40 import org.chromium.base.CalledByNative;
41 import org.chromium.chrome.R; 41 import org.chromium.chrome.R;
42 import org.chromium.chrome.browser.omnibox.OmniboxUrlEmphasizer; 42 import org.chromium.chrome.browser.omnibox.OmniboxUrlEmphasizer;
43 import org.chromium.chrome.browser.profiles.Profile; 43 import org.chromium.chrome.browser.profiles.Profile;
44 import org.chromium.chrome.browser.ssl.ConnectionSecurityHelper;
45 import org.chromium.chrome.browser.ssl.ConnectionSecurityHelperSecurityLevel;
44 import org.chromium.chrome.browser.toolbar.ToolbarModel; 46 import org.chromium.chrome.browser.toolbar.ToolbarModel;
45 import org.chromium.chrome.browser.ui.toolbar.ToolbarModelSecurityLevel;
46 import org.chromium.content_public.browser.WebContents; 47 import org.chromium.content_public.browser.WebContents;
47 import org.chromium.content_public.browser.WebContentsObserver; 48 import org.chromium.content_public.browser.WebContentsObserver;
48 import org.chromium.ui.base.Clipboard; 49 import org.chromium.ui.base.Clipboard;
49 import org.chromium.ui.base.DeviceFormFactor; 50 import org.chromium.ui.base.DeviceFormFactor;
50 import org.chromium.ui.interpolators.BakedBezierInterpolator; 51 import org.chromium.ui.interpolators.BakedBezierInterpolator;
51 52
52 import java.net.URI; 53 import java.net.URI;
53 import java.net.URISyntaxException; 54 import java.net.URISyntaxException;
54 import java.util.ArrayList; 55 import java.util.ArrayList;
55 import java.util.Arrays; 56 import java.util.Arrays;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 private String mFullUrl; 237 private String mFullUrl;
237 238
238 // A parsed version of mFullUrl. Is null if the URL is invalid/cannot be 239 // A parsed version of mFullUrl. Is null if the URL is invalid/cannot be
239 // parsed. 240 // parsed.
240 private URI mParsedUrl; 241 private URI mParsedUrl;
241 242
242 // Whether or not this page is an internal chrome page (e.g. the 243 // Whether or not this page is an internal chrome page (e.g. the
243 // chrome://settings page). 244 // chrome://settings page).
244 private boolean mIsInternalPage; 245 private boolean mIsInternalPage;
245 246
246 // The security level of the page (a valid ToolbarModelSecurityLevel). 247 // The security level of the page (a valid ConnectionSecurityHelperSecurityL evel).
247 private int mSecurityLevel; 248 private int mSecurityLevel;
248 249
249 // Whether the security level of the page was deprecated due to SHA-1. 250 // Whether the security level of the page was deprecated due to SHA-1.
250 private boolean mDeprecatedSHA1Present; 251 private boolean mDeprecatedSHA1Present;
251 252
252 /** 253 /**
253 * Creates the WebsiteSettingsPopup, but does not display it. Also initializ es the corresponding 254 * Creates the WebsiteSettingsPopup, but does not display it. Also initializ es the corresponding
254 * C++ object and saves a pointer to it. 255 * C++ object and saves a pointer to it.
255 * 256 *
256 * @param context Context which is used for launching a dialog. 257 * @param context Context which is used for launching a dialog.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 369
369 // Work out the URL and connection message. 370 // Work out the URL and connection message.
370 mFullUrl = mWebContents.getVisibleUrl(); 371 mFullUrl = mWebContents.getVisibleUrl();
371 try { 372 try {
372 mParsedUrl = new URI(mFullUrl); 373 mParsedUrl = new URI(mFullUrl);
373 mIsInternalPage = UrlUtilities.isInternalScheme(mParsedUrl); 374 mIsInternalPage = UrlUtilities.isInternalScheme(mParsedUrl);
374 } catch (URISyntaxException e) { 375 } catch (URISyntaxException e) {
375 mParsedUrl = null; 376 mParsedUrl = null;
376 mIsInternalPage = false; 377 mIsInternalPage = false;
377 } 378 }
378 mSecurityLevel = ToolbarModel.getSecurityLevelForWebContents(mWebContent s); 379 mSecurityLevel = ConnectionSecurityHelper.getSecurityLevelForWebContents (mWebContents);
379 mDeprecatedSHA1Present = ToolbarModel.isDeprecatedSHA1Present(mWebConten ts); 380 mDeprecatedSHA1Present = ToolbarModel.isDeprecatedSHA1Present(mWebConten ts);
380 381
381 SpannableStringBuilder urlBuilder = new SpannableStringBuilder(mFullUrl) ; 382 SpannableStringBuilder urlBuilder = new SpannableStringBuilder(mFullUrl) ;
382 OmniboxUrlEmphasizer.emphasizeUrl(urlBuilder, mContext.getResources(), m Profile, 383 OmniboxUrlEmphasizer.emphasizeUrl(urlBuilder, mContext.getResources(), m Profile,
383 mSecurityLevel, mIsInternalPage, true); 384 mSecurityLevel, mIsInternalPage, true);
384 mUrlTitle.setText(urlBuilder); 385 mUrlTitle.setText(urlBuilder);
385 386
386 // Set the URL connection message now, and the URL after layout (so it 387 // Set the URL connection message now, and the URL after layout (so it
387 // can calculate its ideal height). 388 // can calculate its ideal height).
388 mUrlConnectionMessage.setText(getUrlConnectionMessage()); 389 mUrlConnectionMessage.setText(getUrlConnectionMessage());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 default: 427 default:
427 assert false : "Icon requested for invalid permission: " + permi ssion; 428 assert false : "Icon requested for invalid permission: " + permi ssion;
428 return -1; 429 return -1;
429 } 430 }
430 } 431 }
431 432
432 /** 433 /**
433 * Gets the message to display in the connection message box for the given s ecurity level. Does 434 * Gets the message to display in the connection message box for the given s ecurity level. Does
434 * not apply to SECURITY_ERROR pages, since these have their own coloured/fo rmatted message. 435 * not apply to SECURITY_ERROR pages, since these have their own coloured/fo rmatted message.
435 * 436 *
436 * @param toolbarModelSecurityLevel A valid ToolbarModelSecurityLevel, which is the security 437 * @param securityLevel A valid ConnectionSecurityHelperSecurityLevel, which is the security
437 * level of the page. 438 * level of the page.
438 * @param isInternalPage Whether or not this page is an internal chrome page (e.g. the 439 * @param isInternalPage Whether or not this page is an internal chrome page (e.g. the
439 * chrome://settings page). 440 * chrome://settings page).
440 * @return The ID of the message to display in the connection message box. 441 * @return The ID of the message to display in the connection message box.
441 */ 442 */
442 private int getConnectionMessageId(int toolbarModelSecurityLevel, boolean is InternalPage) { 443 private int getConnectionMessageId(int securityLevel, boolean isInternalPage ) {
443 if (isInternalPage) return R.string.page_info_connection_internal_page; 444 if (isInternalPage) return R.string.page_info_connection_internal_page;
444 445
445 switch (toolbarModelSecurityLevel) { 446 switch (securityLevel) {
446 case ToolbarModelSecurityLevel.NONE: 447 case ConnectionSecurityHelperSecurityLevel.NONE:
447 return R.string.page_info_connection_http; 448 return R.string.page_info_connection_http;
448 case ToolbarModelSecurityLevel.SECURE: 449 case ConnectionSecurityHelperSecurityLevel.SECURE:
449 case ToolbarModelSecurityLevel.EV_SECURE: 450 case ConnectionSecurityHelperSecurityLevel.EV_SECURE:
450 return R.string.page_info_connection_https; 451 return R.string.page_info_connection_https;
451 case ToolbarModelSecurityLevel.SECURITY_WARNING: 452 case ConnectionSecurityHelperSecurityLevel.SECURITY_WARNING:
452 case ToolbarModelSecurityLevel.SECURITY_POLICY_WARNING: 453 case ConnectionSecurityHelperSecurityLevel.SECURITY_POLICY_WARNING:
453 return R.string.page_info_connection_mixed; 454 return R.string.page_info_connection_mixed;
454 default: 455 default:
455 assert false : "Invalid security level specified: " + toolbarMod elSecurityLevel; 456 assert false : "Invalid security level specified: " + securityLe vel;
456 return R.string.page_info_connection_http; 457 return R.string.page_info_connection_http;
457 } 458 }
458 } 459 }
459 460
460 /** 461 /**
461 * Whether to show a 'Details' link to the connection info popup. The link i s only shown for 462 * Whether to show a 'Details' link to the connection info popup. The link i s only shown for
462 * HTTPS connections. 463 * HTTPS connections.
463 */ 464 */
464 private boolean isConnectionDetailsLinkVisible() { 465 private boolean isConnectionDetailsLinkVisible() {
465 return !mIsInternalPage && mSecurityLevel != ToolbarModelSecurityLevel.N ONE; 466 return !mIsInternalPage && mSecurityLevel != ConnectionSecurityHelperSec urityLevel.NONE;
466 } 467 }
467 468
468 /** 469 /**
469 * Gets the styled connection message to display below the URL. 470 * Gets the styled connection message to display below the URL.
470 */ 471 */
471 private Spannable getUrlConnectionMessage() { 472 private Spannable getUrlConnectionMessage() {
472 // Display the appropriate connection message. 473 // Display the appropriate connection message.
473 SpannableStringBuilder messageBuilder = new SpannableStringBuilder(); 474 SpannableStringBuilder messageBuilder = new SpannableStringBuilder();
474 if (mDeprecatedSHA1Present) { 475 if (mDeprecatedSHA1Present) {
475 messageBuilder.append( 476 messageBuilder.append(
476 mContext.getResources().getString(R.string.page_info_connect ion_sha1)); 477 mContext.getResources().getString(R.string.page_info_connect ion_sha1));
477 } else if (mSecurityLevel != ToolbarModelSecurityLevel.SECURITY_ERROR) { 478 } else if (mSecurityLevel != ConnectionSecurityHelperSecurityLevel.SECUR ITY_ERROR) {
478 messageBuilder.append(mContext.getResources().getString( 479 messageBuilder.append(mContext.getResources().getString(
479 getConnectionMessageId(mSecurityLevel, mIsInternalPage))); 480 getConnectionMessageId(mSecurityLevel, mIsInternalPage)));
480 } else { 481 } else {
481 String originToDisplay; 482 String originToDisplay;
482 try { 483 try {
483 URI parsedUrl = new URI(mFullUrl); 484 URI parsedUrl = new URI(mFullUrl);
484 originToDisplay = UrlUtilities.getOriginForDisplay(parsedUrl, fa lse); 485 originToDisplay = UrlUtilities.getOriginForDisplay(parsedUrl, fa lse);
485 } catch (URISyntaxException e) { 486 } catch (URISyntaxException e) {
486 // The URL is invalid - just display the full URL. 487 // The URL is invalid - just display the full URL.
487 originToDisplay = mFullUrl; 488 originToDisplay = mFullUrl;
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 new WebsiteSettingsPopup(context, profile, webContents); 755 new WebsiteSettingsPopup(context, profile, webContents);
755 } 756 }
756 757
757 private static native long nativeInit(WebsiteSettingsPopup popup, WebContent s webContents); 758 private static native long nativeInit(WebsiteSettingsPopup popup, WebContent s webContents);
758 759
759 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid); 760 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid);
760 761
761 private native void nativeOnPermissionSettingChanged(long nativeWebsiteSetti ngsPopupAndroid, 762 private native void nativeOnPermissionSettingChanged(long nativeWebsiteSetti ngsPopupAndroid,
762 int type, int setting); 763 int type, int setting);
763 } 764 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698