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

Side by Side Diff: ios/chrome/browser/ui/omnibox/omnibox_view_ios.mm

Issue 2934473003: Remove workaround for strikethrough text in iOS omnibox (Closed)
Patch Set: rebse Created 3 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
« no previous file with comments | « ios/chrome/browser/ui/omnibox/omnibox_view_ios.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h" 5 #include "ios/chrome/browser/ui/omnibox/omnibox_view_ios.h"
6 6
7 #import <CoreText/CoreText.h> 7 #import <CoreText/CoreText.h>
8 #import <MobileCoreServices/MobileCoreServices.h> 8 #import <MobileCoreServices/MobileCoreServices.h>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/ios/device_util.h" 12 #include "base/ios/device_util.h"
13 #include "base/ios/ios_util.h"
14 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
15 #include "base/metrics/user_metrics.h" 14 #include "base/metrics/user_metrics.h"
16 #include "base/metrics/user_metrics_action.h" 15 #include "base/metrics/user_metrics_action.h"
17 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
18 #include "base/strings/sys_string_conversions.h" 17 #include "base/strings/sys_string_conversions.h"
19 #include "components/omnibox/browser/autocomplete_input.h" 18 #include "components/omnibox/browser/autocomplete_input.h"
20 #include "components/omnibox/browser/autocomplete_match.h" 19 #include "components/omnibox/browser/autocomplete_match.h"
21 #include "components/omnibox/browser/omnibox_edit_model.h" 20 #include "components/omnibox/browser/omnibox_edit_model.h"
22 #include "components/omnibox/browser/omnibox_popup_model.h" 21 #include "components/omnibox/browser/omnibox_popup_model.h"
23 #include "components/toolbar/toolbar_model.h" 22 #include "components/toolbar/toolbar_model.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 ignore_popup_updates_(false), 181 ignore_popup_updates_(false),
183 attributing_display_string_(nil) { 182 attributing_display_string_(nil) {
184 DCHECK(field_); 183 DCHECK(field_);
185 popup_view_.reset(new OmniboxPopupViewIOS(this, model(), positioner)); 184 popup_view_.reset(new OmniboxPopupViewIOS(this, model(), positioner));
186 field_delegate_.reset( 185 field_delegate_.reset(
187 [[AutocompleteTextFieldDelegate alloc] initWithEditView:this]); 186 [[AutocompleteTextFieldDelegate alloc] initWithEditView:this]);
188 [field_ setDelegate:field_delegate_]; 187 [field_ setDelegate:field_delegate_];
189 [field_ addTarget:field_delegate_ 188 [field_ addTarget:field_delegate_
190 action:@selector(textFieldDidChange:) 189 action:@selector(textFieldDidChange:)
191 forControlEvents:UIControlEventEditingChanged]; 190 forControlEvents:UIControlEventEditingChanged];
192 use_strikethrough_workaround_ = base::ios::IsRunningOnOrLater(10, 3, 0);
193 } 191 }
194 192
195 OmniboxViewIOS::~OmniboxViewIOS() { 193 OmniboxViewIOS::~OmniboxViewIOS() {
196 // |field_| outlives this object. 194 // |field_| outlives this object.
197 [field_ setDelegate:nil]; 195 [field_ setDelegate:nil];
198 196
199 [field_ removeTarget:field_delegate_ 197 [field_ removeTarget:field_delegate_
200 action:@selector(textFieldDidChange:) 198 action:@selector(textFieldDidChange:)
201 forControlEvents:UIControlEventEditingChanged]; 199 forControlEvents:UIControlEventEditingChanged];
202 200
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 668
671 if ((security_level == security_state::NONE) || 669 if ((security_level == security_state::NONE) ||
672 (security_level == security_state::HTTP_SHOW_WARNING)) { 670 (security_level == security_state::HTTP_SHOW_WARNING)) {
673 return; 671 return;
674 } 672 }
675 673
676 DCHECK_NE(security_state::SECURITY_WARNING, security_level); 674 DCHECK_NE(security_state::SECURITY_WARNING, security_level);
677 DCHECK_NE(security_state::SECURE_WITH_POLICY_INSTALLED_CERT, security_level); 675 DCHECK_NE(security_state::SECURE_WITH_POLICY_INSTALLED_CERT, security_level);
678 676
679 if (security_level == security_state::DANGEROUS) { 677 if (security_level == security_state::DANGEROUS) {
680 if (use_strikethrough_workaround_) {
681 // Workaround: Add extra attribute to allow strikethough to apply on iOS
682 // 10.3+. See https://crbug.com/699702 for discussion.
683 [attributing_display_string_
684 addAttribute:NSBaselineOffsetAttributeName
685 value:@0
686 range:NSMakeRange(0, [attributing_display_string_ length])];
687 }
688
689 // Add a strikethrough through the scheme. 678 // Add a strikethrough through the scheme.
690 [attributing_display_string_ 679 [attributing_display_string_
691 addAttribute:NSStrikethroughStyleAttributeName 680 addAttribute:NSStrikethroughStyleAttributeName
692 value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] 681 value:[NSNumber numberWithInteger:NSUnderlineStyleSingle]
693 range:range.ToNSRange()]; 682 range:range.ToNSRange()];
694 } 683 }
695 684
696 UIColor* color = GetSecureTextColor(security_level, [field_ incognito]); 685 UIColor* color = GetSecureTextColor(security_level, [field_ incognito]);
697 if (color) { 686 if (color) {
698 [attributing_display_string_ addAttribute:NSForegroundColorAttributeName 687 [attributing_display_string_ addAttribute:NSForegroundColorAttributeName
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 // is being left out for now because it was not present before the OmniboxView 873 // is being left out for now because it was not present before the OmniboxView
885 // rewrite. 874 // rewrite.
886 #if 0 875 #if 0
887 // When editing is in progress, the url text is not colored, so there is 876 // When editing is in progress, the url text is not colored, so there is
888 // nothing to emphasize. (Calling SetText() in that situation would also be 877 // nothing to emphasize. (Calling SetText() in that situation would also be
889 // harmful, as it would reset the carat position to the end of the text.) 878 // harmful, as it would reset the carat position to the end of the text.)
890 if (!IsEditingOrEmpty()) 879 if (!IsEditingOrEmpty())
891 SetText(GetText()); 880 SetText(GetText());
892 #endif 881 #endif
893 } 882 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/omnibox/omnibox_view_ios.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698