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.webapps; | 5 package org.chromium.chrome.browser.webapps; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.graphics.drawable.Drawable; | 8 import android.graphics.drawable.Drawable; |
9 import android.text.Layout; | 9 import android.text.Layout; |
10 import android.text.TextUtils; | 10 import android.text.TextUtils; |
11 import android.text.method.ScrollingMovementMethod; | 11 import android.text.method.ScrollingMovementMethod; |
12 import android.util.AttributeSet; | 12 import android.util.AttributeSet; |
13 import android.util.Log; | 13 import android.util.Log; |
14 import android.util.SparseIntArray; | 14 import android.util.SparseIntArray; |
15 import android.view.Gravity; | 15 import android.view.Gravity; |
16 import android.view.View; | 16 import android.view.View; |
17 import android.view.ViewGroup; | 17 import android.view.ViewGroup; |
18 import android.widget.FrameLayout; | 18 import android.widget.FrameLayout; |
19 import android.widget.TextView; | 19 import android.widget.TextView; |
20 | 20 |
21 import org.chromium.base.ApiCompatibilityUtils; | 21 import org.chromium.base.ApiCompatibilityUtils; |
22 import org.chromium.base.VisibleForTesting; | 22 import org.chromium.base.VisibleForTesting; |
23 import org.chromium.chrome.R; | 23 import org.chromium.chrome.R; |
24 import org.chromium.chrome.browser.omnibox.LocationBarLayout; | 24 import org.chromium.chrome.browser.omnibox.LocationBarLayout; |
25 import org.chromium.chrome.browser.util.UrlUtilities; | 25 import org.chromium.components.url_formatter.UrlFormatter; |
26 import org.chromium.ui.base.DeviceFormFactor; | 26 import org.chromium.ui.base.DeviceFormFactor; |
27 | 27 |
28 import java.net.URI; | 28 import java.net.URI; |
29 | 29 |
30 /** | 30 /** |
31 * Maintains a URL bar that is displayed above the webapp's content. | 31 * Maintains a URL bar that is displayed above the webapp's content. |
32 * For security reasons, this bar will appear when a user navigates to a website
that is not | 32 * For security reasons, this bar will appear when a user navigates to a website
that is not |
33 * considered the same as the one that was used to open a WebappActivity origina
lly. | 33 * considered the same as the one that was used to open a WebappActivity origina
lly. |
34 * The URL bar will disappear again once the user navigates back to the original
website. | 34 * The URL bar will disappear again once the user navigates back to the original
website. |
35 * | 35 * |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 158 } |
159 | 159 |
160 ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(mU
rlBar, | 160 ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(mU
rlBar, |
161 mCurrentIconResource, 0, 0, 0); | 161 mCurrentIconResource, 0, 0, 0); |
162 } | 162 } |
163 | 163 |
164 private void updateDisplayedUrl(String originalUrl, URI uri) { | 164 private void updateDisplayedUrl(String originalUrl, URI uri) { |
165 boolean showScheme = mCurrentIconResource == 0; | 165 boolean showScheme = mCurrentIconResource == 0; |
166 String displayUrl = originalUrl; | 166 String displayUrl = originalUrl; |
167 if (uri != null) { | 167 if (uri != null) { |
168 String shortenedUrl = UrlUtilities.formatUrlForSecurityDisplay(uri,
showScheme); | 168 String shortenedUrl = UrlFormatter.formatUrlForSecurityDisplay(uri,
showScheme); |
169 if (!TextUtils.isEmpty(shortenedUrl)) displayUrl = shortenedUrl; | 169 if (!TextUtils.isEmpty(shortenedUrl)) displayUrl = shortenedUrl; |
170 } | 170 } |
171 | 171 |
172 mUrlBar.setText(displayUrl); | 172 mUrlBar.setText(displayUrl); |
173 if (!TextUtils.equals(mCurrentlyDisplayedUrl, displayUrl)) { | 173 if (!TextUtils.equals(mCurrentlyDisplayedUrl, displayUrl)) { |
174 mCurrentlyDisplayedUrl = displayUrl; | 174 mCurrentlyDisplayedUrl = displayUrl; |
175 } | 175 } |
176 } | 176 } |
177 } | 177 } |
OLD | NEW |