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

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

Issue 2367373003: [Android] Allow setting recently visited search engines as default search engine (Closed)
Patch Set: remove unnecessary changes. Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.preferences; 5 package org.chromium.chrome.browser.preferences;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.content.SharedPreferences; 9 import android.content.SharedPreferences;
10 import android.content.res.Resources; 10 import android.content.res.Resources;
11 import android.os.Build; 11 import android.os.Build;
12 import android.os.Bundle; 12 import android.os.Bundle;
13 import android.text.SpannableString; 13 import android.text.SpannableString;
14 import android.text.style.ForegroundColorSpan; 14 import android.text.style.ForegroundColorSpan;
15 import android.view.LayoutInflater; 15 import android.view.LayoutInflater;
16 import android.view.View; 16 import android.view.View;
17 import android.view.View.AccessibilityDelegate; 17 import android.view.View.AccessibilityDelegate;
18 import android.view.View.OnClickListener; 18 import android.view.View.OnClickListener;
19 import android.view.ViewGroup; 19 import android.view.ViewGroup;
20 import android.view.accessibility.AccessibilityEvent; 20 import android.view.accessibility.AccessibilityEvent;
21 import android.view.accessibility.AccessibilityNodeInfo; 21 import android.view.accessibility.AccessibilityNodeInfo;
22 import android.widget.BaseAdapter; 22 import android.widget.BaseAdapter;
23 import android.widget.RadioButton; 23 import android.widget.RadioButton;
24 import android.widget.TextView; 24 import android.widget.TextView;
25 25
26 import org.chromium.base.ApiCompatibilityUtils; 26 import org.chromium.base.ApiCompatibilityUtils;
27 import org.chromium.base.ContextUtils; 27 import org.chromium.base.ContextUtils;
28 import org.chromium.base.metrics.RecordUserAction;
28 import org.chromium.chrome.R; 29 import org.chromium.chrome.R;
30 import org.chromium.chrome.browser.locale.LocaleManager;
29 import org.chromium.chrome.browser.omnibox.geo.GeolocationHeader; 31 import org.chromium.chrome.browser.omnibox.geo.GeolocationHeader;
30 import org.chromium.chrome.browser.preferences.website.ContentSetting; 32 import org.chromium.chrome.browser.preferences.website.ContentSetting;
31 import org.chromium.chrome.browser.preferences.website.GeolocationInfo; 33 import org.chromium.chrome.browser.preferences.website.GeolocationInfo;
32 import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences; 34 import org.chromium.chrome.browser.preferences.website.SingleWebsitePreferences;
33 import org.chromium.chrome.browser.preferences.website.WebsitePreferenceBridge; 35 import org.chromium.chrome.browser.preferences.website.WebsitePreferenceBridge;
34 import org.chromium.chrome.browser.search_engines.TemplateUrlService; 36 import org.chromium.chrome.browser.search_engines.TemplateUrlService;
35 import org.chromium.chrome.browser.search_engines.TemplateUrlService.LoadListene r; 37 import org.chromium.chrome.browser.search_engines.TemplateUrlService.LoadListene r;
36 import org.chromium.chrome.browser.search_engines.TemplateUrlService.TemplateUrl ; 38 import org.chromium.chrome.browser.search_engines.TemplateUrlService.TemplateUrl ;
37 import org.chromium.components.location.LocationUtils; 39 import org.chromium.components.location.LocationUtils;
38 import org.chromium.ui.text.SpanApplier; 40 import org.chromium.ui.text.SpanApplier;
39 import org.chromium.ui.text.SpanApplier.SpanInfo; 41 import org.chromium.ui.text.SpanApplier.SpanInfo;
40 42
43 import java.util.ArrayList;
41 import java.util.List; 44 import java.util.List;
42 45
43 /** 46 /**
44 * A custom adapter for listing search engines. 47 * A custom adapter for listing search engines.
45 */ 48 */
46 public class SearchEngineAdapter extends BaseAdapter implements LoadListener, On ClickListener { 49 public class SearchEngineAdapter extends BaseAdapter implements LoadListener, On ClickListener {
47 /** 50 /**
48 * A callback for reporting progress to the owner. 51 * A callback for reporting progress to the owner.
49 */ 52 */
50 public interface SelectSearchEngineCallback { 53 public interface SelectSearchEngineCallback {
51 /** 54 /**
52 * Called when the search engine data has loaded and we've determined th e currently active 55 * Called when the search engine data has loaded and we've determined th e currently active
53 * one. 56 * one.
54 * @param name Provides the name of it (with a simplified URL in parenth esis). 57 * @param name Provides the name of it (with a simplified URL in parenth esis).
55 */ 58 */
56 void currentSearchEngineDetermined(int selectedIndex); 59 void currentSearchEngineDetermined(String keyword);
57 } 60 }
58 61
59 // The current context. 62 // The current context.
60 private Context mContext; 63 private Context mContext;
61 64
62 // The layout inflater to use for the custom views. 65 // The layout inflater to use for the custom views.
63 private LayoutInflater mLayoutInflater; 66 private LayoutInflater mLayoutInflater;
64 67
65 // The callback to use for notifying caller of progress. 68 // The callback to use for notifying caller of progress.
66 private SelectSearchEngineCallback mCallback; 69 private SelectSearchEngineCallback mCallback;
67 70
68 // The list of available search engines. 71 // The list of prepopluated and default search engines.
69 private List<TemplateUrl> mSearchEngines; 72 private List<TemplateUrl> mPrepopulatedSearchEngines = new ArrayList<Templat eUrl>();
70 // The position (index into mSearchEngines) of the currently selected search engine. Can be -1 73 // The list of recently visited search engines.
74 private List<TemplateUrl> mRecentVisitedSearchEngines = new ArrayList<Templa teUrl>();
75 // The position (index into mPrepopulatedSearchEngines) of the currently sel ected search engine.
76 // Can be -1
71 // if current search engine is managed and set to something other than the p re-populated values. 77 // if current search engine is managed and set to something other than the p re-populated values.
72 private int mSelectedSearchEnginePosition = -1; 78 private int mSelectedSearchEnginePosition = -1;
73 79
74 // The position of the default search engine before user's action. 80 // The position of the default search engine before user's action.
75 private int mInitialEnginePosition = -1; 81 private int mInitialEnginePosition = -1;
76 82
83 static final int VIEW_TYPE_ITEM = 0;
Ian Wen 2016/10/17 23:32:21 1. If this variable is not used by other classes i
ltian 2016/10/18 01:01:55 Done.
84 static final int VIEW_TYPE_DIVIDER = 1;
85
77 /** 86 /**
78 * Construct a SearchEngineAdapter. 87 * Construct a SearchEngineAdapter.
79 * @param context The current context. 88 * @param context The current context.
80 * @param callback The callback to use to communicate back. 89 * @param callback The callback to use to communicate back.
81 */ 90 */
82 public SearchEngineAdapter(Context context, SelectSearchEngineCallback callb ack) { 91 public SearchEngineAdapter(Context context, SelectSearchEngineCallback callb ack) {
83 mContext = context; 92 mContext = context;
84 mLayoutInflater = (LayoutInflater) mContext.getSystemService( 93 mLayoutInflater = (LayoutInflater) mContext.getSystemService(
85 Context.LAYOUT_INFLATER_SERVICE); 94 Context.LAYOUT_INFLATER_SERVICE);
86 mCallback = callback; 95 mCallback = callback;
87 96
88 initEntries(); 97 initEntries();
89 } 98 }
90 99
91 /**
92 * @return The index of the selected engine before user's action.
93 */
94 public int getInitialSearchEnginePosition() {
95 return mInitialEnginePosition;
96 }
97
98 // Used for testing. 100 // Used for testing.
99 101
100 String getValueForTesting() { 102 String getValueForTesting() {
101 return Integer.toString(mSelectedSearchEnginePosition); 103 return Integer.toString(mSelectedSearchEnginePosition);
102 } 104 }
103 105
104 void setValueForTesting(String value) { 106 String setValueForTesting(String value) {
105 searchEngineSelected(Integer.parseInt(value)); 107 return searchEngineSelected(Integer.parseInt(value));
108 }
109
110 String getKeywordFromIndex(int index) {
Ian Wen 2016/10/17 23:32:21 Rename it to getKeywordForTesting() ?
ltian 2016/10/18 01:01:55 Done.
111 return toKeyword(index);
106 } 112 }
107 113
108 /** 114 /**
109 * Initialize the search engine list. 115 * Initialize the search engine list.
110 */ 116 */
111 private void initEntries() { 117 private void initEntries() {
112 TemplateUrlService templateUrlService = TemplateUrlService.getInstance() ; 118 TemplateUrlService templateUrlService = TemplateUrlService.getInstance() ;
113 if (!templateUrlService.isLoaded()) { 119 if (!templateUrlService.isLoaded()) {
114 templateUrlService.registerLoadListener(this); 120 templateUrlService.registerLoadListener(this);
115 templateUrlService.load(); 121 templateUrlService.load();
116 return; // Flow continues in onTemplateUrlServiceLoaded below. 122 return; // Flow continues in onTemplateUrlServiceLoaded below.
117 } 123 }
118 124
119 // Fetch all the search engine info and the currently active one. 125 int defaultSearchEngineIndex = templateUrlService.getDefaultSearchEngine Index();
120 mSearchEngines = templateUrlService.getLocalizedSearchEngines(); 126 /**
121 int searchEngineIndex = templateUrlService.getDefaultSearchEngineIndex() ; 127 * Fetch all the search engine info and the currently active one, based on their types,
128 * add into different lists.
Ian Wen 2016/10/17 23:32:21 Inner comments should start with //
ltian 2016/10/18 01:01:55 Done.
129 */
130 for (TemplateUrl templateUrl : templateUrlService.getLocalizedSearchEngi nes()) {
131 if (templateUrl.getType() == TemplateUrlService.TYPE_PREPOPULATED
132 || templateUrl.getType() == TemplateUrlService.TYPE_DEFAULT) {
133 mPrepopulatedSearchEngines.add(templateUrl);
134 } else {
135 mRecentVisitedSearchEngines.add(templateUrl);
136 }
137 }
138
122 // Convert the TemplateUrl index into an index into mSearchEngines. 139 // Convert the TemplateUrl index into an index into mSearchEngines.
Ian Wen 2016/10/17 23:32:21 an index *of* mSearchEngines.
ltian 2016/10/18 01:01:55 Done.
123 mSelectedSearchEnginePosition = -1; 140 mSelectedSearchEnginePosition = -1;
124 for (int i = 0; i < mSearchEngines.size(); ++i) { 141 for (int i = 0; i < mPrepopulatedSearchEngines.size(); ++i) {
125 if (mSearchEngines.get(i).getIndex() == searchEngineIndex) { 142 if (mPrepopulatedSearchEngines.get(i).getIndex() == defaultSearchEng ineIndex) {
126 mSelectedSearchEnginePosition = i; 143 mSelectedSearchEnginePosition = i;
127 } 144 }
128 } 145 }
146
147 for (int i = 0; i < mRecentVisitedSearchEngines.size(); ++i) {
148 if (mRecentVisitedSearchEngines.get(i).getIndex() == defaultSearchEn gineIndex) {
149 mSelectedSearchEnginePosition = i + mPrepopulatedSearchEngines.s ize() + 1;
150 }
151 }
152
129 mInitialEnginePosition = mSelectedSearchEnginePosition; 153 mInitialEnginePosition = mSelectedSearchEnginePosition;
130 154
131 // Report back what is selected. 155 // Report back what is selected.
132 mCallback.currentSearchEngineDetermined(toIndex(mSelectedSearchEnginePos ition)); 156 mCallback.currentSearchEngineDetermined(toKeyword(mSelectedSearchEngineP osition));
133 } 157 }
134 158
135 private int toIndex(int position) { 159 private String toKeyword(int position) {
136 return mSearchEngines.get(position).getIndex(); 160 if (position < mPrepopulatedSearchEngines.size()) {
161 return mPrepopulatedSearchEngines.get(position).getKeyword();
162 } else {
163 position -= mPrepopulatedSearchEngines.size() + 1;
164 return mRecentVisitedSearchEngines.get(position).getKeyword();
165 }
137 } 166 }
138 167
139 // BaseAdapter: 168 // BaseAdapter:
140 169
141 @Override 170 @Override
142 public int getCount() { 171 public int getCount() {
143 return mSearchEngines == null ? 0 : mSearchEngines.size(); 172 return mPrepopulatedSearchEngines == null
173 ? 0
174 : mPrepopulatedSearchEngines.size() + mRecentVisitedSearchEngine s.size() + 1;
144 } 175 }
145 176
146 @Override 177 @Override
147 public Object getItem(int pos) { 178 public Object getItem(int pos) {
148 TemplateUrl templateUrl = mSearchEngines.get(pos); 179 if (pos < mPrepopulatedSearchEngines.size()) {
149 return templateUrl.getShortName(); 180 return mPrepopulatedSearchEngines.get(pos);
181 } else if (pos > mPrepopulatedSearchEngines.size()) {
182 pos -= mPrepopulatedSearchEngines.size() + 1;
183 return mRecentVisitedSearchEngines.get(pos);
184 }
185 return null;
150 } 186 }
151 187
152 @Override 188 @Override
153 public long getItemId(int position) { 189 public long getItemId(int position) {
154 return position; 190 return position;
155 } 191 }
156 192
157 @Override 193 @Override
194 public int getItemViewType(int position) {
195 if (position == mPrepopulatedSearchEngines.size()) {
196 return VIEW_TYPE_DIVIDER;
197 } else {
198 return VIEW_TYPE_ITEM;
199 }
200 }
201
202 @Override
158 public View getView(int position, View convertView, ViewGroup parent) { 203 public View getView(int position, View convertView, ViewGroup parent) {
159 View view = convertView; 204 View view = convertView;
160 if (convertView == null) { 205 TemplateUrl templateUrl = (TemplateUrl) getItem(position);
206 int itemViewType = getItemViewType(position);
207 if (itemViewType == VIEW_TYPE_DIVIDER) {
208 view = mLayoutInflater.inflate(R.layout.search_engine_recent_title, null);
209 } else {
161 view = mLayoutInflater.inflate(R.layout.search_engine, null); 210 view = mLayoutInflater.inflate(R.layout.search_engine, null);
162 } 211 }
212 if (itemViewType == VIEW_TYPE_DIVIDER) {
213 view.setOnClickListener(null);
214 view.setEnabled(false);
215 return view;
216 }
163 217
164 view.setOnClickListener(this); 218 view.setOnClickListener(this);
165 view.setTag(position); 219 view.setTag(position);
166 220
167 // TODO(finnur): There's a tinting bug in the AppCompat lib (see http:// crbug.com/474695), 221 // TODO(finnur): There's a tinting bug in the AppCompat lib (see http:// crbug.com/474695),
168 // which causes the first radiobox to always appear selected, even if it is not. It is being 222 // which causes the first radiobox to always appear selected, even if it is not. It is being
169 // addressed, but in the meantime we should use the native RadioButton i nstead. 223 // addressed, but in the meantime we should use the native RadioButton i nstead.
170 RadioButton radioButton = (RadioButton) view.findViewById(R.id.radiobutt on); 224 RadioButton radioButton = (RadioButton) view.findViewById(R.id.radiobutt on);
171 // On Lollipop this removes the redundant animation ring on selection bu t on older versions 225 // On Lollipop this removes the redundant animation ring on selection bu t on older versions
172 // it would cause the radio button to disappear. 226 // it would cause the radio button to disappear.
173 // TODO(finnur): Remove the encompassing if statement once we go back to using the AppCompat 227 // TODO(finnur): Remove the encompassing if statement once we go back to using the AppCompat
174 // control. 228 // control.
175 final boolean selected = position == mSelectedSearchEnginePosition; 229 final boolean selected = position == mSelectedSearchEnginePosition;
176 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 230 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
177 radioButton.setBackgroundResource(0); 231 radioButton.setBackgroundResource(0);
178 } 232 }
179 radioButton.setChecked(selected); 233 radioButton.setChecked(selected);
180 234
181 TextView description = (TextView) view.findViewById(R.id.description); 235 TextView description = (TextView) view.findViewById(R.id.description);
182 TemplateUrl templateUrl = mSearchEngines.get(position);
183 Resources resources = mContext.getResources(); 236 Resources resources = mContext.getResources();
184 description.setText(templateUrl.getShortName()); 237 description.setText(templateUrl.getShortName());
185 238
239 TextView url = (TextView) view.findViewById(R.id.url);
240 url.setText(templateUrl.getUrl());
241 if (templateUrl.getType() == TemplateUrlService.TYPE_PREPOPULATED
242 || templateUrl.getType() == TemplateUrlService.TYPE_DEFAULT
243 || templateUrl.getUrl().length() == 0) {
244 url.setVisibility(View.GONE);
245 }
246
186 // To improve the explore-by-touch experience, the radio button is hidde n from accessibility 247 // To improve the explore-by-touch experience, the radio button is hidde n from accessibility
187 // and instead, "checked" or "not checked" is read along with the search engine's name, e.g. 248 // and instead, "checked" or "not checked" is read along with the search engine's name, e.g.
188 // "google.com checked" or "google.com not checked". 249 // "google.com checked" or "google.com not checked".
189 radioButton.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILIT Y_NO); 250 radioButton.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILIT Y_NO);
190 description.setAccessibilityDelegate(new AccessibilityDelegate() { 251 description.setAccessibilityDelegate(new AccessibilityDelegate() {
191 @Override 252 @Override
192 public void onInitializeAccessibilityEvent(View host, AccessibilityE vent event) { 253 public void onInitializeAccessibilityEvent(View host, AccessibilityE vent event) {
193 super.onInitializeAccessibilityEvent(host, event); 254 super.onInitializeAccessibilityEvent(host, event);
194 event.setChecked(selected); 255 event.setChecked(selected);
195 } 256 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 301
241 @Override 302 @Override
242 public void onClick(View view) { 303 public void onClick(View view) {
243 if (view.getTag() == null) { 304 if (view.getTag() == null) {
244 onLocationLinkClicked(); 305 onLocationLinkClicked();
245 } else { 306 } else {
246 searchEngineSelected((int) view.getTag()); 307 searchEngineSelected((int) view.getTag());
247 } 308 }
248 } 309 }
249 310
250 private void searchEngineSelected(int position) { 311 private String searchEngineSelected(int position) {
251 // First clean up any automatically added permissions (if any) for the p reviously selected 312 // First clean up any automatically added permissions (if any) for the p reviously selected
252 // search engine. 313 // search engine.
253 SharedPreferences sharedPreferences = 314 SharedPreferences sharedPreferences =
254 ContextUtils.getAppSharedPreferences(); 315 ContextUtils.getAppSharedPreferences();
255 if (sharedPreferences.getBoolean(PrefServiceBridge.LOCATION_AUTO_ALLOWED , false)) { 316 if (sharedPreferences.getBoolean(PrefServiceBridge.LOCATION_AUTO_ALLOWED , false)) {
256 if (locationEnabled(mSelectedSearchEnginePosition, false)) { 317 if (locationEnabled(mSelectedSearchEnginePosition, false)) {
257 String url = TemplateUrlService.getInstance().getSearchEngineUrl FromTemplateUrl( 318 String url = TemplateUrlService.getInstance().getSearchEngineUrl FromTemplateUrl(
258 toIndex(mSelectedSearchEnginePosition)); 319 toKeyword(mSelectedSearchEnginePosition));
259 WebsitePreferenceBridge.nativeSetGeolocationSettingForOrigin( 320 WebsitePreferenceBridge.nativeSetGeolocationSettingForOrigin(
260 url, url, ContentSetting.DEFAULT.toInt(), false); 321 url, url, ContentSetting.DEFAULT.toInt(), false);
261 } 322 }
262 sharedPreferences.edit().remove(PrefServiceBridge.LOCATION_AUTO_ALLO WED).apply(); 323 sharedPreferences.edit().remove(PrefServiceBridge.LOCATION_AUTO_ALLO WED).apply();
263 } 324 }
264 325
265 // Record the change in search engine. 326 // Record the change in search engine.
266 mSelectedSearchEnginePosition = position; 327 mSelectedSearchEnginePosition = position;
267 328
329 String keyword = toKeyword(mSelectedSearchEnginePosition);
268 // Report the change back. 330 // Report the change back.
269 mCallback.currentSearchEngineDetermined(toIndex(mSelectedSearchEnginePos ition)); 331 mCallback.currentSearchEngineDetermined(keyword);
270 332
333 // If the user has manually set the default search engine, disable auto switching.
334 boolean manualSwitch = mSelectedSearchEnginePosition != mInitialEnginePo sition;
335 if (manualSwitch) {
336 RecordUserAction.record("SearchEngine_ManualChange");
337 LocaleManager.getInstance().setSearchEngineAutoSwitch(false);
338 }
271 notifyDataSetChanged(); 339 notifyDataSetChanged();
340 return keyword;
272 } 341 }
273 342
274 private void onLocationLinkClicked() { 343 private void onLocationLinkClicked() {
275 if (!LocationUtils.getInstance().isSystemLocationSettingEnabled()) { 344 if (!LocationUtils.getInstance().isSystemLocationSettingEnabled()) {
276 mContext.startActivity(LocationUtils.getInstance().getSystemLocation SettingsIntent()); 345 mContext.startActivity(LocationUtils.getInstance().getSystemLocation SettingsIntent());
277 } else { 346 } else {
278 Intent settingsIntent = PreferencesLauncher.createIntentForSettingsP age( 347 Intent settingsIntent = PreferencesLauncher.createIntentForSettingsP age(
279 mContext, SingleWebsitePreferences.class.getName()); 348 mContext, SingleWebsitePreferences.class.getName());
280 String url = TemplateUrlService.getInstance().getSearchEngineUrlFrom TemplateUrl( 349 String url = TemplateUrlService.getInstance().getSearchEngineUrlFrom TemplateUrl(
281 toIndex(mSelectedSearchEnginePosition)); 350 toKeyword(mSelectedSearchEnginePosition));
282 Bundle fragmentArgs = SingleWebsitePreferences.createFragmentArgsFor Site(url); 351 Bundle fragmentArgs = SingleWebsitePreferences.createFragmentArgsFor Site(url);
283 fragmentArgs.putBoolean(SingleWebsitePreferences.EXTRA_LOCATION, 352 fragmentArgs.putBoolean(SingleWebsitePreferences.EXTRA_LOCATION,
284 locationEnabled(mSelectedSearchEnginePosition, true)); 353 locationEnabled(mSelectedSearchEnginePosition, true));
285 settingsIntent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, f ragmentArgs); 354 settingsIntent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, f ragmentArgs);
286 mContext.startActivity(settingsIntent); 355 mContext.startActivity(settingsIntent);
287 } 356 }
288 } 357 }
289 358
290 private boolean locationEnabled(int position, boolean checkGeoHeader) { 359 private boolean locationEnabled(int position, boolean checkGeoHeader) {
291 if (position == -1) return false; 360 if (position == -1) return false;
292 361
293 String url = TemplateUrlService.getInstance().getSearchEngineUrlFromTemp lateUrl( 362 String url = TemplateUrlService.getInstance().getSearchEngineUrlFromTemp lateUrl(
294 toIndex(position)); 363 toKeyword(position));
295 GeolocationInfo locationSettings = new GeolocationInfo(url, null, false) ; 364 GeolocationInfo locationSettings = new GeolocationInfo(url, null, false) ;
296 ContentSetting locationPermission = locationSettings.getContentSetting() ; 365 ContentSetting locationPermission = locationSettings.getContentSetting() ;
297 // Handle the case where the geoHeader being sent when no permission has been specified. 366 // Handle the case where the geoHeader being sent when no permission has been specified.
298 if (locationPermission == ContentSetting.ASK && checkGeoHeader) { 367 if (locationPermission == ContentSetting.ASK && checkGeoHeader) {
299 return GeolocationHeader.isGeoHeaderEnabledForUrl(mContext, url, fal se); 368 return GeolocationHeader.isGeoHeaderEnabledForUrl(mContext, url, fal se);
300 } 369 }
301 return locationPermission == ContentSetting.ALLOW; 370 return locationPermission == ContentSetting.ALLOW;
302 } 371 }
303 } 372 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698