| 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 #import <UIKit/UIKit.h> | 5 #import <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 12 matching lines...) Expand all Loading... |
| 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 | 32 |
| 33 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 34 #error "This file requires ARC support." |
| 35 #endif |
| 36 |
| 33 namespace { | 37 namespace { |
| 34 const CGFloat kClearTextButtonWidth = 28; | 38 const CGFloat kClearTextButtonWidth = 28; |
| 35 const CGFloat kClearTextButtonHeight = 28; | 39 const CGFloat kClearTextButtonHeight = 28; |
| 36 | 40 |
| 37 // Workaround for https://crbug.com/527084 . If there is connection | 41 // Workaround for https://crbug.com/527084 . If there is connection |
| 38 // information, always show the icon. Remove this once connection info | 42 // information, always show the icon. Remove this once connection info |
| 39 // is available via other UI: https://crbug.com/533581 | 43 // is available via other UI: https://crbug.com/533581 |
| 40 bool DoesCurrentPageHaveCertInfo(web::WebState* webState) { | 44 bool DoesCurrentPageHaveCertInfo(web::WebState* webState) { |
| 41 if (!webState) | 45 if (!webState) |
| 42 return false; | 46 return false; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 302 |
| 299 CGRect frame = CGRectZero; | 303 CGRect frame = CGRectZero; |
| 300 frame.size = CGSizeMake(kClearTextButtonWidth, kClearTextButtonHeight); | 304 frame.size = CGSizeMake(kClearTextButtonWidth, kClearTextButtonHeight); |
| 301 [button setFrame:frame]; | 305 [button setFrame:frame]; |
| 302 | 306 |
| 303 clear_button_bridge_.reset( | 307 clear_button_bridge_.reset( |
| 304 [[OmniboxClearButtonBridge alloc] initWithOmniboxView:edit_view_.get()]); | 308 [[OmniboxClearButtonBridge alloc] initWithOmniboxView:edit_view_.get()]); |
| 305 [button addTarget:clear_button_bridge_ | 309 [button addTarget:clear_button_bridge_ |
| 306 action:@selector(clearText) | 310 action:@selector(clearText) |
| 307 forControlEvents:UIControlEventTouchUpInside]; | 311 forControlEvents:UIControlEventTouchUpInside]; |
| 308 clear_text_button_.reset([button retain]); | 312 clear_text_button_.reset(button); |
| 309 | 313 |
| 310 SetA11yLabelAndUiAutomationName(clear_text_button_, | 314 SetA11yLabelAndUiAutomationName(clear_text_button_, |
| 311 IDS_IOS_ACCNAME_CLEAR_TEXT, @"Clear Text"); | 315 IDS_IOS_ACCNAME_CLEAR_TEXT, @"Clear Text"); |
| 312 } | 316 } |
| 313 | 317 |
| 314 void LocationBarViewIOS::UpdateRightDecorations() { | 318 void LocationBarViewIOS::UpdateRightDecorations() { |
| 315 DCHECK(clear_text_button_); | 319 DCHECK(clear_text_button_); |
| 316 if (!edit_view_->model()->has_focus()) { | 320 if (!edit_view_->model()->has_focus()) { |
| 317 // Do nothing for iPhone. The right view will be set to nil after the | 321 // Do nothing for iPhone. The right view will be set to nil after the |
| 318 // omnibox animation is completed. | 322 // omnibox animation is completed. |
| 319 if (IsIPadIdiom()) | 323 if (IsIPadIdiom()) |
| 320 [field_ setRightView:nil]; | 324 [field_ setRightView:nil]; |
| 321 } else if ([field_ displayedText].empty() && | 325 } else if ([field_ displayedText].empty() && |
| 322 ![field_ isShowingQueryRefinementChip]) { | 326 ![field_ isShowingQueryRefinementChip]) { |
| 323 [field_ setRightView:nil]; | 327 [field_ setRightView:nil]; |
| 324 } else { | 328 } else { |
| 325 [field_ setRightView:clear_text_button_]; | 329 [field_ setRightView:clear_text_button_]; |
| 326 [clear_text_button_ setAlpha:1]; | 330 [clear_text_button_ setAlpha:1]; |
| 327 } | 331 } |
| 328 } | 332 } |
| OLD | NEW |