| 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 | 8 |
| 9 import org.chromium.base.ApplicationStatus; | 9 import org.chromium.base.ApplicationStatus; |
| 10 import org.chromium.chrome.R; | 10 import org.chromium.chrome.R; |
| 11 import org.chromium.chrome.browser.Tab; | 11 import org.chromium.chrome.browser.Tab; |
| 12 import org.chromium.chrome.browser.ntp.NewTabPage; | 12 import org.chromium.chrome.browser.ntp.NewTabPage; |
| 13 import org.chromium.chrome.browser.tab.BackgroundContentViewHelper; | 13 import org.chromium.chrome.browser.tab.BackgroundContentViewHelper; |
| 14 import org.chromium.chrome.browser.tab.ChromeTab; | 14 import org.chromium.chrome.browser.tab.ChromeTab; |
| 15 import org.chromium.chrome.browser.toolbar.ToolbarModel.ToolbarModelDelegate; | 15 import org.chromium.chrome.browser.toolbar.ToolbarModel.ToolbarModelDelegate; |
| 16 import org.chromium.chrome.browser.util.FeatureUtilities; | 16 import org.chromium.chrome.browser.util.FeatureUtilities; |
| 17 import org.chromium.content_public.browser.WebContents; | 17 import org.chromium.content_public.browser.WebContents; |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * Contains the data and state for the toolbar. | 20 * Contains the data and state for the toolbar. |
| 21 */ | 21 */ |
| 22 class ToolbarModelImpl extends ToolbarModel implements ToolbarDataProvider, Tool
barModelDelegate { | 22 class ToolbarModelImpl extends ToolbarModel implements ToolbarDataProvider, Tool
barModelDelegate { |
| 23 | 23 |
| 24 private ChromeTab mTab; | 24 private ChromeTab mTab; |
| 25 private boolean mIsIncognito; | 25 private boolean mIsIncognito; |
| 26 private int mLoadProgress; | |
| 27 private int mPrimaryColor; | 26 private int mPrimaryColor; |
| 28 private boolean mIsUsingBrandColor; | 27 private boolean mIsUsingBrandColor; |
| 29 | 28 |
| 30 /** | 29 /** |
| 31 * Handle any initialization that must occur after native has been initializ
ed. | 30 * Handle any initialization that must occur after native has been initializ
ed. |
| 32 */ | 31 */ |
| 33 public void initializeWithNative() { | 32 public void initializeWithNative() { |
| 34 initialize(this); | 33 initialize(this); |
| 35 } | 34 } |
| 36 | 35 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 76 } |
| 78 return null; | 77 return null; |
| 79 } | 78 } |
| 80 | 79 |
| 81 @Override | 80 @Override |
| 82 public boolean isIncognito() { | 81 public boolean isIncognito() { |
| 83 return mIsIncognito; | 82 return mIsIncognito; |
| 84 } | 83 } |
| 85 | 84 |
| 86 /** | 85 /** |
| 87 * Set the load progress for the current tab. | |
| 88 * @param progress The loading progress for the tab. | |
| 89 */ | |
| 90 public void setLoadProgress(int progress) { | |
| 91 assert progress >= 0; | |
| 92 assert progress <= 100; | |
| 93 | |
| 94 mLoadProgress = progress; | |
| 95 } | |
| 96 | |
| 97 @Override | |
| 98 public int getLoadProgress() { | |
| 99 return mLoadProgress; | |
| 100 } | |
| 101 | |
| 102 /** | |
| 103 * Sets the primary color and changes the state for isUsingBrandColor. | 86 * Sets the primary color and changes the state for isUsingBrandColor. |
| 104 * @param color The primary color for the current tab. | 87 * @param color The primary color for the current tab. |
| 105 */ | 88 */ |
| 106 public void setPrimaryColor(int color) { | 89 public void setPrimaryColor(int color) { |
| 107 mPrimaryColor = color; | 90 mPrimaryColor = color; |
| 108 Context context = ApplicationStatus.getApplicationContext(); | 91 Context context = ApplicationStatus.getApplicationContext(); |
| 109 mIsUsingBrandColor = FeatureUtilities.isDocumentMode(context) | 92 mIsUsingBrandColor = FeatureUtilities.isDocumentMode(context) |
| 110 && !isIncognito() | 93 && !isIncognito() |
| 111 && mPrimaryColor != context.getResources().getColor(R.color.defa
ult_primary_color) | 94 && mPrimaryColor != context.getResources().getColor(R.color.defa
ult_primary_color) |
| 112 && getTab() != null && !getTab().isNativePage(); | 95 && getTab() != null && !getTab().isNativePage(); |
| 113 } | 96 } |
| 114 | 97 |
| 115 @Override | 98 @Override |
| 116 public int getPrimaryColor() { | 99 public int getPrimaryColor() { |
| 117 return mPrimaryColor; | 100 return mPrimaryColor; |
| 118 } | 101 } |
| 119 | 102 |
| 120 @Override | 103 @Override |
| 121 public boolean isUsingBrandColor() { | 104 public boolean isUsingBrandColor() { |
| 122 return mIsUsingBrandColor; | 105 return mIsUsingBrandColor; |
| 123 } | 106 } |
| 124 } | 107 } |
| OLD | NEW |