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

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

Issue 1100283002: Add connection info popup within Page Info on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 5 years, 8 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;
11 import android.app.Dialog; 11 import android.app.Dialog;
12 import android.content.Context; 12 import android.content.Context;
13 import android.content.DialogInterface; 13 import android.content.DialogInterface;
14 import android.graphics.Color; 14 import android.graphics.Color;
15 import android.graphics.drawable.ColorDrawable; 15 import android.graphics.drawable.ColorDrawable;
16 import android.text.Layout; 16 import android.text.Layout;
17 import android.text.Spannable; 17 import android.text.Spannable;
18 import android.text.SpannableString;
18 import android.text.SpannableStringBuilder; 19 import android.text.SpannableStringBuilder;
19 import android.text.style.ForegroundColorSpan; 20 import android.text.style.ForegroundColorSpan;
20 import android.text.style.StyleSpan; 21 import android.text.style.StyleSpan;
21 import android.util.AttributeSet; 22 import android.util.AttributeSet;
22 import android.view.Gravity; 23 import android.view.Gravity;
23 import android.view.LayoutInflater; 24 import android.view.LayoutInflater;
24 import android.view.View; 25 import android.view.View;
25 import android.view.View.OnClickListener; 26 import android.view.View.OnClickListener;
26 import android.view.ViewGroup; 27 import android.view.ViewGroup;
27 import android.view.Window; 28 import android.view.Window;
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 mDeprecatedSHA1Present = ToolbarModel.isDeprecatedSHA1Present(mWebConten ts); 377 mDeprecatedSHA1Present = ToolbarModel.isDeprecatedSHA1Present(mWebConten ts);
377 378
378 SpannableStringBuilder urlBuilder = new SpannableStringBuilder(mFullUrl) ; 379 SpannableStringBuilder urlBuilder = new SpannableStringBuilder(mFullUrl) ;
379 OmniboxUrlEmphasizer.emphasizeUrl(urlBuilder, mContext.getResources(), m Profile, 380 OmniboxUrlEmphasizer.emphasizeUrl(urlBuilder, mContext.getResources(), m Profile,
380 mSecurityLevel, mIsInternalPage, true); 381 mSecurityLevel, mIsInternalPage, true);
381 mUrlTitle.setText(urlBuilder); 382 mUrlTitle.setText(urlBuilder);
382 383
383 // Set the URL connection message now, and the URL after layout (so it 384 // Set the URL connection message now, and the URL after layout (so it
384 // can calculate its ideal height). 385 // can calculate its ideal height).
385 mUrlConnectionMessage.setText(getUrlConnectionMessage()); 386 mUrlConnectionMessage.setText(getUrlConnectionMessage());
387 if (isConnectionDetailsLinkVisible()) mUrlConnectionMessage.setOnClickLi stener(this);
386 } 388 }
387 389
388 /** 390 /**
389 * Sets the visibility of the lower area of the dialog (containing the permi ssions and 'Site 391 * Sets the visibility of the lower area of the dialog (containing the permi ssions and 'Site
390 * Settings' button). 392 * Settings' button).
391 * 393 *
392 * @param isVisible Whether to show or hide the dialog area. 394 * @param isVisible Whether to show or hide the dialog area.
393 */ 395 */
394 private void setVisibilityOfLowerDialogArea(boolean isVisible) { 396 private void setVisibilityOfLowerDialogArea(boolean isVisible) {
395 mHorizontalSeparator.setVisibility(isVisible ? View.VISIBLE : View.GONE) ; 397 mHorizontalSeparator.setVisibility(isVisible ? View.VISIBLE : View.GONE) ;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 case ToolbarModelSecurityLevel.SECURITY_WARNING: 449 case ToolbarModelSecurityLevel.SECURITY_WARNING:
448 case ToolbarModelSecurityLevel.SECURITY_POLICY_WARNING: 450 case ToolbarModelSecurityLevel.SECURITY_POLICY_WARNING:
449 return R.string.page_info_connection_mixed; 451 return R.string.page_info_connection_mixed;
450 default: 452 default:
451 assert false : "Invalid security level specified: " + toolbarMod elSecurityLevel; 453 assert false : "Invalid security level specified: " + toolbarMod elSecurityLevel;
452 return R.string.page_info_connection_http; 454 return R.string.page_info_connection_http;
453 } 455 }
454 } 456 }
455 457
456 /** 458 /**
459 * Whether to show a 'Details' link to the connection info popup. The link i s only shown for
460 * HTTPS connections.
461 */
462 private boolean isConnectionDetailsLinkVisible() {
463 return !mIsInternalPage && mSecurityLevel != ToolbarModelSecurityLevel.N ONE;
464 }
465
466 /**
457 * Gets the styled connection message to display below the URL. 467 * Gets the styled connection message to display below the URL.
458 */ 468 */
459 private Spannable getUrlConnectionMessage() { 469 private Spannable getUrlConnectionMessage() {
460 // Display the appropriate connection message. 470 // Display the appropriate connection message.
461 SpannableStringBuilder messageBuilder = new SpannableStringBuilder(); 471 SpannableStringBuilder messageBuilder = new SpannableStringBuilder();
462 if (mDeprecatedSHA1Present) { 472 if (mDeprecatedSHA1Present) {
463 messageBuilder.append( 473 messageBuilder.append(
464 mContext.getResources().getString(R.string.page_info_connect ion_sha1)); 474 mContext.getResources().getString(R.string.page_info_connect ion_sha1));
465 } else if (mSecurityLevel != ToolbarModelSecurityLevel.SECURITY_ERROR) { 475 } else if (mSecurityLevel != ToolbarModelSecurityLevel.SECURITY_ERROR) {
466 messageBuilder.append(mContext.getResources().getString( 476 messageBuilder.append(mContext.getResources().getString(
(...skipping 14 matching lines...) Expand all
481 R.string.page_info_connection_broken_following_text, originT oDisplay); 491 R.string.page_info_connection_broken_following_text, originT oDisplay);
482 messageBuilder.append(leadingText + " " + followingText); 492 messageBuilder.append(leadingText + " " + followingText);
483 final ForegroundColorSpan redSpan = new ForegroundColorSpan(mContext .getResources() 493 final ForegroundColorSpan redSpan = new ForegroundColorSpan(mContext .getResources()
484 .getColor(R.color.website_settings_connection_broken_leading _text)); 494 .getColor(R.color.website_settings_connection_broken_leading _text));
485 final StyleSpan boldSpan = new StyleSpan(android.graphics.Typeface.B OLD); 495 final StyleSpan boldSpan = new StyleSpan(android.graphics.Typeface.B OLD);
486 messageBuilder.setSpan(redSpan, 0, leadingText.length(), 496 messageBuilder.setSpan(redSpan, 0, leadingText.length(),
487 Spannable.SPAN_INCLUSIVE_EXCLUSIVE); 497 Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
488 messageBuilder.setSpan(boldSpan, 0, leadingText.length(), 498 messageBuilder.setSpan(boldSpan, 0, leadingText.length(),
489 Spannable.SPAN_INCLUSIVE_EXCLUSIVE); 499 Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
490 } 500 }
501
502 if (isConnectionDetailsLinkVisible()) {
503 messageBuilder.append(" ");
504 SpannableString detailsText = new SpannableString(
505 mContext.getResources().getString(R.string.page_info_details _link));
506 final ForegroundColorSpan blueSpan = new ForegroundColorSpan(
507 mContext.getResources().getColor(R.color.website_settings_po pup_text_link));
508 detailsText.setSpan(
509 blueSpan, 0, detailsText.length(), Spannable.SPAN_INCLUSIVE_ EXCLUSIVE);
510 messageBuilder.append(detailsText);
511 }
512
491 return messageBuilder; 513 return messageBuilder;
492 } 514 }
493 515
494 /** 516 /**
495 * Adds a new row for the given permission. 517 * Adds a new row for the given permission.
496 * 518 *
497 * @param name The title of the permission to display to the user. 519 * @param name The title of the permission to display to the user.
498 * @param type The ContentSettingsType of the permission. 520 * @param type The ContentSettingsType of the permission.
499 * @param currentSetting The ContentSetting of the currently selected settin g. 521 * @param currentSetting The ContentSetting of the currently selected settin g.
500 */ 522 */
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 if (view == mCopyUrlButton) { 624 if (view == mCopyUrlButton) {
603 new Clipboard(mContext).setText(mFullUrl, mFullUrl); 625 new Clipboard(mContext).setText(mFullUrl, mFullUrl);
604 mDialog.dismiss(); 626 mDialog.dismiss();
605 } else if (view == mSiteSettingsButton) { 627 } else if (view == mSiteSettingsButton) {
606 // TODO(sashab,finnur): Make this open the Website Settings dialog. 628 // TODO(sashab,finnur): Make this open the Website Settings dialog.
607 assert false : "No Website Settings here!"; 629 assert false : "No Website Settings here!";
608 mDialog.dismiss(); 630 mDialog.dismiss();
609 } else if (view == mUrlTitle) { 631 } else if (view == mUrlTitle) {
610 // Expand/collapse the displayed URL title. 632 // Expand/collapse the displayed URL title.
611 mUrlTitle.toggleTruncation(); 633 mUrlTitle.toggleTruncation();
634 } else if (view == mUrlConnectionMessage) {
635 if (DeviceFormFactor.isTablet(mContext)) {
636 ConnectionInfoPopup.show(mContext, mWebContents);
637 } else {
638 // Delay while the WebsiteSettingsPopup closes.
639 mContainer.postDelayed(new Runnable() {
640 @Override
641 public void run() {
642 ConnectionInfoPopup.show(mContext, mWebContents);
643 }
644 }, FADE_DURATION + CLOSE_CLEANUP_DELAY);
645 }
646 mDialog.dismiss();
612 } 647 }
613 } 648 }
614 649
615 /** 650 /**
616 * Create a list of all the views which we want to individually fade in. 651 * Create a list of all the views which we want to individually fade in.
617 */ 652 */
618 private List<View> collectAnimatableViews() { 653 private List<View> collectAnimatableViews() {
619 List<View> animatableViews = new ArrayList<View>(); 654 List<View> animatableViews = new ArrayList<View>();
620 animatableViews.add(mUrlTitle); 655 animatableViews.add(mUrlTitle);
621 animatableViews.add(mUrlConnectionMessage); 656 animatableViews.add(mUrlConnectionMessage);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 new WebsiteSettingsPopup(context, profile, webContents); 752 new WebsiteSettingsPopup(context, profile, webContents);
718 } 753 }
719 754
720 private static native long nativeInit(WebsiteSettingsPopup popup, WebContent s webContents); 755 private static native long nativeInit(WebsiteSettingsPopup popup, WebContent s webContents);
721 756
722 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid); 757 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid);
723 758
724 private native void nativeOnPermissionSettingChanged(long nativeWebsiteSetti ngsPopupAndroid, 759 private native void nativeOnPermissionSettingChanged(long nativeWebsiteSetti ngsPopupAndroid,
725 int type, int setting); 760 int type, int setting);
726 } 761 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698