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 #include <UIKit/UIKit.h> | 5 #include <UIKit/UIKit.h> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "ios/chrome/browser/ui/ui_util.h" | 22 #include "ios/chrome/browser/ui/ui_util.h" |
23 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 23 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
24 #include "ios/chrome/grit/ios_strings.h" | 24 #include "ios/chrome/grit/ios_strings.h" |
25 #include "ios/chrome/grit/ios_theme_resources.h" | 25 #include "ios/chrome/grit/ios_theme_resources.h" |
26 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 26 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
27 #include "ios/web/public/navigation_item.h" | 27 #include "ios/web/public/navigation_item.h" |
28 #include "ios/web/public/navigation_manager.h" | 28 #include "ios/web/public/navigation_manager.h" |
29 #include "ios/web/public/ssl_status.h" | 29 #include "ios/web/public/ssl_status.h" |
30 #include "ios/web/public/web_state/web_state.h" | 30 #include "ios/web/public/web_state/web_state.h" |
31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
32 #include "ui/base/resource/resource_bundle.h" | |
33 #include "ui/gfx/geometry/rect.h" | |
34 #include "ui/gfx/image/image.h" | |
35 | 32 |
36 namespace { | 33 namespace { |
37 const CGFloat kClearTextButtonWidth = 28; | 34 const CGFloat kClearTextButtonWidth = 28; |
38 const CGFloat kClearTextButtonHeight = 28; | 35 const CGFloat kClearTextButtonHeight = 28; |
39 | 36 |
40 // Workaround for https://crbug.com/527084 . If there is connection | 37 // Workaround for https://crbug.com/527084 . If there is connection |
41 // information, always show the icon. Remove this once connection info | 38 // information, always show the icon. Remove this once connection info |
42 // is available via other UI: https://crbug.com/533581 | 39 // is available via other UI: https://crbug.com/533581 |
43 bool DoesCurrentPageHaveCertInfo(web::WebState* webState) { | 40 bool DoesCurrentPageHaveCertInfo(web::WebState* webState) { |
44 if (!webState) | 41 if (!webState) |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 ToolbarModel* LocationBarViewIOS::GetToolbarModel() { | 250 ToolbarModel* LocationBarViewIOS::GetToolbarModel() { |
254 return [delegate_ toolbarModel]; | 251 return [delegate_ toolbarModel]; |
255 } | 252 } |
256 | 253 |
257 web::WebState* LocationBarViewIOS::GetWebState() { | 254 web::WebState* LocationBarViewIOS::GetWebState() { |
258 return [delegate_ getWebState]; | 255 return [delegate_ getWebState]; |
259 } | 256 } |
260 | 257 |
261 void LocationBarViewIOS::InstallLocationIcon() { | 258 void LocationBarViewIOS::InstallLocationIcon() { |
262 // Set the placeholder for empty omnibox. | 259 // Set the placeholder for empty omnibox. |
263 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
264 gfx::Image magImage = rb.GetNativeImageNamed(IDR_IOS_OMNIBOX_SEARCH); | |
265 UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom]; | 260 UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom]; |
266 UIImage* image = magImage.ToUIImage(); | 261 UIImage* image = NativeImage(IDR_IOS_OMNIBOX_SEARCH); |
267 [button setImage:image forState:UIControlStateNormal]; | 262 [button setImage:image forState:UIControlStateNormal]; |
268 [button setFrame:CGRectMake(0, 0, image.size.width, image.size.height)]; | 263 [button setFrame:CGRectMake(0, 0, image.size.width, image.size.height)]; |
269 [button addTarget:nil | 264 [button addTarget:nil |
270 action:@selector(chromeExecuteCommand:) | 265 action:@selector(chromeExecuteCommand:) |
271 forControlEvents:UIControlEventTouchUpInside]; | 266 forControlEvents:UIControlEventTouchUpInside]; |
272 [button setTag:IDC_SHOW_PAGE_INFO]; | 267 [button setTag:IDC_SHOW_PAGE_INFO]; |
273 SetA11yLabelAndUiAutomationName( | 268 SetA11yLabelAndUiAutomationName( |
274 button, IDS_IOS_PAGE_INFO_SECURITY_BUTTON_ACCESSIBILITY_LABEL, | 269 button, IDS_IOS_PAGE_INFO_SECURITY_BUTTON_ACCESSIBILITY_LABEL, |
275 @"Page Security Info"); | 270 @"Page Security Info"); |
276 [button setIsAccessibilityElement:YES]; | 271 [button setIsAccessibilityElement:YES]; |
277 | 272 |
278 // Set chip text options. | 273 // Set chip text options. |
279 [button setTitleColor:[UIColor colorWithWhite:0.631 alpha:1] | 274 [button setTitleColor:[UIColor colorWithWhite:0.631 alpha:1] |
280 forState:UIControlStateNormal]; | 275 forState:UIControlStateNormal]; |
281 [button titleLabel].font = | 276 [button titleLabel].font = |
282 [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:12]; | 277 [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:12]; |
283 [field_ setLeftView:button]; | 278 [field_ setLeftView:button]; |
284 | 279 |
285 // The placeholder image is only shown when in edit mode on iPhone, and always | 280 // The placeholder image is only shown when in edit mode on iPhone, and always |
286 // shown on iPad. | 281 // shown on iPad. |
287 if (IsIPadIdiom()) | 282 if (IsIPadIdiom()) |
288 [field_ setLeftViewMode:UITextFieldViewModeAlways]; | 283 [field_ setLeftViewMode:UITextFieldViewModeAlways]; |
289 else | 284 else |
290 [field_ setLeftViewMode:UITextFieldViewModeNever]; | 285 [field_ setLeftViewMode:UITextFieldViewModeNever]; |
291 } | 286 } |
292 | 287 |
293 void LocationBarViewIOS::CreateClearTextIcon(bool is_incognito) { | 288 void LocationBarViewIOS::CreateClearTextIcon(bool is_incognito) { |
294 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
295 UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom]; | 289 UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom]; |
296 UIImage* omniBoxClearImage = | 290 UIImage* omniBoxClearImage = is_incognito |
297 is_incognito | 291 ? NativeImage(IDR_IOS_OMNIBOX_CLEAR_OTR) |
298 ? rb.GetNativeImageNamed(IDR_IOS_OMNIBOX_CLEAR_OTR).ToUIImage() | 292 : NativeImage(IDR_IOS_OMNIBOX_CLEAR); |
299 : rb.GetNativeImageNamed(IDR_IOS_OMNIBOX_CLEAR).ToUIImage(); | |
300 UIImage* omniBoxClearPressedImage = | 293 UIImage* omniBoxClearPressedImage = |
301 is_incognito | 294 is_incognito ? NativeImage(IDR_IOS_OMNIBOX_CLEAR_OTR_PRESSED) |
302 ? rb.GetNativeImageNamed(IDR_IOS_OMNIBOX_CLEAR_OTR_PRESSED) | 295 : NativeImage(IDR_IOS_OMNIBOX_CLEAR_PRESSED); |
303 .ToUIImage() | |
304 : rb.GetNativeImageNamed(IDR_IOS_OMNIBOX_CLEAR_PRESSED).ToUIImage(); | |
305 [button setImage:omniBoxClearImage forState:UIControlStateNormal]; | 296 [button setImage:omniBoxClearImage forState:UIControlStateNormal]; |
306 [button setImage:omniBoxClearPressedImage forState:UIControlStateHighlighted]; | 297 [button setImage:omniBoxClearPressedImage forState:UIControlStateHighlighted]; |
307 | 298 |
308 CGRect frame = CGRectZero; | 299 CGRect frame = CGRectZero; |
309 frame.size = CGSizeMake(kClearTextButtonWidth, kClearTextButtonHeight); | 300 frame.size = CGSizeMake(kClearTextButtonWidth, kClearTextButtonHeight); |
310 [button setFrame:frame]; | 301 [button setFrame:frame]; |
311 | 302 |
312 clear_button_bridge_.reset( | 303 clear_button_bridge_.reset( |
313 [[OmniboxClearButtonBridge alloc] initWithOmniboxView:edit_view_.get()]); | 304 [[OmniboxClearButtonBridge alloc] initWithOmniboxView:edit_view_.get()]); |
314 [button addTarget:clear_button_bridge_ | 305 [button addTarget:clear_button_bridge_ |
(...skipping 13 matching lines...) Expand all Loading... |
328 if (IsIPadIdiom()) | 319 if (IsIPadIdiom()) |
329 [field_ setRightView:nil]; | 320 [field_ setRightView:nil]; |
330 } else if ([field_ displayedText].empty() && | 321 } else if ([field_ displayedText].empty() && |
331 ![field_ isShowingQueryRefinementChip]) { | 322 ![field_ isShowingQueryRefinementChip]) { |
332 [field_ setRightView:nil]; | 323 [field_ setRightView:nil]; |
333 } else { | 324 } else { |
334 [field_ setRightView:clear_text_button_]; | 325 [field_ setRightView:clear_text_button_]; |
335 [clear_text_button_ setAlpha:1]; | 326 [clear_text_button_ setAlpha:1]; |
336 } | 327 } |
337 } | 328 } |
OLD | NEW |