Chromium Code Reviews| 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.ClipData; | |
| 9 import android.content.ClipboardManager; | |
| 8 import android.content.Context; | 10 import android.content.Context; |
| 9 import android.content.DialogInterface; | 11 import android.content.DialogInterface; |
| 10 import android.graphics.Color; | 12 import android.graphics.Color; |
| 11 import android.graphics.drawable.ColorDrawable; | 13 import android.graphics.drawable.ColorDrawable; |
| 12 import android.text.Spannable; | 14 import android.text.Spannable; |
| 13 import android.text.SpannableStringBuilder; | 15 import android.text.SpannableStringBuilder; |
| 14 import android.text.style.ForegroundColorSpan; | 16 import android.text.style.ForegroundColorSpan; |
| 15 import android.text.style.StyleSpan; | |
| 16 import android.view.Gravity; | 17 import android.view.Gravity; |
| 17 import android.view.LayoutInflater; | 18 import android.view.LayoutInflater; |
| 19 import android.view.View; | |
| 20 import android.view.View.OnClickListener; | |
| 18 import android.view.ViewGroup; | 21 import android.view.ViewGroup; |
| 19 import android.view.Window; | 22 import android.view.Window; |
| 23 import android.widget.AdapterView; | |
| 24 import android.widget.AdapterView.OnItemSelectedListener; | |
| 25 import android.widget.ArrayAdapter; | |
| 26 import android.widget.Button; | |
| 27 import android.widget.ImageView; | |
| 20 import android.widget.LinearLayout; | 28 import android.widget.LinearLayout; |
| 21 import android.widget.ScrollView; | 29 import android.widget.ScrollView; |
| 30 import android.widget.Spinner; | |
| 22 import android.widget.TextView; | 31 import android.widget.TextView; |
| 32 import android.widget.Toast; | |
| 23 | 33 |
| 24 import org.chromium.base.CalledByNative; | 34 import org.chromium.base.CalledByNative; |
| 25 import org.chromium.base.CommandLine; | 35 import org.chromium.base.CommandLine; |
| 26 import org.chromium.chrome.ChromeSwitches; | 36 import org.chromium.chrome.ChromeSwitches; |
| 27 import org.chromium.chrome.R; | 37 import org.chromium.chrome.R; |
| 28 import org.chromium.content.browser.WebContentsObserverAndroid; | 38 import org.chromium.content.browser.WebContentsObserverAndroid; |
| 29 import org.chromium.content_public.browser.WebContents; | 39 import org.chromium.content_public.browser.WebContents; |
| 30 | 40 |
| 41 import java.util.Arrays; | |
| 42 | |
| 31 /** | 43 /** |
| 32 * Java side of Android implementation of the website settings UI. | 44 * Java side of Android implementation of the website settings UI. |
| 45 * TODO(sashab): Rename this, and all its resources, to PageInfo* and page_info_ * instead of | |
| 46 * WebsiteSettings* and website_settings_*. Do this on the C++ side as well. | |
|
Ted C
2014/10/09 01:25:14
For TODO's, align all subsequent lines with the st
sashab
2014/10/14 02:53:18
Done.
| |
| 33 */ | 47 */ |
| 34 public class WebsiteSettingsPopup { | 48 public class WebsiteSettingsPopup implements OnClickListener, OnItemSelectedList ener { |
| 35 private final Context mContext; | 49 private final Context mContext; |
| 36 private final WebContents mWebContents; | 50 private final WebContents mWebContents; |
| 37 | 51 |
| 38 // A pointer to the C++ object for this UI. | 52 // A pointer to the C++ object for this UI. |
| 39 private final long mNativeWebsiteSettingsPopup; | 53 private final long mNativeWebsiteSettingsPopup; |
| 40 | 54 |
| 41 // The outer container, filled with the layout from website_settings.xml. | 55 // The outer container, filled with the layout from website_settings.xml. |
| 42 private final LinearLayout mContainer; | 56 private final LinearLayout mContainer; |
| 43 | 57 |
| 44 // UI elements in the dialog. | 58 // UI elements in the dialog. |
| 45 private final TextView mUrlTitle; | 59 private final TextView mUrlTitle; |
| 46 private final TextView mUrlConnectionMessage; | 60 private final TextView mUrlConnectionMessage; |
| 61 private final LinearLayout mPermissionsList; | |
| 62 private final Button mCopyUrlButton; | |
| 63 private final Button mSiteSettingsButton; | |
| 64 private final Button mDoneButton; | |
| 47 | 65 |
| 48 // The dialog the container is placed in. | 66 // The dialog the container is placed in. |
| 49 private final Dialog mDialog; | 67 private final Dialog mDialog; |
| 50 | 68 |
| 69 // The full URL from the URL bar, which is copied to the user's clipboard wh en they select 'Copy | |
| 70 // URL'. | |
| 71 private String mFullUrl; | |
| 72 | |
| 51 /** | 73 /** |
| 52 * Creates the WebsiteSettingsPopup, but does not display it. Also | 74 * Creates the WebsiteSettingsPopup, but does not display it. Also |
| 53 * initializes the corresponding C++ object and saves a pointer to it. | 75 * initializes the corresponding C++ object and saves a pointer to it. |
| 54 */ | 76 */ |
| 55 private WebsiteSettingsPopup(Context context, WebContents webContents) { | 77 private WebsiteSettingsPopup(Context context, WebContents webContents) { |
| 56 mContext = context; | 78 mContext = context; |
| 57 mWebContents = webContents; | 79 mWebContents = webContents; |
| 58 | 80 |
| 59 // Find the container and all it's important subviews. | 81 // Find the container and all it's important subviews. |
| 60 mContainer = (LinearLayout) LayoutInflater.from(mContext).inflate( | 82 mContainer = (LinearLayout) LayoutInflater.from(mContext).inflate( |
| 61 R.layout.website_settings, null); | 83 R.layout.website_settings, null); |
| 62 | 84 |
| 63 mUrlTitle = (TextView) mContainer | 85 mUrlTitle = (TextView) mContainer |
| 64 .findViewById(R.id.website_settings_url); | 86 .findViewById(R.id.website_settings_url); |
| 65 mUrlConnectionMessage = (TextView) mContainer | 87 mUrlConnectionMessage = (TextView) mContainer |
| 66 .findViewById(R.id.website_settings_permission_message); | 88 .findViewById(R.id.website_settings_connection_message); |
| 89 mPermissionsList = (LinearLayout) mContainer | |
| 90 .findViewById(R.id.website_settings_permissions_list); | |
| 91 | |
| 92 mCopyUrlButton = (Button) mContainer.findViewById(R.id.website_settings_ copy_url_button); | |
| 93 mCopyUrlButton.setOnClickListener(this); | |
| 94 mSiteSettingsButton = (Button) mContainer | |
| 95 .findViewById(R.id.website_settings_site_settings_button); | |
| 96 mSiteSettingsButton.setOnClickListener(this); | |
| 97 mDoneButton = (Button) mContainer.findViewById(R.id.website_settings_don e_button); | |
| 98 mDoneButton.setOnClickListener(this); | |
| 99 | |
| 100 // Hide the Site Settings button until there's a link to take it to. | |
| 101 // TODO(sashab,finnur): Make this button visible once Site Settings is w orking. | |
| 102 mSiteSettingsButton.setVisibility(View.GONE); | |
|
Ted C
2014/10/09 01:25:15
move this up with the mSiteSettingsButton configur
sashab
2014/10/14 02:53:18
Done.
| |
| 67 | 103 |
| 68 // Create the dialog. | 104 // Create the dialog. |
| 69 mDialog = new Dialog(mContext); | 105 mDialog = new Dialog(mContext); |
| 70 mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); | 106 mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); |
| 71 mDialog.setCanceledOnTouchOutside(true); | 107 mDialog.setCanceledOnTouchOutside(true); |
| 72 | 108 |
| 73 // Place the dialog at the top of the screen, and remove its border. | 109 // Place the dialog at the top of the screen, and remove its border. |
| 74 Window window = mDialog.getWindow(); | 110 Window window = mDialog.getWindow(); |
| 75 window.setGravity(Gravity.TOP); | 111 window.setGravity(Gravity.TOP); |
| 76 window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); | 112 window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); |
| 77 | 113 |
| 78 // This needs to come after other member initialization. | 114 // This needs to come after other member initialization. |
| 79 mNativeWebsiteSettingsPopup = nativeInit(this, webContents); | 115 mNativeWebsiteSettingsPopup = nativeInit(this, webContents); |
| 80 final WebContentsObserverAndroid webContentsObserver = new WebContentsOb serverAndroid( | 116 final WebContentsObserverAndroid webContentsObserver = new WebContentsOb serverAndroid( |
| 81 mWebContents) { | 117 mWebContents) { |
| 82 @Override | 118 @Override |
| 83 public void navigationEntryCommitted() { | 119 public void navigationEntryCommitted() { |
| 84 // If a navigation is committed (e.g. from in-page redirect), th e data we're | 120 // If a navigation is committed (e.g. from in-page redirect), |
| 121 // the data we're | |
|
Ted C
2014/10/09 01:25:15
this looks like it fit fine before on 100 char lin
sashab
2014/10/14 02:53:18
Weird... Done.
| |
| 85 // showing is stale so dismiss the dialog. | 122 // showing is stale so dismiss the dialog. |
| 86 mDialog.dismiss(); | 123 mDialog.dismiss(); |
| 87 } | 124 } |
| 88 }; | 125 }; |
| 89 mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { | 126 mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { |
| 90 @Override | 127 @Override |
| 91 public void onDismiss(DialogInterface dialog) { | 128 public void onDismiss(DialogInterface dialog) { |
| 92 assert mNativeWebsiteSettingsPopup != 0; | 129 assert mNativeWebsiteSettingsPopup != 0; |
| 93 webContentsObserver.detachFromWebContents(); | 130 webContentsObserver.detachFromWebContents(); |
| 94 nativeDestroy(mNativeWebsiteSettingsPopup); | 131 nativeDestroy(mNativeWebsiteSettingsPopup); |
| 95 } | 132 } |
| 96 }); | 133 }); |
| 97 } | 134 } |
| 98 | 135 |
| 99 /** | 136 /** |
| 137 * Returns the Image resource of the icon to use for the given permission. | |
| 138 * Permission must be a valid ContentSettingsType viewable in the PageInfo | |
| 139 * dialog. | |
| 140 */ | |
| 141 private int getImageResourceForPermission(int permission) { | |
| 142 switch (permission) { | |
| 143 case ContentSettingsType.CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS: | |
| 144 return R.drawable.page_info_auto_downloads; | |
| 145 // TODO(sashab): Check if this needs to be removed - manually | |
|
Ted C
2014/10/09 01:25:14
should this be above the return?
sashab
2014/10/14 02:53:18
Yes, but I've now actually confirmed that this doe
| |
| 146 // setting downloads may | |
| 147 // not be available on mobile. | |
|
Ted C
2014/10/09 01:25:14
put this on the previous line
sashab
2014/10/14 02:53:18
Done.
| |
| 148 case ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN: | |
|
Ted C
2014/10/09 01:25:15
We don't use this on mobile.
sashab
2014/10/14 02:53:18
Done.
| |
| 149 // TODO(sashab): Check if this needs to be removed - manually | |
| 150 // setting fullscreen may | |
| 151 // not be available on mobile. | |
| 152 return R.drawable.page_info_fullscreen; | |
| 153 case ContentSettingsType.CONTENT_SETTINGS_TYPE_IMAGES: | |
| 154 return R.drawable.page_info_image; | |
| 155 case ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT: | |
| 156 return R.drawable.page_info_javascript; | |
| 157 case ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION: | |
| 158 return R.drawable.page_info_location; | |
| 159 case ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM: | |
| 160 return R.drawable.page_info_media; | |
| 161 case ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | |
| 162 return R.drawable.page_info_notification; | |
| 163 case ContentSettingsType.CONTENT_SETTINGS_TYPE_PLUGINS: | |
| 164 return R.drawable.page_info_plugins; | |
| 165 case ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS: | |
| 166 return R.drawable.page_info_popups; | |
| 167 default: | |
| 168 assert false : "Icon requested for invalid permission: " + permi ssion; | |
| 169 return -1; | |
| 170 } | |
| 171 } | |
| 172 | |
| 173 /** | |
| 100 * Sets the URL in the title to: (scheme)://(domain)(path). Also colors | 174 * Sets the URL in the title to: (scheme)://(domain)(path). Also colors |
| 101 * different parts of the URL depending on connectionType. | 175 * different parts of the URL depending on connectionType. connectionType |
| 102 * connectionType should be a valid PageInfoConnectionType. | 176 * should be a valid PageInfoConnectionType. |
| 103 */ | 177 */ |
| 104 @CalledByNative | 178 @CalledByNative |
| 105 private void setURLTitle(String scheme, String domain, String path, int conn ectionType) { | 179 private void setURL(String fullUrl, String scheme, String domain, String pat h, |
| 106 boolean makeDomainBold = false; | 180 int connectionType) { |
| 181 mFullUrl = fullUrl; | |
| 107 int schemeColorId = R.color.website_settings_popup_url_scheme_broken; | 182 int schemeColorId = R.color.website_settings_popup_url_scheme_broken; |
| 108 switch (connectionType) { | 183 switch (connectionType) { |
| 109 case PageInfoConnectionType.CONNECTION_UNKNOWN: | 184 case PageInfoConnectionType.CONNECTION_UNKNOWN: |
| 110 schemeColorId = R.color.website_settings_popup_url_scheme_http; | 185 schemeColorId = R.color.website_settings_popup_url_scheme_http; |
| 111 makeDomainBold = true; | |
| 112 break; | 186 break; |
| 113 case PageInfoConnectionType.CONNECTION_ENCRYPTED: | 187 case PageInfoConnectionType.CONNECTION_ENCRYPTED: |
| 114 schemeColorId = R.color.website_settings_popup_url_scheme_https; | 188 schemeColorId = R.color.website_settings_popup_url_scheme_https; |
| 115 break; | 189 break; |
| 116 case PageInfoConnectionType.CONNECTION_MIXED_CONTENT: | 190 case PageInfoConnectionType.CONNECTION_MIXED_CONTENT: |
| 117 schemeColorId = R.color.website_settings_popup_url_scheme_mixed; | 191 schemeColorId = R.color.website_settings_popup_url_scheme_mixed; |
| 118 makeDomainBold = true; | |
| 119 break; | 192 break; |
| 120 case PageInfoConnectionType.CONNECTION_UNENCRYPTED: | 193 case PageInfoConnectionType.CONNECTION_UNENCRYPTED: |
| 121 schemeColorId = R.color.website_settings_popup_url_scheme_http; | 194 schemeColorId = R.color.website_settings_popup_url_scheme_http; |
| 122 makeDomainBold = true; | |
| 123 break; | 195 break; |
| 124 case PageInfoConnectionType.CONNECTION_ENCRYPTED_ERROR: | 196 case PageInfoConnectionType.CONNECTION_ENCRYPTED_ERROR: |
| 125 schemeColorId = R.color.website_settings_popup_url_scheme_broken ; | 197 schemeColorId = R.color.website_settings_popup_url_scheme_broken ; |
| 126 makeDomainBold = true; | |
| 127 break; | 198 break; |
| 128 case PageInfoConnectionType.CONNECTION_INTERNAL_PAGE: | 199 case PageInfoConnectionType.CONNECTION_INTERNAL_PAGE: |
| 129 schemeColorId = R.color.website_settings_popup_url_scheme_http; | 200 schemeColorId = R.color.website_settings_popup_url_scheme_http; |
| 130 break; | 201 break; |
| 131 default: | 202 default: |
| 132 assert false : "Unexpected connection type: " + connectionType; | 203 assert false : "Unexpected connection type: " + connectionType; |
| 133 } | 204 } |
| 134 | 205 |
| 206 // The scheme should be one color, the ://(domain) as another color, and | |
| 207 // the path as a third color. | |
| 135 SpannableStringBuilder sb = new SpannableStringBuilder(scheme + "://" + domain + path); | 208 SpannableStringBuilder sb = new SpannableStringBuilder(scheme + "://" + domain + path); |
| 136 | 209 |
| 137 ForegroundColorSpan schemeColorSpan = new ForegroundColorSpan( | 210 ForegroundColorSpan schemeColorSpan = new ForegroundColorSpan( |
| 138 mContext.getResources().getColor(schemeColorId)); | 211 mContext.getResources().getColor(schemeColorId)); |
| 139 sb.setSpan(schemeColorSpan, 0, scheme.length(), Spannable.SPAN_INCLUSIVE _INCLUSIVE); | 212 sb.setSpan(schemeColorSpan, 0, scheme.length(), Spannable.SPAN_INCLUSIVE _INCLUSIVE); |
| 140 | 213 |
| 141 int domainStartIndex = scheme.length() + 3; | 214 int domainStartIndex = scheme.length(); |
|
Ted C
2014/10/09 01:25:14
this should really be schemeEndIndex now
sashab
2014/10/14 02:53:17
Done.
| |
| 215 int domainEndIndex = domainStartIndex + domain.length() + 3; | |
|
Ted C
2014/10/09 01:25:15
Out of curiosity, what about pages like about:blan
sashab
2014/10/14 02:53:18
Good point. Also confirmed with UI that we actuall
| |
| 142 ForegroundColorSpan domainColorSpan = new ForegroundColorSpan( | 216 ForegroundColorSpan domainColorSpan = new ForegroundColorSpan( |
| 143 mContext.getResources().getColor(R.color.website_settings_popup_ url_domain)); | 217 mContext.getResources().getColor(R.color.website_settings_popup_ url_domain)); |
| 144 sb.setSpan(domainColorSpan, domainStartIndex, domainStartIndex + domain. length(), | 218 sb.setSpan(domainColorSpan, domainStartIndex, domainEndIndex, |
| 145 Spannable.SPAN_INCLUSIVE_INCLUSIVE); | 219 Spannable.SPAN_INCLUSIVE_INCLUSIVE); |
| 146 | 220 |
| 147 if (makeDomainBold) { | |
| 148 StyleSpan boldStyleSpan = new StyleSpan(android.graphics.Typeface.BO LD); | |
| 149 sb.setSpan(boldStyleSpan, domainStartIndex, domainStartIndex + domai n.length(), | |
| 150 Spannable.SPAN_INCLUSIVE_INCLUSIVE); | |
| 151 } | |
| 152 | |
| 153 mUrlTitle.setText(sb); | 221 mUrlTitle.setText(sb); |
| 154 } | 222 } |
| 155 | 223 |
| 156 /** | 224 /** |
| 157 * Sets the connection message displayed at the top of the dialog to | 225 * Sets the connection message displayed at the top of the dialog to |
| 158 * connectionMessage (e.g. "Could not securely connect to this site"). | 226 * connectionMessage (e.g. "Could not securely connect to this site"). |
| 159 */ | 227 */ |
| 160 @CalledByNative | 228 @CalledByNative |
| 161 private void setConnectionMessage(String connectionMessage) { | 229 private void setConnectionMessage(String connectionMessage) { |
| 162 mUrlConnectionMessage.setText(connectionMessage); | 230 mUrlConnectionMessage.setText(connectionMessage); |
| 163 } | 231 } |
| 164 | 232 |
| 233 /** | |
| 234 * Adds a new row for the given permission. - name is the title of the | |
| 235 * permission to display to the user. - type is a ContentSettingsType used | |
| 236 * to identify the permission; this is what is returned when the permission | |
| 237 * is changed. - settingsNames and settingsValues are the list of available | |
| 238 * options the user can select; the name is the value that is displayed and | |
| 239 * the value is the value returned when it is changed. - currentSettingIndex | |
| 240 * is the index of the currently selected setting in | |
| 241 * settingsNames/settingsValues. | |
|
sashab
2014/10/14 02:53:18
Went through and changed all these comments to be
| |
| 242 */ | |
| 243 @CalledByNative | |
| 244 private void addPermissionSection(String name, int type, String[] settingsNa mes, | |
| 245 int[] settingsValues, int currentSettingIndex) { | |
| 246 LinearLayout permission_row = (LinearLayout) LayoutInflater.from(mContex t).inflate( | |
|
Ted C
2014/10/09 01:25:14
always use camelCased names in java
sashab
2014/10/14 02:53:18
Done.
| |
| 247 R.layout.website_settings_permission_row, null); | |
| 248 | |
| 249 ImageView permission_icon = (ImageView) permission_row.findViewById( | |
| 250 R.id.website_settings_permission_icon); | |
| 251 permission_icon.setImageResource(getImageResourceForPermission(type)); | |
| 252 | |
| 253 TextView permission_name = (TextView) permission_row.findViewById( | |
| 254 R.id.website_settings_permission_name); | |
| 255 permission_name.setText(name); | |
| 256 | |
| 257 Spinner permission_spinner = (Spinner) permission_row.findViewById( | |
| 258 R.id.website_settings_permission_spinner); | |
| 259 | |
| 260 // Save the permission type in a tag inside the spinner. | |
| 261 permission_spinner.setTag(R.id.website_settings_popup_permission_type, t ype); | |
| 262 permission_spinner.setTag(R.id.website_settings_popup_permission_spinner _values, | |
| 263 settingsValues); | |
| 264 | |
| 265 ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, | |
|
Ted C
2014/10/09 01:25:15
Instead of using tags, I think it would be slightl
sashab
2014/10/14 02:53:18
Nice. Done.
Also changed the place these are set
| |
| 266 R.drawable.website_settings_permission_spinner_item, Arrays.asLi st(settingsNames)); | |
| 267 adapter.setDropDownViewResource( | |
| 268 R.drawable.website_settings_permission_spinner_dropdown_item); | |
| 269 permission_spinner.setAdapter(adapter); | |
| 270 permission_spinner.setSelection(currentSettingIndex, false); | |
| 271 permission_spinner.setOnItemSelectedListener(this); | |
| 272 | |
| 273 mPermissionsList.addView(permission_row); | |
| 274 } | |
| 275 | |
| 165 /** Displays the WebsiteSettingsPopup. */ | 276 /** Displays the WebsiteSettingsPopup. */ |
| 166 @CalledByNative | 277 @CalledByNative |
| 167 private void showDialog() { | 278 private void showDialog() { |
| 168 // Wrap the dialog in a ScrollView in case the content is too long. | 279 // Wrap the dialog in a ScrollView in case the content is too long. |
| 169 ScrollView scrollView = new ScrollView(mContext); | 280 ScrollView scrollView = new ScrollView(mContext); |
| 170 scrollView.addView(mContainer); | 281 scrollView.addView(mContainer); |
| 171 mDialog.addContentView(scrollView, new LinearLayout.LayoutParams( | 282 mDialog.addContentView(scrollView, new LinearLayout.LayoutParams( |
| 172 LinearLayout.LayoutParams.MATCH_PARENT, | 283 LinearLayout.LayoutParams.MATCH_PARENT, |
| 173 LinearLayout.LayoutParams.MATCH_PARENT)); | 284 LinearLayout.LayoutParams.MATCH_PARENT)); |
| 174 | 285 |
| 175 // Make the dialog fill the width of the screen. This must be called | 286 // Make the dialog fill the width of the screen. This must be called |
| 176 // after addContentView, or it won't fully fill to the edge. | 287 // after addContentView, or it won't fully fill to the edge. |
| 177 Window window = mDialog.getWindow(); | 288 Window window = mDialog.getWindow(); |
| 178 window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, | 289 window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, |
| 179 ViewGroup.LayoutParams.WRAP_CONTENT); | 290 ViewGroup.LayoutParams.WRAP_CONTENT); |
| 180 | 291 |
| 181 mDialog.show(); | 292 mDialog.show(); |
| 182 } | 293 } |
| 183 | 294 |
| 295 @Override | |
| 296 public void onItemSelected(AdapterView<?> parent, View view, int pos, long i d) { | |
| 297 int[] settingsValues = (int[]) parent | |
| 298 .getTag(R.id.website_settings_popup_permission_spinner_values); | |
| 299 int settingsType = (Integer) parent.getTag(R.id.website_settings_popup_p ermission_type); | |
| 300 nativeOnPermissionSettingChanged(mNativeWebsiteSettingsPopup, settingsTy pe, | |
| 301 settingsValues[pos]); | |
| 302 } | |
| 303 | |
| 304 @Override | |
| 305 public void onNothingSelected(AdapterView<?> parent) { | |
| 306 // Do nothing intentionally. | |
| 307 } | |
| 308 | |
| 309 @Override | |
| 310 public void onClick(View view) { | |
| 311 if (view == mCopyUrlButton) { | |
| 312 ClipboardManager clipboardManager = (ClipboardManager) mContext.getS ystemService( | |
|
Ted C
2014/10/09 01:25:14
Clipboard.java is slightly safer to compensate for
sashab
2014/10/14 02:53:18
Thanks for this; done, and set the label to the va
| |
| 313 Context.CLIPBOARD_SERVICE); | |
| 314 ClipData clip = ClipData.newPlainText("url", mFullUrl); | |
| 315 clipboardManager.setPrimaryClip(clip); | |
| 316 Toast.makeText(mContext, R.string.page_info_copy_success_text, Toast .LENGTH_SHORT) | |
|
Ted C
2014/10/09 01:25:15
This toast isn't consistent with the rest of the c
sashab
2014/10/14 02:53:18
Removed the toast; it was my own idea (and you're
| |
| 317 .show(); | |
| 318 } else if (view == mSiteSettingsButton) { | |
| 319 // TODO(sashab,finnur): Make this open the Website Settings dialog. | |
| 320 assert false : "No Website Settings here!"; | |
| 321 mDialog.dismiss(); | |
| 322 } else if (view == mDoneButton) { | |
| 323 mDialog.dismiss(); | |
| 324 } | |
| 325 } | |
| 326 | |
| 184 /** | 327 /** |
| 185 * Shows a WebsiteSettings dialog for the provided WebContents. The popup | 328 * Shows a WebsiteSettings dialog for the provided WebContents. The popup |
| 186 * adds itself to the view hierarchy which owns the reference while it's | 329 * adds itself to the view hierarchy which owns the reference while it's |
| 187 * visible. | 330 * visible. |
| 188 * | 331 * |
| 189 * @param context Context which is used for launching a dialog. | 332 * @param context Context which is used for launching a dialog. |
| 190 * @param webContents The WebContents for which to show Website information. | 333 * @param webContents The WebContents for which to show Website information. |
| 191 * This information is retrieved for the visible entry. | 334 * This information is retrieved for the visible entry. |
| 192 */ | 335 */ |
| 193 @SuppressWarnings("unused") | 336 @SuppressWarnings("unused") |
| 194 public static void show(Context context, WebContents webContents) { | 337 public static void show(Context context, WebContents webContents) { |
| 195 if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_NEW_WEBSIT E_SETTINGS)) { | 338 if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_NEW_WEBSIT E_SETTINGS)) { |
| 196 new WebsiteSettingsPopup(context, webContents); | 339 new WebsiteSettingsPopup(context, webContents); |
| 197 } else { | 340 } else { |
| 198 WebsiteSettingsPopupLegacy.show(context, webContents); | 341 WebsiteSettingsPopupLegacy.show(context, webContents); |
| 199 } | 342 } |
| 200 } | 343 } |
| 201 | 344 |
| 202 private static native long nativeInit(WebsiteSettingsPopup popup, | 345 private static native long nativeInit(WebsiteSettingsPopup popup, |
| 203 WebContents webContents); | 346 WebContents webContents); |
| 204 | 347 |
| 205 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid); | 348 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid); |
| 349 | |
| 350 private native void nativeOnPermissionSettingChanged(long nativeWebsiteSetti ngsPopupAndroid, | |
| 351 int type, int setting); | |
| 206 } | 352 } |
| OLD | NEW |