Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java

Issue 2410603002: Inflate toolbar layouts in ControlContainer (Closed)
Patch Set: fix ID Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 */ 159 */
160 public AppMenuHandler get(Activity activity, AppMenuPropertiesDelegate d elegate, 160 public AppMenuHandler get(Activity activity, AppMenuPropertiesDelegate d elegate,
161 int menuResourceId); 161 int menuResourceId);
162 } 162 }
163 163
164 /** 164 /**
165 * No control container to inflate during initialization. 165 * No control container to inflate during initialization.
166 */ 166 */
167 static final int NO_CONTROL_CONTAINER = -1; 167 static final int NO_CONTROL_CONTAINER = -1;
168 168
169 /**
170 * No toolbar layout to inflate during initialization.
171 */
172 static final int NO_TOOLBAR_LAYOUT = -1;
173
169 private static final int RECORD_MULTI_WINDOW_SCREEN_WIDTH_DELAY_MS = 5000; 174 private static final int RECORD_MULTI_WINDOW_SCREEN_WIDTH_DELAY_MS = 5000;
170 175
171 /** 176 /**
172 * Timeout in ms for reading PartnerBrowserCustomizations provider. 177 * Timeout in ms for reading PartnerBrowserCustomizations provider.
173 */ 178 */
174 private static final int PARTNER_BROWSER_CUSTOMIZATIONS_TIMEOUT_MS = 10000; 179 private static final int PARTNER_BROWSER_CUSTOMIZATIONS_TIMEOUT_MS = 10000;
175 private static final String TAG = "ChromeActivity"; 180 private static final String TAG = "ChromeActivity";
176 private static final Rect EMPTY_RECT = new Rect(); 181 private static final Rect EMPTY_RECT = new Rect();
177 182
178 private TabModelSelector mTabModelSelector; 183 private TabModelSelector mTabModelSelector;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 warmupManager.transferViewHierarchyTo(contentParent); 349 warmupManager.transferViewHierarchyTo(contentParent);
345 contentParent.removeView(placeHolderView); 350 contentParent.removeView(placeHolderView);
346 } else { 351 } else {
347 warmupManager.clearViewHierarchy(); 352 warmupManager.clearViewHierarchy();
348 353
349 // Allow disk access for the content view and toolbar container setu p. 354 // Allow disk access for the content view and toolbar container setu p.
350 // On certain android devices this setup sequence results in disk wr ites outside 355 // On certain android devices this setup sequence results in disk wr ites outside
351 // of our control, so we have to disable StrictMode to work. See crb ug.com/639352. 356 // of our control, so we have to disable StrictMode to work. See crb ug.com/639352.
352 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites (); 357 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites ();
353 try { 358 try {
359 ControlContainer controlContainer = null;
354 setContentView(R.layout.main); 360 setContentView(R.layout.main);
355 if (controlContainerLayoutId != NO_CONTROL_CONTAINER) { 361 if (controlContainerLayoutId != NO_CONTROL_CONTAINER) {
356 ViewStub toolbarContainerStub = 362 ViewStub toolbarContainerStub =
357 ((ViewStub) findViewById(R.id.control_container_stub )); 363 ((ViewStub) findViewById(R.id.control_container_stub ));
358 toolbarContainerStub.setLayoutResource(controlContainerLayou tId); 364 toolbarContainerStub.setLayoutResource(controlContainerLayou tId);
359 toolbarContainerStub.inflate(); 365 controlContainer = (ControlContainer) toolbarContainerStub.i nflate();
366 }
367
368 // Inflate the correct toolbar layout for the device.
369 int toolbarLayoutId = getToolbarLayoutId();
370 if (toolbarLayoutId != NO_TOOLBAR_LAYOUT && controlContainer != null) {
371 controlContainer.initWithToolbar(toolbarLayoutId);
360 } 372 }
361 } finally { 373 } finally {
362 StrictMode.setThreadPolicy(oldPolicy); 374 StrictMode.setThreadPolicy(oldPolicy);
363 } 375 }
364 } 376 }
365 TraceEvent.end("onCreate->setContentView()"); 377 TraceEvent.end("onCreate->setContentView()");
366 mInflateInitialLayoutDurationMs = SystemClock.elapsedRealtime() - begin; 378 mInflateInitialLayoutDurationMs = SystemClock.elapsedRealtime() - begin;
367 379
368 // Set the status bar color to black by default. This is an optimization for 380 // Set the status bar color to black by default. This is an optimization for
369 // Chrome not to draw under status and navigation bars when we use the d efault 381 // Chrome not to draw under status and navigation bars when we use the d efault
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 } 469 }
458 470
459 /** 471 /**
460 * @return The resource id for the layout to use for {@link ControlContainer }. 0 by default. 472 * @return The resource id for the layout to use for {@link ControlContainer }. 0 by default.
461 */ 473 */
462 protected int getControlContainerLayoutId() { 474 protected int getControlContainerLayoutId() {
463 return NO_CONTROL_CONTAINER; 475 return NO_CONTROL_CONTAINER;
464 } 476 }
465 477
466 /** 478 /**
479 * @return The layout ID for the toolbar to use.
480 */
481 protected int getToolbarLayoutId() {
482 return NO_TOOLBAR_LAYOUT;
483 }
484
485 /**
467 * @return Whether contextual search is allowed for this activity or not. 486 * @return Whether contextual search is allowed for this activity or not.
468 */ 487 */
469 protected boolean isContextualSearchAllowed() { 488 protected boolean isContextualSearchAllowed() {
470 return true; 489 return true;
471 } 490 }
472 491
473 @Override 492 @Override
474 public void initializeState() { 493 public void initializeState() {
475 super.initializeState(); 494 super.initializeState();
476 mBlimpClientContextDelegate = 495 mBlimpClientContextDelegate =
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 "Android.MultiWindowMode.IsTabletScreenWidthBelow600", 1869 "Android.MultiWindowMode.IsTabletScreenWidthBelow600",
1851 mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP); 1870 mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP);
1852 1871
1853 if (mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) { 1872 if (mScreenWidthDp < DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) {
1854 RecordHistogram.recordLinearCountHistogram( 1873 RecordHistogram.recordLinearCountHistogram(
1855 "Android.MultiWindowMode.TabletScreenWidth", mScreenWidthDp, 1, 1874 "Android.MultiWindowMode.TabletScreenWidth", mScreenWidthDp, 1,
1856 DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP, 50); 1875 DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP, 50);
1857 } 1876 }
1858 } 1877 }
1859 } 1878 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698