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; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 try { | 142 try { |
143 return URI.create(url); | 143 return URI.create(url); |
144 } catch (IllegalArgumentException exception) { | 144 } catch (IllegalArgumentException exception) { |
145 Log.e(TAG, "Failed to convert URI: ", exception); | 145 Log.e(TAG, "Failed to convert URI: ", exception); |
146 return null; | 146 return null; |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 private void updateSecurityIcon(int securityLevel) { | 150 private void updateSecurityIcon(int securityLevel) { |
151 boolean isSmallDevice = !DeviceFormFactor.isTablet(getContext()); | 151 boolean isSmallDevice = !DeviceFormFactor.isTablet(); |
152 mCurrentIconResource = | 152 mCurrentIconResource = |
153 LocationBarLayout.getSecurityIconResource(securityLevel, isSmall
Device, false); | 153 LocationBarLayout.getSecurityIconResource(securityLevel, isSmall
Device, false); |
154 | 154 |
155 if (mCurrentIconResource != 0 && mIconResourceWidths.get(mCurrentIconRes
ource, -1) == -1) { | 155 if (mCurrentIconResource != 0 && mIconResourceWidths.get(mCurrentIconRes
ource, -1) == -1) { |
156 Drawable icon = ApiCompatibilityUtils.getDrawable(getResources(), mC
urrentIconResource); | 156 Drawable icon = ApiCompatibilityUtils.getDrawable(getResources(), mC
urrentIconResource); |
157 mIconResourceWidths.put(mCurrentIconResource, icon.getIntrinsicWidth
()); | 157 mIconResourceWidths.put(mCurrentIconResource, icon.getIntrinsicWidth
()); |
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 = UrlFormatter.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 |