Chromium Code Reviews| 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.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
| 9 import android.app.Activity; | 9 import android.app.Activity; |
| 10 import android.app.SearchManager; | 10 import android.app.SearchManager; |
| 11 import android.app.assist.AssistContent; | 11 import android.app.assist.AssistContent; |
| 12 import android.content.Context; | 12 import android.content.Context; |
| 13 import android.content.Intent; | 13 import android.content.Intent; |
| 14 import android.content.res.Configuration; | 14 import android.content.res.Configuration; |
| 15 import android.graphics.Bitmap; | 15 import android.graphics.Bitmap; |
| 16 import android.graphics.Color; | 16 import android.graphics.Color; |
| 17 import android.graphics.Rect; | 17 import android.graphics.Rect; |
| 18 import android.graphics.drawable.ColorDrawable; | 18 import android.graphics.drawable.ColorDrawable; |
| 19 import android.graphics.drawable.Drawable; | 19 import android.graphics.drawable.Drawable; |
| 20 import android.net.Uri; | 20 import android.net.Uri; |
| 21 import android.os.Build; | 21 import android.os.Build; |
| 22 import android.os.Bundle; | 22 import android.os.Bundle; |
| 23 import android.os.StrictMode; | 23 import android.os.StrictMode; |
| 24 import android.os.SystemClock; | 24 import android.os.SystemClock; |
| 25 import android.support.design.widget.CoordinatorLayout.LayoutParams; | |
| 26 import android.support.v7.app.AlertDialog; | 25 import android.support.v7.app.AlertDialog; |
| 27 import android.util.DisplayMetrics; | 26 import android.util.DisplayMetrics; |
| 28 import android.util.Pair; | 27 import android.util.Pair; |
| 29 import android.view.Gravity; | |
| 30 import android.view.Menu; | 28 import android.view.Menu; |
| 31 import android.view.MenuItem; | 29 import android.view.MenuItem; |
| 32 import android.view.View; | 30 import android.view.View; |
| 33 import android.view.ViewConfiguration; | 31 import android.view.ViewConfiguration; |
| 34 import android.view.ViewGroup; | 32 import android.view.ViewGroup; |
| 35 import android.view.ViewStub; | 33 import android.view.ViewStub; |
| 36 import android.view.Window; | 34 import android.view.Window; |
| 37 import android.view.WindowManager; | 35 import android.view.WindowManager; |
| 38 import android.view.accessibility.AccessibilityManager; | 36 import android.view.accessibility.AccessibilityManager; |
| 39 import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeL istener; | 37 import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeL istener; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 import org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver; | 118 import org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver; |
| 121 import org.chromium.chrome.browser.tabmodel.TabModelUtils; | 119 import org.chromium.chrome.browser.tabmodel.TabModelUtils; |
| 122 import org.chromium.chrome.browser.tabmodel.TabWindowManager; | 120 import org.chromium.chrome.browser.tabmodel.TabWindowManager; |
| 123 import org.chromium.chrome.browser.toolbar.Toolbar; | 121 import org.chromium.chrome.browser.toolbar.Toolbar; |
| 124 import org.chromium.chrome.browser.toolbar.ToolbarControlContainer; | 122 import org.chromium.chrome.browser.toolbar.ToolbarControlContainer; |
| 125 import org.chromium.chrome.browser.toolbar.ToolbarManager; | 123 import org.chromium.chrome.browser.toolbar.ToolbarManager; |
| 126 import org.chromium.chrome.browser.util.ChromeFileProvider; | 124 import org.chromium.chrome.browser.util.ChromeFileProvider; |
| 127 import org.chromium.chrome.browser.util.ColorUtils; | 125 import org.chromium.chrome.browser.util.ColorUtils; |
| 128 import org.chromium.chrome.browser.util.FeatureUtilities; | 126 import org.chromium.chrome.browser.util.FeatureUtilities; |
| 129 import org.chromium.chrome.browser.webapps.AddToHomescreenManager; | 127 import org.chromium.chrome.browser.webapps.AddToHomescreenManager; |
| 128 import org.chromium.chrome.browser.widget.BottomSheet; | |
| 130 import org.chromium.chrome.browser.widget.ControlContainer; | 129 import org.chromium.chrome.browser.widget.ControlContainer; |
| 131 import org.chromium.components.bookmarks.BookmarkId; | 130 import org.chromium.components.bookmarks.BookmarkId; |
| 132 import org.chromium.content.browser.ContentVideoView; | 131 import org.chromium.content.browser.ContentVideoView; |
| 133 import org.chromium.content.browser.ContentViewCore; | 132 import org.chromium.content.browser.ContentViewCore; |
| 134 import org.chromium.content.common.ContentSwitches; | 133 import org.chromium.content.common.ContentSwitches; |
| 135 import org.chromium.content_public.browser.ContentBitmapCallback; | 134 import org.chromium.content_public.browser.ContentBitmapCallback; |
| 136 import org.chromium.content_public.browser.LoadUrlParams; | 135 import org.chromium.content_public.browser.LoadUrlParams; |
| 137 import org.chromium.content_public.browser.WebContents; | 136 import org.chromium.content_public.browser.WebContents; |
| 138 import org.chromium.content_public.browser.readback_types.ReadbackResponse; | 137 import org.chromium.content_public.browser.readback_types.ReadbackResponse; |
| 139 import org.chromium.policy.CombinedPolicyProvider; | 138 import org.chromium.policy.CombinedPolicyProvider; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 * super.setContentView() before using {@link #getTabModelSelector()} or | 349 * super.setContentView() before using {@link #getTabModelSelector()} or |
| 351 * {@link #getCompositorViewHolder()}. | 350 * {@link #getCompositorViewHolder()}. |
| 352 */ | 351 */ |
| 353 @Override | 352 @Override |
| 354 protected final void setContentView() { | 353 protected final void setContentView() { |
| 355 final long begin = SystemClock.elapsedRealtime(); | 354 final long begin = SystemClock.elapsedRealtime(); |
| 356 TraceEvent.begin("onCreate->setContentView()"); | 355 TraceEvent.begin("onCreate->setContentView()"); |
| 357 | 356 |
| 358 enableHardwareAcceleration(); | 357 enableHardwareAcceleration(); |
| 359 setLowEndTheme(); | 358 setLowEndTheme(); |
| 359 ControlContainer controlContainer = null; | |
|
Ian Wen
2017/01/17 18:39:47
Why this line? IIUC you are not using the variable
mdjones
2017/01/17 21:29:45
Code was previously more spread out, fixed.
| |
| 360 int controlContainerLayoutId = getControlContainerLayoutId(); | 360 int controlContainerLayoutId = getControlContainerLayoutId(); |
| 361 WarmupManager warmupManager = WarmupManager.getInstance(); | 361 WarmupManager warmupManager = WarmupManager.getInstance(); |
| 362 if (warmupManager.hasViewHierarchyWithToolbar(controlContainerLayoutId)) { | 362 if (warmupManager.hasViewHierarchyWithToolbar(controlContainerLayoutId)) { |
| 363 View placeHolderView = new View(this); | 363 View placeHolderView = new View(this); |
| 364 setContentView(placeHolderView); | 364 setContentView(placeHolderView); |
| 365 ViewGroup contentParent = (ViewGroup) placeHolderView.getParent(); | 365 ViewGroup contentParent = (ViewGroup) placeHolderView.getParent(); |
| 366 warmupManager.transferViewHierarchyTo(contentParent); | 366 warmupManager.transferViewHierarchyTo(contentParent); |
| 367 contentParent.removeView(placeHolderView); | 367 contentParent.removeView(placeHolderView); |
| 368 } else { | 368 } else { |
| 369 warmupManager.clearViewHierarchy(); | 369 warmupManager.clearViewHierarchy(); |
| 370 | 370 |
| 371 // Allow disk access for the content view and toolbar container setu p. | 371 // Allow disk access for the content view and toolbar container setu p. |
| 372 // On certain android devices this setup sequence results in disk wr ites outside | 372 // On certain android devices this setup sequence results in disk wr ites outside |
| 373 // of our control, so we have to disable StrictMode to work. See crb ug.com/639352. | 373 // of our control, so we have to disable StrictMode to work. See crb ug.com/639352. |
| 374 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites (); | 374 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites (); |
| 375 try { | 375 try { |
| 376 setContentView(R.layout.main); | 376 setContentView(R.layout.main); |
| 377 if (controlContainerLayoutId != NO_CONTROL_CONTAINER) { | 377 if (controlContainerLayoutId != NO_CONTROL_CONTAINER) { |
| 378 ViewStub toolbarContainerStub = | 378 ViewStub toolbarContainerStub = |
| 379 ((ViewStub) findViewById(R.id.control_container_stub )); | 379 ((ViewStub) findViewById(R.id.control_container_stub )); |
| 380 | 380 |
| 381 toolbarContainerStub.setLayoutResource(controlContainerLayou tId); | 381 toolbarContainerStub.setLayoutResource(controlContainerLayou tId); |
| 382 View container = toolbarContainerStub.inflate(); | 382 View container = toolbarContainerStub.inflate(); |
| 383 | |
| 384 // If the control container is at the bottom apply Gravity.B OTTOM here since | |
| 385 // it is not respected in the XML while the ViewStub in betw een the | |
| 386 // CompositorViewHolder and ControlContainer. | |
| 387 if (controlContainerLayoutId == R.layout.bottom_control_cont ainer) { | |
| 388 ((LayoutParams) container.getLayoutParams()).gravity = G ravity.BOTTOM; | |
| 389 } | |
| 390 } | 383 } |
| 391 | 384 |
| 392 // It cannot be assumed that the result of toolbarContainerStub. inflate() will be | 385 // It cannot be assumed that the result of toolbarContainerStub. inflate() will be |
| 393 // the control container since it may be wrapped in another view . | 386 // the control container since it may be wrapped in another view . |
| 394 ControlContainer controlContainer = | 387 controlContainer = (ControlContainer) findViewById(R.id.control_ container); |
| 395 (ControlContainer) findViewById(R.id.control_container); | 388 |
| 389 // Get a handle to the bottom sheet if using the bottom control container. | |
| 390 if (controlContainerLayoutId == R.layout.bottom_control_containe r) { | |
| 391 View coordinator = findViewById(R.id.coordinator); | |
| 392 BottomSheet bottomSheet = (BottomSheet) findViewById(R.id.bo ttom_sheet); | |
| 393 bottomSheet.init(coordinator, controlContainer.getView()); | |
| 394 } | |
| 396 | 395 |
| 397 // Inflate the correct toolbar layout for the device. | 396 // Inflate the correct toolbar layout for the device. |
| 398 int toolbarLayoutId = getToolbarLayoutId(); | 397 int toolbarLayoutId = getToolbarLayoutId(); |
| 399 if (toolbarLayoutId != NO_TOOLBAR_LAYOUT && controlContainer != null) { | 398 if (toolbarLayoutId != NO_TOOLBAR_LAYOUT && controlContainer != null) { |
| 400 controlContainer.initWithToolbar(toolbarLayoutId); | 399 controlContainer.initWithToolbar(toolbarLayoutId); |
| 401 } | 400 } |
| 402 } finally { | 401 } finally { |
| 403 StrictMode.setThreadPolicy(oldPolicy); | 402 StrictMode.setThreadPolicy(oldPolicy); |
| 404 } | 403 } |
| 405 } | 404 } |
| (...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1956 "Android.MultiWindowMode.IsTabletScreenWidthBelow600", | 1955 "Android.MultiWindowMode.IsTabletScreenWidthBelow600", |
| 1957 mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP); | 1956 mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP); |
| 1958 | 1957 |
| 1959 if (mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) { | 1958 if (mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) { |
| 1960 RecordHistogram.recordLinearCountHistogram( | 1959 RecordHistogram.recordLinearCountHistogram( |
| 1961 "Android.MultiWindowMode.TabletScreenWidth", mScreenWidthDp, 1, | 1960 "Android.MultiWindowMode.TabletScreenWidth", mScreenWidthDp, 1, |
| 1962 DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP, 50); | 1961 DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP, 50); |
| 1963 } | 1962 } |
| 1964 } | 1963 } |
| 1965 } | 1964 } |
| OLD | NEW |