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; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.app.Activity; | 8 import android.app.Activity; |
9 import android.app.ActivityManager; | 9 import android.app.ActivityManager; |
10 import android.content.Context; | 10 import android.content.Context; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 import org.chromium.chrome.browser.cookies.CookiesFetcher; | 55 import org.chromium.chrome.browser.cookies.CookiesFetcher; |
56 import org.chromium.chrome.browser.device.DeviceClassManager; | 56 import org.chromium.chrome.browser.device.DeviceClassManager; |
57 import org.chromium.chrome.browser.document.ChromeLauncherActivity; | 57 import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
58 import org.chromium.chrome.browser.download.DownloadUtils; | 58 import org.chromium.chrome.browser.download.DownloadUtils; |
59 import org.chromium.chrome.browser.firstrun.FirstRunActivity; | 59 import org.chromium.chrome.browser.firstrun.FirstRunActivity; |
60 import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer; | 60 import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer; |
61 import org.chromium.chrome.browser.firstrun.FirstRunSignInProcessor; | 61 import org.chromium.chrome.browser.firstrun.FirstRunSignInProcessor; |
62 import org.chromium.chrome.browser.firstrun.FirstRunStatus; | 62 import org.chromium.chrome.browser.firstrun.FirstRunStatus; |
63 import org.chromium.chrome.browser.incognito.IncognitoNotificationManager; | 63 import org.chromium.chrome.browser.incognito.IncognitoNotificationManager; |
64 import org.chromium.chrome.browser.infobar.DataReductionPromoInfoBar; | 64 import org.chromium.chrome.browser.infobar.DataReductionPromoInfoBar; |
65 import org.chromium.chrome.browser.locale.LocaleManager; | |
65 import org.chromium.chrome.browser.metrics.ActivityStopMetrics; | 66 import org.chromium.chrome.browser.metrics.ActivityStopMetrics; |
66 import org.chromium.chrome.browser.metrics.LaunchMetrics; | 67 import org.chromium.chrome.browser.metrics.LaunchMetrics; |
67 import org.chromium.chrome.browser.metrics.StartupMetrics; | 68 import org.chromium.chrome.browser.metrics.StartupMetrics; |
68 import org.chromium.chrome.browser.metrics.UmaUtils; | 69 import org.chromium.chrome.browser.metrics.UmaUtils; |
69 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; | 70 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; |
70 import org.chromium.chrome.browser.ntp.NativePageAssassin; | 71 import org.chromium.chrome.browser.ntp.NativePageAssassin; |
71 import org.chromium.chrome.browser.ntp.NewTabPageUma; | 72 import org.chromium.chrome.browser.ntp.NewTabPageUma; |
72 import org.chromium.chrome.browser.omaha.OmahaClient; | 73 import org.chromium.chrome.browser.omaha.OmahaClient; |
73 import org.chromium.chrome.browser.omnibox.AutocompleteController; | 74 import org.chromium.chrome.browser.omnibox.AutocompleteController; |
74 import org.chromium.chrome.browser.partnercustomizations.HomepageManager; | 75 import org.chromium.chrome.browser.partnercustomizations.HomepageManager; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 private TabModelSelectorTabObserver mTabModelSelectorTabObserver; | 194 private TabModelSelectorTabObserver mTabModelSelectorTabObserver; |
194 private TabModelObserver mTabModelObserver; | 195 private TabModelObserver mTabModelObserver; |
195 | 196 |
196 private boolean mUIInitialized = false; | 197 private boolean mUIInitialized = false; |
197 | 198 |
198 private boolean mIsOnFirstRun = false; | 199 private boolean mIsOnFirstRun = false; |
199 private Boolean mMergeTabsOnResume; | 200 private Boolean mMergeTabsOnResume; |
200 | 201 |
201 private Boolean mIsAccessibilityEnabled; | 202 private Boolean mIsAccessibilityEnabled; |
202 | 203 |
204 private LocaleManager mLocaleManager; | |
205 | |
203 /** | 206 /** |
204 * Keeps track of whether or not a specific tab was created based on the sta rtup intent. | 207 * Keeps track of whether or not a specific tab was created based on the sta rtup intent. |
205 */ | 208 */ |
206 private boolean mCreatedTabOnStartup = false; | 209 private boolean mCreatedTabOnStartup = false; |
207 | 210 |
208 // Whether or not chrome was launched with an intent to open a tab. | 211 // Whether or not chrome was launched with an intent to open a tab. |
209 private boolean mIntentWithEffect = false; | 212 private boolean mIntentWithEffect = false; |
210 | 213 |
211 // Time at which an intent was received and handled. | 214 // Time at which an intent was received and handled. |
212 private long mIntentHandlingTimeMs = 0; | 215 private long mIntentHandlingTimeMs = 0; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 mTabModelSelectorImpl.notifyChanged(); | 341 mTabModelSelectorImpl.notifyChanged(); |
339 | 342 |
340 getWindow().setFeatureInt(Window.FEATURE_INDETERMINATE_PROGRESS, | 343 getWindow().setFeatureInt(Window.FEATURE_INDETERMINATE_PROGRESS, |
341 Window.PROGRESS_VISIBILITY_OFF); | 344 Window.PROGRESS_VISIBILITY_OFF); |
342 | 345 |
343 // Check for incognito tabs to handle the case where Chrome was swip ed away in the | 346 // Check for incognito tabs to handle the case where Chrome was swip ed away in the |
344 // background. | 347 // background. |
345 int incognitoCount = TabWindowManager.getInstance().getIncognitoTabC ount(); | 348 int incognitoCount = TabWindowManager.getInstance().getIncognitoTabC ount(); |
346 if (incognitoCount == 0) IncognitoNotificationManager.dismissIncogni toNotification(); | 349 if (incognitoCount == 0) IncognitoNotificationManager.dismissIncogni toNotification(); |
347 | 350 |
351 mLocaleManager = ((ChromeApplication) getApplication()).createLocale Manager(); | |
352 mLocaleManager.showSearchEnginePromoIfNeeded(this); | |
353 | |
348 super.finishNativeInitialization(); | 354 super.finishNativeInitialization(); |
349 } finally { | 355 } finally { |
350 TraceEvent.end("ChromeTabbedActivity.finishNativeInitialization"); | 356 TraceEvent.end("ChromeTabbedActivity.finishNativeInitialization"); |
351 } | 357 } |
352 } | 358 } |
353 | 359 |
354 @Override | 360 @Override |
355 public void onResumeWithNative() { | 361 public void onResumeWithNative() { |
356 super.onResumeWithNative(); | 362 super.onResumeWithNative(); |
357 CookiesFetcher.restoreCookies(this); | 363 CookiesFetcher.restoreCookies(this); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 toggleOverview(); | 520 toggleOverview(); |
515 } | 521 } |
516 }; | 522 }; |
517 OnClickListener newTabClickHandler = new OnClickListener() { | 523 OnClickListener newTabClickHandler = new OnClickListener() { |
518 @Override | 524 @Override |
519 public void onClick(View v) { | 525 public void onClick(View v) { |
520 getTabModelSelector().getModel(false).commitAllTabClosures() ; | 526 getTabModelSelector().getModel(false).commitAllTabClosures() ; |
521 // This assumes that the keyboard can not be seen at the sam e time as the | 527 // This assumes that the keyboard can not be seen at the sam e time as the |
522 // newtab button on the toolbar. | 528 // newtab button on the toolbar. |
523 getCurrentTabCreator().launchNTP(); | 529 getCurrentTabCreator().launchNTP(); |
530 mLocaleManager.showSearchEnginePromoIfNeeded(ChromeTabbedAct ivity.this); | |
Maria
2016/10/01 00:00:46
Why do we want to do this? Seems like showing afte
Ian Wen
2016/10/03 17:05:37
It might take some time for the variation server t
| |
524 } | 531 } |
525 }; | 532 }; |
526 OnClickListener bookmarkClickHandler = new OnClickListener() { | 533 OnClickListener bookmarkClickHandler = new OnClickListener() { |
527 @Override | 534 @Override |
528 public void onClick(View v) { | 535 public void onClick(View v) { |
529 addOrEditBookmark(getActivityTab()); | 536 addOrEditBookmark(getActivityTab()); |
530 } | 537 } |
531 }; | 538 }; |
532 | 539 |
533 getToolbarManager().initializeWithNative(mTabModelSelectorImpl, getF ullscreenManager(), | 540 getToolbarManager().initializeWithNative(mTabModelSelectorImpl, getF ullscreenManager(), |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
653 refreshSignIn(); | 660 refreshSignIn(); |
654 } else { | 661 } else { |
655 if (data != null && data.getBooleanExtra( | 662 if (data != null && data.getBooleanExtra( |
656 FirstRunActivity.RESULT_CLOSE_APP, false)) { | 663 FirstRunActivity.RESULT_CLOSE_APP, false)) { |
657 getTabModelSelector().closeAllTabs(true); | 664 getTabModelSelector().closeAllTabs(true); |
658 finish(); | 665 finish(); |
659 } else { | 666 } else { |
660 launchFirstRunExperience(); | 667 launchFirstRunExperience(); |
661 } | 668 } |
662 } | 669 } |
670 mLocaleManager.showSearchEnginePromoIfNeeded(this); | |
663 return true; | 671 return true; |
664 } | 672 } |
665 return false; | 673 return false; |
666 } | 674 } |
667 | 675 |
668 @Override | 676 @Override |
669 public void onAccessibilityModeChanged(boolean enabled) { | 677 public void onAccessibilityModeChanged(boolean enabled) { |
670 super.onAccessibilityModeChanged(enabled); | 678 super.onAccessibilityModeChanged(enabled); |
671 | 679 |
672 if (mLayoutManager != null) { | 680 if (mLayoutManager != null) { |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1016 @Override | 1024 @Override |
1017 public boolean onMenuOrKeyboardAction(final int id, boolean fromMenu) { | 1025 public boolean onMenuOrKeyboardAction(final int id, boolean fromMenu) { |
1018 final Tab currentTab = getActivityTab(); | 1026 final Tab currentTab = getActivityTab(); |
1019 if (id == R.id.move_to_other_window_menu_id) { | 1027 if (id == R.id.move_to_other_window_menu_id) { |
1020 if (currentTab != null) moveTabToOtherWindow(currentTab); | 1028 if (currentTab != null) moveTabToOtherWindow(currentTab); |
1021 } else if (id == R.id.new_tab_menu_id) { | 1029 } else if (id == R.id.new_tab_menu_id) { |
1022 getTabModelSelector().getModel(false).commitAllTabClosures(); | 1030 getTabModelSelector().getModel(false).commitAllTabClosures(); |
1023 RecordUserAction.record("MobileMenuNewTab"); | 1031 RecordUserAction.record("MobileMenuNewTab"); |
1024 RecordUserAction.record("MobileNewTabOpened"); | 1032 RecordUserAction.record("MobileNewTabOpened"); |
1025 getTabCreator(false).launchUrl(UrlConstants.NTP_URL, TabLaunchType.F ROM_CHROME_UI); | 1033 getTabCreator(false).launchUrl(UrlConstants.NTP_URL, TabLaunchType.F ROM_CHROME_UI); |
1034 mLocaleManager.showSearchEnginePromoIfNeeded(this); | |
1026 } else if (id == R.id.new_incognito_tab_menu_id) { | 1035 } else if (id == R.id.new_incognito_tab_menu_id) { |
1027 if (PrefServiceBridge.getInstance().isIncognitoModeEnabled()) { | 1036 if (PrefServiceBridge.getInstance().isIncognitoModeEnabled()) { |
1028 getTabModelSelector().getModel(false).commitAllTabClosures(); | 1037 getTabModelSelector().getModel(false).commitAllTabClosures(); |
1029 // This action must be recorded before opening the incognito tab since UMA actions | 1038 // This action must be recorded before opening the incognito tab since UMA actions |
1030 // are dropped when an incognito tab is open. | 1039 // are dropped when an incognito tab is open. |
1031 RecordUserAction.record("MobileMenuNewIncognitoTab"); | 1040 RecordUserAction.record("MobileMenuNewIncognitoTab"); |
1032 RecordUserAction.record("MobileNewTabOpened"); | 1041 RecordUserAction.record("MobileNewTabOpened"); |
1033 getTabCreator(true).launchUrl(UrlConstants.NTP_URL, TabLaunchTyp e.FROM_CHROME_UI); | 1042 getTabCreator(true).launchUrl(UrlConstants.NTP_URL, TabLaunchTyp e.FROM_CHROME_UI); |
1034 } | 1043 } |
1035 } else if (id == R.id.all_bookmarks_menu_id) { | 1044 } else if (id == R.id.all_bookmarks_menu_id) { |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1328 | 1337 |
1329 if (mUndoBarPopupController != null) { | 1338 if (mUndoBarPopupController != null) { |
1330 mUndoBarPopupController.destroy(); | 1339 mUndoBarPopupController.destroy(); |
1331 mUndoBarPopupController = null; | 1340 mUndoBarPopupController = null; |
1332 } | 1341 } |
1333 | 1342 |
1334 if (mVrShellDelegate != null) { | 1343 if (mVrShellDelegate != null) { |
1335 mVrShellDelegate.destroyVrShell(); | 1344 mVrShellDelegate.destroyVrShell(); |
1336 } | 1345 } |
1337 | 1346 |
1347 mLocaleManager.destroy(); | |
1348 | |
1338 super.onDestroyInternal(); | 1349 super.onDestroyInternal(); |
1339 } | 1350 } |
1340 | 1351 |
1341 @Override | 1352 @Override |
1342 public void onTrimMemory(int level) { | 1353 public void onTrimMemory(int level) { |
1343 super.onTrimMemory(level); | 1354 super.onTrimMemory(level); |
1344 // The conditions are expressed using ranges to capture intermediate lev els possibly added | 1355 // The conditions are expressed using ranges to capture intermediate lev els possibly added |
1345 // to the API in the future. | 1356 // to the API in the future. |
1346 if ((level >= TRIM_MEMORY_RUNNING_LOW && level < TRIM_MEMORY_UI_HIDDEN) | 1357 if ((level >= TRIM_MEMORY_RUNNING_LOW && level < TRIM_MEMORY_UI_HIDDEN) |
1347 || level >= TRIM_MEMORY_MODERATE) { | 1358 || level >= TRIM_MEMORY_MODERATE) { |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1542 // TODO(mthiesse): Toggle toolbar overlay, popups, etc. | 1553 // TODO(mthiesse): Toggle toolbar overlay, popups, etc. |
1543 public void setUIVisibilityForVR(int visibility) { | 1554 public void setUIVisibilityForVR(int visibility) { |
1544 mControlContainer.setVisibility(visibility); | 1555 mControlContainer.setVisibility(visibility); |
1545 getCompositorViewHolder().getSurfaceView().setVisibility(visibility); | 1556 getCompositorViewHolder().getSurfaceView().setVisibility(visibility); |
1546 getCompositorViewHolder().setVisibility(visibility); | 1557 getCompositorViewHolder().setVisibility(visibility); |
1547 | 1558 |
1548 // Enter HTML5 fullscreen to ensure the texture fills the entire composi ted surface. | 1559 // Enter HTML5 fullscreen to ensure the texture fills the entire composi ted surface. |
1549 getFullscreenManager().setPersistentFullscreenMode(visibility == View.GO NE); | 1560 getFullscreenManager().setPersistentFullscreenMode(visibility == View.GO NE); |
1550 } | 1561 } |
1551 } | 1562 } |
OLD | NEW |