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 // LocaleManager can only function after the native library is loade
d. |
| 352 mLocaleManager = LocaleManager.getInstance(); |
| 353 mLocaleManager.showSearchEnginePromoIfNeeded(this); |
| 354 |
348 super.finishNativeInitialization(); | 355 super.finishNativeInitialization(); |
349 } finally { | 356 } finally { |
350 TraceEvent.end("ChromeTabbedActivity.finishNativeInitialization"); | 357 TraceEvent.end("ChromeTabbedActivity.finishNativeInitialization"); |
351 } | 358 } |
352 } | 359 } |
353 | 360 |
354 @Override | 361 @Override |
355 public void onResumeWithNative() { | 362 public void onResumeWithNative() { |
356 super.onResumeWithNative(); | 363 super.onResumeWithNative(); |
357 CookiesFetcher.restoreCookies(this); | 364 CookiesFetcher.restoreCookies(this); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 toggleOverview(); | 521 toggleOverview(); |
515 } | 522 } |
516 }; | 523 }; |
517 OnClickListener newTabClickHandler = new OnClickListener() { | 524 OnClickListener newTabClickHandler = new OnClickListener() { |
518 @Override | 525 @Override |
519 public void onClick(View v) { | 526 public void onClick(View v) { |
520 getTabModelSelector().getModel(false).commitAllTabClosures()
; | 527 getTabModelSelector().getModel(false).commitAllTabClosures()
; |
521 // This assumes that the keyboard can not be seen at the sam
e time as the | 528 // This assumes that the keyboard can not be seen at the sam
e time as the |
522 // newtab button on the toolbar. | 529 // newtab button on the toolbar. |
523 getCurrentTabCreator().launchNTP(); | 530 getCurrentTabCreator().launchNTP(); |
| 531 mLocaleManager.showSearchEnginePromoIfNeeded(ChromeTabbedAct
ivity.this); |
524 } | 532 } |
525 }; | 533 }; |
526 OnClickListener bookmarkClickHandler = new OnClickListener() { | 534 OnClickListener bookmarkClickHandler = new OnClickListener() { |
527 @Override | 535 @Override |
528 public void onClick(View v) { | 536 public void onClick(View v) { |
529 addOrEditBookmark(getActivityTab()); | 537 addOrEditBookmark(getActivityTab()); |
530 } | 538 } |
531 }; | 539 }; |
532 | 540 |
533 getToolbarManager().initializeWithNative(mTabModelSelectorImpl, getF
ullscreenManager(), | 541 getToolbarManager().initializeWithNative(mTabModelSelectorImpl, getF
ullscreenManager(), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 } | 652 } |
645 | 653 |
646 @Override | 654 @Override |
647 public boolean onActivityResultWithNative(int requestCode, int resultCode, I
ntent data) { | 655 public boolean onActivityResultWithNative(int requestCode, int resultCode, I
ntent data) { |
648 if (super.onActivityResultWithNative(requestCode, resultCode, data)) ret
urn true; | 656 if (super.onActivityResultWithNative(requestCode, resultCode, data)) ret
urn true; |
649 | 657 |
650 if (requestCode == FIRST_RUN_EXPERIENCE_RESULT) { | 658 if (requestCode == FIRST_RUN_EXPERIENCE_RESULT) { |
651 mIsOnFirstRun = false; | 659 mIsOnFirstRun = false; |
652 if (resultCode == RESULT_OK) { | 660 if (resultCode == RESULT_OK) { |
653 refreshSignIn(); | 661 refreshSignIn(); |
| 662 mLocaleManager.showSearchEnginePromoIfNeeded(this); |
654 } else { | 663 } else { |
655 if (data != null && data.getBooleanExtra( | 664 if (data != null && data.getBooleanExtra( |
656 FirstRunActivity.RESULT_CLOSE_APP, false)) { | 665 FirstRunActivity.RESULT_CLOSE_APP, false)) { |
657 getTabModelSelector().closeAllTabs(true); | 666 getTabModelSelector().closeAllTabs(true); |
658 finish(); | 667 finish(); |
659 } else { | 668 } else { |
660 launchFirstRunExperience(); | 669 launchFirstRunExperience(); |
661 } | 670 } |
662 } | 671 } |
663 return true; | 672 return true; |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 @Override | 1025 @Override |
1017 public boolean onMenuOrKeyboardAction(final int id, boolean fromMenu) { | 1026 public boolean onMenuOrKeyboardAction(final int id, boolean fromMenu) { |
1018 final Tab currentTab = getActivityTab(); | 1027 final Tab currentTab = getActivityTab(); |
1019 if (id == R.id.move_to_other_window_menu_id) { | 1028 if (id == R.id.move_to_other_window_menu_id) { |
1020 if (currentTab != null) moveTabToOtherWindow(currentTab); | 1029 if (currentTab != null) moveTabToOtherWindow(currentTab); |
1021 } else if (id == R.id.new_tab_menu_id) { | 1030 } else if (id == R.id.new_tab_menu_id) { |
1022 getTabModelSelector().getModel(false).commitAllTabClosures(); | 1031 getTabModelSelector().getModel(false).commitAllTabClosures(); |
1023 RecordUserAction.record("MobileMenuNewTab"); | 1032 RecordUserAction.record("MobileMenuNewTab"); |
1024 RecordUserAction.record("MobileNewTabOpened"); | 1033 RecordUserAction.record("MobileNewTabOpened"); |
1025 getTabCreator(false).launchUrl(UrlConstants.NTP_URL, TabLaunchType.F
ROM_CHROME_UI); | 1034 getTabCreator(false).launchUrl(UrlConstants.NTP_URL, TabLaunchType.F
ROM_CHROME_UI); |
| 1035 mLocaleManager.showSearchEnginePromoIfNeeded(this); |
1026 } else if (id == R.id.new_incognito_tab_menu_id) { | 1036 } else if (id == R.id.new_incognito_tab_menu_id) { |
1027 if (PrefServiceBridge.getInstance().isIncognitoModeEnabled()) { | 1037 if (PrefServiceBridge.getInstance().isIncognitoModeEnabled()) { |
1028 getTabModelSelector().getModel(false).commitAllTabClosures(); | 1038 getTabModelSelector().getModel(false).commitAllTabClosures(); |
1029 // This action must be recorded before opening the incognito tab
since UMA actions | 1039 // This action must be recorded before opening the incognito tab
since UMA actions |
1030 // are dropped when an incognito tab is open. | 1040 // are dropped when an incognito tab is open. |
1031 RecordUserAction.record("MobileMenuNewIncognitoTab"); | 1041 RecordUserAction.record("MobileMenuNewIncognitoTab"); |
1032 RecordUserAction.record("MobileNewTabOpened"); | 1042 RecordUserAction.record("MobileNewTabOpened"); |
1033 getTabCreator(true).launchUrl(UrlConstants.NTP_URL, TabLaunchTyp
e.FROM_CHROME_UI); | 1043 getTabCreator(true).launchUrl(UrlConstants.NTP_URL, TabLaunchTyp
e.FROM_CHROME_UI); |
1034 } | 1044 } |
1035 } else if (id == R.id.all_bookmarks_menu_id) { | 1045 } else if (id == R.id.all_bookmarks_menu_id) { |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 // TODO(mthiesse): Toggle toolbar overlay, popups, etc. | 1552 // TODO(mthiesse): Toggle toolbar overlay, popups, etc. |
1543 public void setUIVisibilityForVR(int visibility) { | 1553 public void setUIVisibilityForVR(int visibility) { |
1544 mControlContainer.setVisibility(visibility); | 1554 mControlContainer.setVisibility(visibility); |
1545 getCompositorViewHolder().getSurfaceView().setVisibility(visibility); | 1555 getCompositorViewHolder().getSurfaceView().setVisibility(visibility); |
1546 getCompositorViewHolder().setVisibility(visibility); | 1556 getCompositorViewHolder().setVisibility(visibility); |
1547 | 1557 |
1548 // Enter HTML5 fullscreen to ensure the texture fills the entire composi
ted surface. | 1558 // Enter HTML5 fullscreen to ensure the texture fills the entire composi
ted surface. |
1549 getFullscreenManager().setPersistentFullscreenMode(visibility == View.GO
NE); | 1559 getFullscreenManager().setPersistentFullscreenMode(visibility == View.GO
NE); |
1550 } | 1560 } |
1551 } | 1561 } |
OLD | NEW |