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.text.Spannable; | 12 import android.text.Spannable; |
13 import android.text.SpannableStringBuilder; | 13 import android.text.SpannableStringBuilder; |
14 import android.text.style.ForegroundColorSpan; | 14 import android.text.style.ForegroundColorSpan; |
15 import android.text.style.StyleSpan; | 15 import android.text.style.StyleSpan; |
16 import android.view.Gravity; | 16 import android.view.Gravity; |
17 import android.view.LayoutInflater; | 17 import android.view.LayoutInflater; |
18 import android.view.ViewGroup; | 18 import android.view.ViewGroup; |
19 import android.view.Window; | 19 import android.view.Window; |
20 import android.widget.LinearLayout; | 20 import android.widget.LinearLayout; |
21 import android.widget.ScrollView; | 21 import android.widget.ScrollView; |
22 import android.widget.TextView; | 22 import android.widget.TextView; |
23 | 23 |
24 import org.chromium.base.CalledByNative; | 24 import org.chromium.base.CalledByNative; |
25 import org.chromium.base.CommandLine; | 25 import org.chromium.base.CommandLine; |
26 import org.chromium.chrome.ChromeSwitches; | 26 import org.chromium.chrome.ChromeSwitches; |
27 import org.chromium.chrome.R; | 27 import org.chromium.chrome.R; |
28 import org.chromium.content.browser.WebContentsObserverAndroid; | 28 import org.chromium.content.browser.WebContentsObserver; |
29 import org.chromium.content_public.browser.WebContents; | 29 import org.chromium.content_public.browser.WebContents; |
30 | 30 |
31 /** | 31 /** |
32 * Java side of Android implementation of the website settings UI. | 32 * Java side of Android implementation of the website settings UI. |
33 */ | 33 */ |
34 public class WebsiteSettingsPopup { | 34 public class WebsiteSettingsPopup { |
35 private final Context mContext; | 35 private final Context mContext; |
36 private final WebContents mWebContents; | 36 private final WebContents mWebContents; |
37 | 37 |
38 // A pointer to the C++ object for this UI. | 38 // A pointer to the C++ object for this UI. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); | 70 mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); |
71 mDialog.setCanceledOnTouchOutside(true); | 71 mDialog.setCanceledOnTouchOutside(true); |
72 | 72 |
73 // Place the dialog at the top of the screen, and remove its border. | 73 // Place the dialog at the top of the screen, and remove its border. |
74 Window window = mDialog.getWindow(); | 74 Window window = mDialog.getWindow(); |
75 window.setGravity(Gravity.TOP); | 75 window.setGravity(Gravity.TOP); |
76 window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); | 76 window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); |
77 | 77 |
78 // This needs to come after other member initialization. | 78 // This needs to come after other member initialization. |
79 mNativeWebsiteSettingsPopup = nativeInit(this, webContents); | 79 mNativeWebsiteSettingsPopup = nativeInit(this, webContents); |
80 final WebContentsObserverAndroid webContentsObserver = new WebContentsOb
serverAndroid( | 80 final WebContentsObserver webContentsObserver = new WebContentsObserver(
mWebContents) { |
81 mWebContents) { | |
82 @Override | 81 @Override |
83 public void navigationEntryCommitted() { | 82 public void navigationEntryCommitted() { |
84 // If a navigation is committed (e.g. from in-page redirect), th
e data we're | 83 // If a navigation is committed (e.g. from in-page redirect), th
e data we're |
85 // showing is stale so dismiss the dialog. | 84 // showing is stale so dismiss the dialog. |
86 mDialog.dismiss(); | 85 mDialog.dismiss(); |
87 } | 86 } |
88 }; | 87 }; |
89 mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { | 88 mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { |
90 @Override | 89 @Override |
91 public void onDismiss(DialogInterface dialog) { | 90 public void onDismiss(DialogInterface dialog) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } else { | 196 } else { |
198 WebsiteSettingsPopupLegacy.show(context, webContents); | 197 WebsiteSettingsPopupLegacy.show(context, webContents); |
199 } | 198 } |
200 } | 199 } |
201 | 200 |
202 private static native long nativeInit(WebsiteSettingsPopup popup, | 201 private static native long nativeInit(WebsiteSettingsPopup popup, |
203 WebContents webContents); | 202 WebContents webContents); |
204 | 203 |
205 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid); | 204 private native void nativeDestroy(long nativeWebsiteSettingsPopupAndroid); |
206 } | 205 } |
OLD | NEW |