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.toolbar; | 5 package org.chromium.chrome.browser.toolbar; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
9 import android.os.Handler; | 9 import android.os.Handler; |
10 import android.os.Looper; | 10 import android.os.Looper; |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 OnClickListener bookmarkClickHandler, | 499 OnClickListener bookmarkClickHandler, |
500 OnClickListener customTabsBackClickHandler) { | 500 OnClickListener customTabsBackClickHandler) { |
501 assert !mInitializedWithNative; | 501 assert !mInitializedWithNative; |
502 mTabModelSelector = tabModelSelector; | 502 mTabModelSelector = tabModelSelector; |
503 | 503 |
504 mToolbar.getLocationBar().updateVisualsForState(); | 504 mToolbar.getLocationBar().updateVisualsForState(); |
505 mToolbar.getLocationBar().setUrlToPageUrl(); | 505 mToolbar.getLocationBar().setUrlToPageUrl(); |
506 mToolbar.setOnTabSwitcherClickHandler(tabSwitcherClickHandler); | 506 mToolbar.setOnTabSwitcherClickHandler(tabSwitcherClickHandler); |
507 mToolbar.setOnNewTabClickHandler(newTabClickHandler); | 507 mToolbar.setOnNewTabClickHandler(newTabClickHandler); |
508 mToolbar.setBookmarkClickHandler(bookmarkClickHandler); | 508 mToolbar.setBookmarkClickHandler(bookmarkClickHandler); |
509 mToolbar.setCustomTabReturnClickHandler(customTabsBackClickHandler); | 509 mToolbar.setCustomTabCloseClickHandler(customTabsBackClickHandler); |
510 | 510 |
511 mToolbarModel.initializeWithNative(); | 511 mToolbarModel.initializeWithNative(); |
512 | 512 |
513 mToolbar.addOnAttachStateChangeListener(new OnAttachStateChangeListener(
) { | 513 mToolbar.addOnAttachStateChangeListener(new OnAttachStateChangeListener(
) { |
514 @Override | 514 @Override |
515 public void onViewDetachedFromWindow(View v) { | 515 public void onViewDetachedFromWindow(View v) { |
516 Context context = mToolbar.getContext(); | 516 Context context = mToolbar.getContext(); |
517 HomepageManager.getInstance(context).removeListener(mHomepageSta
teListener); | 517 HomepageManager.getInstance(context).removeListener(mHomepageSta
teListener); |
518 mTabModelSelector.removeObserver(mTabModelSelectorObserver); | 518 mTabModelSelector.removeObserver(mTabModelSelectorObserver); |
519 for (TabModel model : mTabModelSelector.getModels()) { | 519 for (TabModel model : mTabModelSelector.getModels()) { |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 */ | 790 */ |
791 public void updatePrimaryColor(int color) { | 791 public void updatePrimaryColor(int color) { |
792 boolean colorChanged = mToolbarModel.getPrimaryColor() != color; | 792 boolean colorChanged = mToolbarModel.getPrimaryColor() != color; |
793 if (!colorChanged) return; | 793 if (!colorChanged) return; |
794 | 794 |
795 mToolbarModel.setPrimaryColor(color); | 795 mToolbarModel.setPrimaryColor(color); |
796 mToolbar.onPrimaryColorChanged(); | 796 mToolbar.onPrimaryColorChanged(); |
797 } | 797 } |
798 | 798 |
799 /** | 799 /** |
| 800 * Sets the icon resource that the close button shows. |
| 801 */ |
| 802 public void setCloseButtonIcon(int iconRes) { |
| 803 mToolbar.setCloseButtonImageResource(iconRes); |
| 804 } |
| 805 |
| 806 /** |
800 * Sets whether a title should be shown within the Toolbar. | 807 * Sets whether a title should be shown within the Toolbar. |
801 * @param showTitle Whether a title should be shown. | 808 * @param showTitle Whether a title should be shown. |
802 */ | 809 */ |
803 public void setShowTitle(boolean showTitle) { | 810 public void setShowTitle(boolean showTitle) { |
804 mLocationBar.setShowTitle(showTitle); | 811 mLocationBar.setShowTitle(showTitle); |
805 } | 812 } |
806 | 813 |
807 /** | 814 /** |
808 * Focuses or unfocuses the URL bar. | 815 * Focuses or unfocuses the URL bar. |
809 * @param focused Whether URL bar should be focused. | 816 * @param focused Whether URL bar should be focused. |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 } | 1068 } |
1062 | 1069 |
1063 /** | 1070 /** |
1064 * Cancels simulating load progress. | 1071 * Cancels simulating load progress. |
1065 */ | 1072 */ |
1066 public void cancel() { | 1073 public void cancel() { |
1067 mHandler.removeMessages(MSG_ID_UPDATE_PROGRESS); | 1074 mHandler.removeMessages(MSG_ID_UPDATE_PROGRESS); |
1068 } | 1075 } |
1069 } | 1076 } |
1070 } | 1077 } |
OLD | NEW |