OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.searchwidget; | 5 package org.chromium.chrome.browser.searchwidget; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Intent; | 8 import android.content.Intent; |
9 import android.net.Uri; | 9 import android.net.Uri; |
10 import android.support.v4.app.ActivityOptionsCompat; | 10 import android.support.v4.app.ActivityOptionsCompat; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 // Kick off everything needed for the user to type into the box. | 129 // Kick off everything needed for the user to type into the box. |
130 beginQuery(); | 130 beginQuery(); |
131 mSearchBox.showCachedZeroSuggestResultsIfAvailable(); | 131 mSearchBox.showCachedZeroSuggestResultsIfAvailable(); |
132 | 132 |
133 // Kick off loading of the native library. | 133 // Kick off loading of the native library. |
134 if (!getActivityDelegate().shouldDelayNativeInitialization()) { | 134 if (!getActivityDelegate().shouldDelayNativeInitialization()) { |
135 mHandler.post(new Runnable() { | 135 mHandler.post(new Runnable() { |
136 @Override | 136 @Override |
137 public void run() { | 137 public void run() { |
138 startNativeInitialization(); | 138 startDelayedNativeInitialization(); |
139 } | 139 } |
140 }); | 140 }); |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 @Override | 144 @Override |
145 public void finishNativeInitialization() { | 145 public void finishNativeInitialization() { |
146 super.finishNativeInitialization(); | 146 super.finishNativeInitialization(); |
147 | 147 |
148 mTab = new Tab(TabIdManager.getInstance().generateValidId(Tab.INVALID_TA
B_ID), | 148 mTab = new Tab(TabIdManager.getInstance().generateValidId(Tab.INVALID_TA
B_ID), |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 return contentView; | 265 return contentView; |
266 } | 266 } |
267 | 267 |
268 private void cancelSearch() { | 268 private void cancelSearch() { |
269 finish(); | 269 finish(); |
270 overridePendingTransition(0, R.anim.activity_close_exit); | 270 overridePendingTransition(0, R.anim.activity_close_exit); |
271 } | 271 } |
272 | 272 |
273 @Override | 273 @Override |
274 @VisibleForTesting | 274 @VisibleForTesting |
275 public final void startNativeInitialization() { | 275 public final void startDelayedNativeInitialization() { |
276 super.startNativeInitialization(); | 276 super.startDelayedNativeInitialization(); |
277 } | 277 } |
278 | 278 |
279 private static SearchActivityDelegate getActivityDelegate() { | 279 private static SearchActivityDelegate getActivityDelegate() { |
280 synchronized (DELEGATE_LOCK) { | 280 synchronized (DELEGATE_LOCK) { |
281 if (sDelegate == null) sDelegate = new SearchActivityDelegate(); | 281 if (sDelegate == null) sDelegate = new SearchActivityDelegate(); |
282 } | 282 } |
283 return sDelegate; | 283 return sDelegate; |
284 } | 284 } |
285 | 285 |
286 /** See {@link #sDelegate}. */ | 286 /** See {@link #sDelegate}. */ |
287 @VisibleForTesting | 287 @VisibleForTesting |
288 static void setDelegateForTests(SearchActivityDelegate delegate) { | 288 static void setDelegateForTests(SearchActivityDelegate delegate) { |
289 sDelegate = delegate; | 289 sDelegate = delegate; |
290 } | 290 } |
291 } | 291 } |
OLD | NEW |