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

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

Issue 12463042: Shows chrome-extension urls and greys out the whole url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: No longer involves toolbar model Created 7 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/string_util.h" 10 #include "base/string_util.h"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/autocomplete/autocomplete_input.h" 13 #include "chrome/browser/autocomplete/autocomplete_input.h"
14 #include "chrome/browser/autocomplete/autocomplete_match.h" 14 #include "chrome/browser/autocomplete/autocomplete_match.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/search/search.h" 17 #include "chrome/browser/search/search.h"
18 #include "chrome/browser/ui/cocoa/event_utils.h" 18 #include "chrome/browser/ui/cocoa/event_utils.h"
19 #include "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" 19 #include "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
20 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" 20 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h"
21 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" 21 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h"
22 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" 22 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h"
23 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 23 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
24 #include "chrome/browser/ui/toolbar/toolbar_model.h" 24 #include "chrome/browser/ui/toolbar/toolbar_model.h"
25 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
26 #include "extensions/common/constants.h"
26 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
27 #include "grit/theme_resources.h" 28 #include "grit/theme_resources.h"
28 #import "third_party/mozilla/NSPasteboard+Utils.h" 29 #import "third_party/mozilla/NSPasteboard+Utils.h"
29 #include "ui/base/clipboard/clipboard.h" 30 #include "ui/base/clipboard/clipboard.h"
30 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
31 #include "ui/gfx/rect.h" 32 #include "ui/gfx/rect.h"
32 33
33 using content::WebContents; 34 using content::WebContents;
34 35
35 // Focus-handling between |field_| and model() is a bit subtle. 36 // Focus-handling between |field_| and model() is a bit subtle.
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 scoped_nsobject<NSMutableParagraphStyle> 442 scoped_nsobject<NSMutableParagraphStyle>
442 paragraph_style([[NSMutableParagraphStyle alloc] init]); 443 paragraph_style([[NSMutableParagraphStyle alloc] init]);
443 [paragraph_style setMaximumLineHeight:line_height_]; 444 [paragraph_style setMaximumLineHeight:line_height_];
444 [paragraph_style setMinimumLineHeight:line_height_]; 445 [paragraph_style setMinimumLineHeight:line_height_];
445 [as addAttribute:NSParagraphStyleAttributeName value:paragraph_style 446 [as addAttribute:NSParagraphStyleAttributeName value:paragraph_style
446 range:as_entire_string]; 447 range:as_entire_string];
447 448
448 url_parse::Component scheme, host; 449 url_parse::Component scheme, host;
449 AutocompleteInput::ParseForEmphasizeComponents( 450 AutocompleteInput::ParseForEmphasizeComponents(
450 display_text, &scheme, &host); 451 display_text, &scheme, &host);
451 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0); 452 bool grey_out_url = GetText().substr(scheme.begin, scheme.len) ==
Peter Kasting 2013/04/11 23:10:40 Use |display_text| here instead of GetText().
Patrick Riordan 2013/04/11 23:27:38 Done. Sorry. This patch set was sloppy.
452 if (emphasize) { 453 UTF8toUTF16(extensions::kExtensionScheme);
454 if (model()->currentTextIsURL() &&
455 (host.is_nonempty() || grey_out_url)) {
453 [as addAttribute:NSForegroundColorAttributeName value:BaseTextColor() 456 [as addAttribute:NSForegroundColorAttributeName value:BaseTextColor()
454 range:as_entire_string]; 457 range:as_entire_string];
455 458
456 [as addAttribute:NSForegroundColorAttributeName value:HostTextColor() 459 if (grey_out_url) {
Peter Kasting 2013/04/11 23:10:40 Isn't this conditional backwards?
Patrick Riordan 2013/04/11 23:27:38 Done.
460 [as addAttribute:NSForegroundColorAttributeName value:HostTextColor()
457 range:ComponentToNSRange(host)]; 461 range:ComponentToNSRange(host)];
462 }
458 } 463 }
459 464
460 // TODO(shess): GTK has this as a member var, figure out why. 465 // TODO(shess): GTK has this as a member var, figure out why.
461 // [Could it be to not change if no change? If so, I'm guessing 466 // [Could it be to not change if no change? If so, I'm guessing
462 // AppKit may already handle that.] 467 // AppKit may already handle that.]
463 const ToolbarModel::SecurityLevel security_level = 468 const ToolbarModel::SecurityLevel security_level =
464 toolbar_model()->GetSecurityLevel(); 469 toolbar_model()->GetSecurityLevel();
465 470
466 // Emphasize the scheme for security UI display purposes (if necessary). 471 // Emphasize the scheme for security UI display purposes (if necessary).
467 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && 472 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() &&
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 973
969 NSUInteger OmniboxViewMac::GetTextLength() const { 974 NSUInteger OmniboxViewMac::GetTextLength() const {
970 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : 975 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] :
971 [[field_ stringValue] length]; 976 [[field_ stringValue] length];
972 } 977 }
973 978
974 bool OmniboxViewMac::IsCaretAtEnd() const { 979 bool OmniboxViewMac::IsCaretAtEnd() const {
975 const NSRange selection = GetSelectedRange(); 980 const NSRange selection = GetSelectedRange();
976 return NSMaxRange(selection) == GetTextLength(); 981 return NSMaxRange(selection) == GetTextLength();
977 } 982 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698