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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/infobar/SearchGeolocationDisclosureInfoBar.java

Issue 2482023002: Put a Settings link on the new Google Search geolocation disclosure. (Closed)
Patch Set: Feedback Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/app/generated_resources.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/SearchGeolocationDisclosureInfoBar.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/SearchGeolocationDisclosureInfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/SearchGeolocationDisclosureInfoBar.java
index ec46847867ac756befc965867f74238d2040e8c7..73a291b5ebabd81bfc5acbad4feb8bf6c4352e42 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/SearchGeolocationDisclosureInfoBar.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/SearchGeolocationDisclosureInfoBar.java
@@ -4,26 +4,82 @@
package org.chromium.chrome.browser.infobar;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.SpannableString;
+import android.text.Spanned;
+import android.text.TextPaint;
+import android.text.style.ClickableSpan;
+import android.view.View;
+
+import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.browser.ResourceId;
+import org.chromium.chrome.browser.preferences.Preferences;
+import org.chromium.chrome.browser.preferences.PreferencesLauncher;
+import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences;
+import org.chromium.chrome.browser.util.IntentUtils;
/**
* An infobar to disclose to the user that the default search engine has geolocation access by
* default.
*/
public class SearchGeolocationDisclosureInfoBar extends InfoBar {
+ private final String mMessageText;
+ private final int mInlineLinkRangeStart;
+ private final int mInlineLinkRangeEnd;
+
@CalledByNative
- private static InfoBar show(int enumeratedIconId, String message) {
+ private static InfoBar show(int enumeratedIconId, String messageText, int inlineLinkRangeStart,
+ int inlineLinkRangeEnd) {
int drawableId = ResourceId.mapToDrawableId(enumeratedIconId);
- return new SearchGeolocationDisclosureInfoBar(drawableId, message);
+ return new SearchGeolocationDisclosureInfoBar(
+ drawableId, messageText, inlineLinkRangeStart, inlineLinkRangeEnd);
}
/**
* Creates the infobar.
* @param iconDrawableId Drawable ID corresponding to the icon that the infobar will show.
* @param messageText Message to display in the infobar.
+ * @param inlineLinkRangeStartBeginning Beginning of the link in the message.
+ * @param inlineLinkRangeStartEnd End of the link in the message.
*/
- private SearchGeolocationDisclosureInfoBar(int iconDrawableId, String messageText) {
- super(iconDrawableId, null, messageText);
+ private SearchGeolocationDisclosureInfoBar(int iconDrawableId, String messageText,
+ int inlineLinkRangeStart, int inlineLinkRangeEnd) {
+ super(iconDrawableId, null, null);
+ mMessageText = messageText;
+ mInlineLinkRangeStart = inlineLinkRangeStart;
+ mInlineLinkRangeEnd = inlineLinkRangeEnd;
+ }
+
+ @Override
+ public void createContent(InfoBarLayout layout) {
+ super.createContent(layout);
+ SpannableString message = new SpannableString(mMessageText);
+ message.setSpan(
+ new ClickableSpan() {
+ @Override
+ public void onClick(View view) {
+ onLinkClicked();
+ }
+
+ @Override
+ public void updateDrawState(TextPaint ds) {
+ super.updateDrawState(ds);
+ ds.setUnderlineText(false);
+ }
+ }, mInlineLinkRangeStart, mInlineLinkRangeEnd, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ layout.setMessage(message);
+ }
+
+ @CalledByNative
+ private static void showSettingsPage(String searchUrl) {
+ Context context = ContextUtils.getApplicationContext();
+ Intent settingsIntent = PreferencesLauncher.createIntentForSettingsPage(
+ context, SingleWebsitePreferences.class.getName());
+ Bundle fragmentArgs = SingleWebsitePreferences.createFragmentArgsForSite(searchUrl);
+ settingsIntent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, fragmentArgs);
+ IntentUtils.safeStartActivity(context, settingsIntent);
}
}
« no previous file with comments | « no previous file | chrome/app/generated_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698