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

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm

Issue 1104513003: Omnibox: Remove Hint Text Code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed WITH_DEFAULT_SEARCH_PROVIDER part of string Created 5 years, 8 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
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 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
6 6
7 #include <Carbon/Carbon.h> // kVK_Return 7 #include <Carbon/Carbon.h> // kVK_Return
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 [[field_ currentEditor] setSelectedRange:state->selection]; 207 [[field_ currentEditor] setSelectedRange:state->selection];
208 #endif 208 #endif
209 } 209 }
210 } 210 }
211 211
212 void OmniboxViewMac::ResetTabState(WebContents* web_contents) { 212 void OmniboxViewMac::ResetTabState(WebContents* web_contents) {
213 StoreStateToTab(web_contents, nullptr); 213 StoreStateToTab(web_contents, nullptr);
214 } 214 }
215 215
216 void OmniboxViewMac::Update() { 216 void OmniboxViewMac::Update() {
217 UpdatePlaceholderText();
218
219 if (model()->UpdatePermanentText()) { 217 if (model()->UpdatePermanentText()) {
220 // Something visibly changed. Re-enable URL replacement. 218 // Something visibly changed. Re-enable URL replacement.
221 controller()->GetToolbarModel()->set_url_replacement_enabled(true); 219 controller()->GetToolbarModel()->set_url_replacement_enabled(true);
222 model()->UpdatePermanentText(); 220 model()->UpdatePermanentText();
223 221
224 // Restore everything to the baseline look. 222 // Restore everything to the baseline look.
225 RevertAll(); 223 RevertAll();
226 224
227 // TODO(shess): Figure out how this case is used, to make sure 225 // TODO(shess): Figure out how this case is used, to make sure
228 // we're getting the selection and popup right. 226 // we're getting the selection and popup right.
229 } else { 227 } else {
230 // TODO(shess): This corresponds to _win and _gtk, except those 228 // TODO(shess): This corresponds to _win and _gtk, except those
231 // guard it with a test for whether the security level changed. 229 // guard it with a test for whether the security level changed.
232 // But AFAICT, that can only change if the text changed, and that 230 // But AFAICT, that can only change if the text changed, and that
233 // code compares the toolbar model security level with the local 231 // code compares the toolbar model security level with the local
234 // security level. Dig in and figure out why this isn't a no-op 232 // security level. Dig in and figure out why this isn't a no-op
235 // that should go away. 233 // that should go away.
236 EmphasizeURLComponents(); 234 EmphasizeURLComponents();
237 } 235 }
238 } 236 }
239 237
240 void OmniboxViewMac::UpdatePlaceholderText() {
241 if (OmniboxFieldTrial::DisplayHintTextWhenPossible()) {
242 NSDictionary* placeholder_attributes = @{
243 NSForegroundColorAttributeName : [NSColor disabledControlTextColor]
244 };
245 base::scoped_nsobject<NSMutableAttributedString> placeholder_text(
246 [[NSMutableAttributedString alloc]
247 initWithString:base::SysUTF16ToNSString(GetHintText())
248 attributes:placeholder_attributes]);
249 ApplyTextStyle(placeholder_text);
250 [[field_ cell] setPlaceholderAttributedString:placeholder_text];
251 }
252 }
253
254 void OmniboxViewMac::OpenMatch(const AutocompleteMatch& match, 238 void OmniboxViewMac::OpenMatch(const AutocompleteMatch& match,
255 WindowOpenDisposition disposition, 239 WindowOpenDisposition disposition,
256 const GURL& alternate_nav_url, 240 const GURL& alternate_nav_url,
257 const base::string16& pasted_text, 241 const base::string16& pasted_text,
258 size_t selected_line) { 242 size_t selected_line) {
259 // Coalesce text and selection updates from the following function. If we 243 // Coalesce text and selection updates from the following function. If we
260 // don't do this, the user may see intermediate states as brief flickers. 244 // don't do this, the user may see intermediate states as brief flickers.
261 in_coalesced_update_block_ = true; 245 in_coalesced_update_block_ = true;
262 OmniboxView::OpenMatch( 246 OmniboxView::OpenMatch(
263 match, disposition, alternate_nav_url, pasted_text, selected_line); 247 match, disposition, alternate_nav_url, pasted_text, selected_line);
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 1008
1025 NSUInteger OmniboxViewMac::GetTextLength() const { 1009 NSUInteger OmniboxViewMac::GetTextLength() const {
1026 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : 1010 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] :
1027 [[field_ stringValue] length]; 1011 [[field_ stringValue] length];
1028 } 1012 }
1029 1013
1030 bool OmniboxViewMac::IsCaretAtEnd() const { 1014 bool OmniboxViewMac::IsCaretAtEnd() const {
1031 const NSRange selection = GetSelectedRange(); 1015 const NSRange selection = GetSelectedRange();
1032 return NSMaxRange(selection) == GetTextLength(); 1016 return NSMaxRange(selection) == GetTextLength();
1033 } 1017 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h ('k') | chrome/browser/ui/omnibox/omnibox_edit_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698