OLD | NEW |
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; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 122 } |
123 | 123 |
124 private int toIndex(int position) { | 124 private int toIndex(int position) { |
125 return mSearchEngines.get(position).getIndex(); | 125 return mSearchEngines.get(position).getIndex(); |
126 } | 126 } |
127 | 127 |
128 // BaseAdapter: | 128 // BaseAdapter: |
129 | 129 |
130 @Override | 130 @Override |
131 public int getCount() { | 131 public int getCount() { |
132 return mSearchEngines.size(); | 132 return mSearchEngines == null ? 0 : mSearchEngines.size(); |
133 } | 133 } |
134 | 134 |
135 @Override | 135 @Override |
136 public Object getItem(int pos) { | 136 public Object getItem(int pos) { |
137 TemplateUrl templateUrl = mSearchEngines.get(pos); | 137 TemplateUrl templateUrl = mSearchEngines.get(pos); |
138 return templateUrl.getShortName(); | 138 return templateUrl.getShortName(); |
139 } | 139 } |
140 | 140 |
141 @Override | 141 @Override |
142 public long getItemId(int position) { | 142 public long getItemId(int position) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 215 |
216 return view; | 216 return view; |
217 } | 217 } |
218 | 218 |
219 // TemplateUrlService.LoadListener | 219 // TemplateUrlService.LoadListener |
220 | 220 |
221 @Override | 221 @Override |
222 public void onTemplateUrlServiceLoaded() { | 222 public void onTemplateUrlServiceLoaded() { |
223 TemplateUrlService.getInstance().unregisterLoadListener(this); | 223 TemplateUrlService.getInstance().unregisterLoadListener(this); |
224 initEntries(); | 224 initEntries(); |
| 225 notifyDataSetChanged(); |
225 } | 226 } |
226 | 227 |
227 // OnClickListener: | 228 // OnClickListener: |
228 | 229 |
229 @Override | 230 @Override |
230 public void onClick(View view) { | 231 public void onClick(View view) { |
231 if (view.getTag() == null) { | 232 if (view.getTag() == null) { |
232 onLocationLinkClicked(); | 233 onLocationLinkClicked(); |
233 } else { | 234 } else { |
234 searchEngineSelected((int) view.getTag()); | 235 searchEngineSelected((int) view.getTag()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 toIndex(position)); | 283 toIndex(position)); |
283 GeolocationInfo locationSettings = new GeolocationInfo(url, null, false)
; | 284 GeolocationInfo locationSettings = new GeolocationInfo(url, null, false)
; |
284 ContentSetting locationPermission = locationSettings.getContentSetting()
; | 285 ContentSetting locationPermission = locationSettings.getContentSetting()
; |
285 // Handle the case where the geoHeader being sent when no permission has
been specified. | 286 // Handle the case where the geoHeader being sent when no permission has
been specified. |
286 if (locationPermission == ContentSetting.ASK && checkGeoHeader) { | 287 if (locationPermission == ContentSetting.ASK && checkGeoHeader) { |
287 return GeolocationHeader.isGeoHeaderEnabledForUrl(mContext, url, fal
se); | 288 return GeolocationHeader.isGeoHeaderEnabledForUrl(mContext, url, fal
se); |
288 } | 289 } |
289 return locationPermission == ContentSetting.ALLOW; | 290 return locationPermission == ContentSetting.ALLOW; |
290 } | 291 } |
291 } | 292 } |
OLD | NEW |