Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(710)

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_view.cc

Issue 415073003: Move omnibox icons to components (1/2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Linux Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/ui/omnibox/omnibox_view.h" 8 #include "chrome/browser/ui/omnibox/omnibox_view.h"
9 9
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/autocomplete/autocomplete_match.h" 13 #include "chrome/browser/autocomplete/autocomplete_match.h"
14 #include "chrome/browser/search/search.h" 14 #include "chrome/browser/search/search.h"
15 #include "chrome/browser/search_engines/template_url_service_factory.h" 15 #include "chrome/browser/search_engines/template_url_service_factory.h"
16 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" 16 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h"
17 #include "chrome/browser/ui/toolbar/toolbar_model.h" 17 #include "chrome/browser/ui/toolbar/toolbar_model.h"
18 #include "components/search_engines/template_url.h" 18 #include "components/search_engines/template_url.h"
19 #include "components/search_engines/template_url_service.h" 19 #include "components/search_engines/template_url_service.h"
20 #include "grit/component_scaled_resources.h"
20 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
22 #include "grit/theme_resources.h"
21 #include "ui/base/clipboard/clipboard.h" 23 #include "ui/base/clipboard/clipboard.h"
22 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
23 25
24 // static 26 // static
25 base::string16 OmniboxView::StripJavascriptSchemas(const base::string16& text) { 27 base::string16 OmniboxView::StripJavascriptSchemas(const base::string16& text) {
26 const base::string16 kJsPrefix( 28 const base::string16 kJsPrefix(
27 base::ASCIIToUTF16(url::kJavaScriptScheme) + base::ASCIIToUTF16(":")); 29 base::ASCIIToUTF16(url::kJavaScriptScheme) + base::ASCIIToUTF16(":"));
28 base::string16 out(text); 30 base::string16 out(text);
29 while (StartsWith(out, kJsPrefix, false)) { 31 while (StartsWith(out, kJsPrefix, false)) {
30 base::TrimWhitespace(out.substr(kJsPrefix.length()), base::TRIM_LEADING, 32 base::TrimWhitespace(out.substr(kJsPrefix.length()), base::TRIM_LEADING,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 115 }
114 116
115 bool OmniboxView::IsEditingOrEmpty() const { 117 bool OmniboxView::IsEditingOrEmpty() const {
116 return (model_.get() && model_->user_input_in_progress()) || 118 return (model_.get() && model_->user_input_in_progress()) ||
117 (GetOmniboxTextLength() == 0); 119 (GetOmniboxTextLength() == 0);
118 } 120 }
119 121
120 int OmniboxView::GetIcon() const { 122 int OmniboxView::GetIcon() const {
121 if (!IsEditingOrEmpty()) 123 if (!IsEditingOrEmpty())
122 return controller_->GetToolbarModel()->GetIcon(); 124 return controller_->GetToolbarModel()->GetIcon();
123 return AutocompleteMatch::TypeToLocationBarIcon(model_.get() ? 125 int id = AutocompleteMatch::TypeToIcon(model_.get() ?
124 model_->CurrentTextType() : AutocompleteMatchType::URL_WHAT_YOU_TYPED); 126 model_->CurrentTextType() : AutocompleteMatchType::URL_WHAT_YOU_TYPED);
127 if (id == IDR_OMNIBOX_HTTP)
128 return IDR_LOCATION_BAR_HTTP;
129 return id;
Peter Kasting 2014/07/24 18:40:17 Nit: Simpler: return (id == IDR_OMNIBOX_HTTP) ?
hashimoto 2014/07/25 05:23:23 Done.
125 } 130 }
126 131
127 base::string16 OmniboxView::GetHintText() const { 132 base::string16 OmniboxView::GetHintText() const {
128 // If the user is in keyword mode (the "Search <some site>:" chip is showing) 133 // If the user is in keyword mode (the "Search <some site>:" chip is showing)
129 // then it doesn't make sense to show the "Search <default search engine>" 134 // then it doesn't make sense to show the "Search <default search engine>"
130 // hint text. 135 // hint text.
131 if (model_->is_keyword_selected()) 136 if (model_->is_keyword_selected())
132 return base::string16(); 137 return base::string16();
133 138
134 // Attempt to determine the default search provider and use that in the hint 139 // Attempt to determine the default search provider and use that in the hint
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // |profile| can be NULL in tests. 229 // |profile| can be NULL in tests.
225 if (profile) 230 if (profile)
226 model_.reset(new OmniboxEditModel(this, controller, profile)); 231 model_.reset(new OmniboxEditModel(this, controller, profile));
227 } 232 }
228 233
229 void OmniboxView::TextChanged() { 234 void OmniboxView::TextChanged() {
230 EmphasizeURLComponents(); 235 EmphasizeURLComponents();
231 if (model_.get()) 236 if (model_.get())
232 model_->OnChanged(); 237 model_->OnChanged();
233 } 238 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtk2ui/libgtk2ui.gyp ('k') | chrome/browser/ui/toolbar/toolbar_model_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698