Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file defines helper functions shared by the various implementations | 5 // This file defines helper functions shared by the various implementations |
| 6 // of OmniboxView. | 6 // of OmniboxView. |
| 7 | 7 |
| 8 #include "components/omnibox/browser/omnibox_view.h" | 8 #include "components/omnibox/browser/omnibox_view.h" |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 if (client) { | 178 if (client) { |
| 179 model_.reset(new OmniboxEditModel(this, controller, std::move(client))); | 179 model_.reset(new OmniboxEditModel(this, controller, std::move(client))); |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 void OmniboxView::TextChanged() { | 183 void OmniboxView::TextChanged() { |
| 184 EmphasizeURLComponents(); | 184 EmphasizeURLComponents(); |
| 185 if (model_.get()) | 185 if (model_.get()) |
| 186 model_->OnChanged(); | 186 model_->OnChanged(); |
| 187 } | 187 } |
| 188 | |
| 189 OmniboxView::DEEMPHASIZE_COMPONENTS OmniboxView::GetDeemphasis( | |
| 190 const base::string16& url_scheme, | |
| 191 const bool has_host) const { | |
| 192 OmniboxView::DEEMPHASIZE_COMPONENTS deemphasize = NOTHING; | |
|
Peter Kasting
2017/02/24 01:53:40
Nit: Can remove this variable, change assignments
| |
| 193 | |
| 194 // This constant is copied from extensions/common/constants.h to avoid | |
| 195 // complicated dependencies. | |
|
Peter Kasting
2017/02/24 01:53:40
Urgh.
Can we not have extensions/common/ in compo
| |
| 196 const char kExtensionScheme[] = "chrome-extension"; | |
| 197 | |
| 198 if (model_->CurrentTextIsURL()) { | |
| 199 // Extension IDs are not human-readable, so deemphasize everything to draw | |
| 200 // attention to the human-readable name in the location icon text. | |
| 201 if (url_scheme == base::UTF8ToUTF16(kExtensionScheme)) | |
| 202 deemphasize = EVERYTHING; | |
| 203 // Data URLs are rarely human-readable and can be used for spoofing, so draw | |
| 204 // attention to the scheme to emphasize "this is just a bunch of data". | |
| 205 else if (url_scheme == base::UTF8ToUTF16(url::kDataScheme)) | |
| 206 deemphasize = ALL_BUT_SCHEME; | |
| 207 // For normal URLs, the host is the best proxy for "identity". | |
| 208 else if (has_host) | |
| 209 deemphasize = ALL_BUT_HOST; | |
| 210 } | |
| 211 | |
| 212 return deemphasize; | |
| 213 } | |
| OLD | NEW |