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

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

Issue 10660021: HiDPI assets for omnibox icons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cros Created 8 years, 6 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 #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/property_bag.h" 9 #include "base/property_bag.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // read. 123 // read.
124 NSRange ComponentToNSRange(const url_parse::Component& component) { 124 NSRange ComponentToNSRange(const url_parse::Component& component) {
125 return NSMakeRange(static_cast<NSInteger>(component.begin), 125 return NSMakeRange(static_cast<NSInteger>(component.begin),
126 static_cast<NSInteger>(component.len)); 126 static_cast<NSInteger>(component.len));
127 } 127 }
128 128
129 } // namespace 129 } // namespace
130 130
131 // static 131 // static
132 NSImage* OmniboxViewMac::ImageForResource(int resource_id) { 132 NSImage* OmniboxViewMac::ImageForResource(int resource_id) {
133 NSString* image_name = nil;
134
135 switch(resource_id) {
136 // Values from |AutocompleteMatch::TypeToIcon()|.
137 case IDR_OMNIBOX_SEARCH:
138 image_name = @"omnibox_search.pdf"; break;
139 case IDR_OMNIBOX_HTTP:
140 image_name = @"omnibox_http.pdf"; break;
141 case IDR_OMNIBOX_EXTENSION_APP:
142 image_name = @"omnibox_extension_app.pdf"; break;
143
144 // Values from |ToolbarModel::GetIcon()|.
145 case IDR_OMNIBOX_HTTPS_VALID:
146 image_name = @"omnibox_https_valid.pdf"; break;
147 case IDR_OMNIBOX_HTTPS_WARNING:
148 image_name = @"omnibox_https_warning.pdf"; break;
149 case IDR_OMNIBOX_HTTPS_INVALID:
150 image_name = @"omnibox_https_invalid.pdf"; break;
151 }
152
153 if (image_name) {
154 if (NSImage* image = gfx::GetCachedImageWithName(image_name)) {
155 return image;
156 } else {
157 NOTREACHED()
158 << "Missing image for " << base::SysNSStringToUTF8(image_name);
159 }
160 }
161
162 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 133 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
163 return rb.GetNativeImageNamed(resource_id); 134 return rb.GetNativeImageNamed(resource_id);
164 } 135 }
165 136
166 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller, 137 OmniboxViewMac::OmniboxViewMac(OmniboxEditController* controller,
167 ToolbarModel* toolbar_model, 138 ToolbarModel* toolbar_model,
168 Profile* profile, 139 Profile* profile,
169 CommandUpdater* command_updater, 140 CommandUpdater* command_updater,
170 AutocompleteTextField* field) 141 AutocompleteTextField* field)
171 : model_(new OmniboxEditModel(this, controller, profile)), 142 : model_(new OmniboxEditModel(this, controller, profile)),
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 1044
1074 void OmniboxViewMac::PlaceCaretAt(NSUInteger pos) { 1045 void OmniboxViewMac::PlaceCaretAt(NSUInteger pos) {
1075 DCHECK(pos <= GetTextLength()); 1046 DCHECK(pos <= GetTextLength());
1076 SetSelectedRange(NSMakeRange(pos, pos)); 1047 SetSelectedRange(NSMakeRange(pos, pos));
1077 } 1048 }
1078 1049
1079 bool OmniboxViewMac::IsCaretAtEnd() const { 1050 bool OmniboxViewMac::IsCaretAtEnd() const {
1080 const NSRange selection = GetSelectedRange(); 1051 const NSRange selection = GetSelectedRange();
1081 return selection.length == 0 && selection.location == GetTextLength(); 1052 return selection.length == 0 && selection.location == GetTextLength();
1082 } 1053 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm ('k') | chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698