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

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

Issue 2707963002: [ObjC ARC] Converts ios/chrome/browser/ui/omnibox:omnibox_internal to ARC. (Closed)
Patch Set: weaks Created 3 years, 10 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 "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/command_line.h" 10 #include "base/command_line.h"
(...skipping 19 matching lines...) Expand all
30 #include "ios/chrome/grit/ios_theme_resources.h" 30 #include "ios/chrome/grit/ios_theme_resources.h"
31 #include "ios/web/public/referrer.h" 31 #include "ios/web/public/referrer.h"
32 #import "net/base/mac/url_conversions.h" 32 #import "net/base/mac/url_conversions.h"
33 #include "skia/ext/skia_utils_ios.h" 33 #include "skia/ext/skia_utils_ios.h"
34 #include "ui/base/page_transition_types.h" 34 #include "ui/base/page_transition_types.h"
35 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
36 #include "ui/base/window_open_disposition.h" 36 #include "ui/base/window_open_disposition.h"
37 #include "ui/gfx/color_palette.h" 37 #include "ui/gfx/color_palette.h"
38 #include "ui/gfx/image/image.h" 38 #include "ui/gfx/image/image.h"
39 39
40 #if !defined(__has_feature) || !__has_feature(objc_arc)
41 #error "This file requires ARC support."
42 #endif
43
40 using base::UserMetricsAction; 44 using base::UserMetricsAction;
41 45
42 namespace { 46 namespace {
43 // The color of the rest of the URL (i.e. after the TLD) in the omnibox. 47 // The color of the rest of the URL (i.e. after the TLD) in the omnibox.
44 UIColor* BaseTextColor() { 48 UIColor* BaseTextColor() {
45 return [UIColor colorWithWhite:(161 / 255.0) alpha:1.0]; 49 return [UIColor colorWithWhite:(161 / 255.0) alpha:1.0];
46 } 50 }
47 51
48 // The color of the https when there is an error. 52 // The color of the https when there is an error.
49 UIColor* ErrorTextColor() { 53 UIColor* ErrorTextColor() {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 179
176 OmniboxViewIOS::OmniboxViewIOS(OmniboxTextFieldIOS* field, 180 OmniboxViewIOS::OmniboxViewIOS(OmniboxTextFieldIOS* field,
177 WebOmniboxEditController* controller, 181 WebOmniboxEditController* controller,
178 ios::ChromeBrowserState* browser_state, 182 ios::ChromeBrowserState* browser_state,
179 id<PreloadProvider> preloader, 183 id<PreloadProvider> preloader,
180 id<OmniboxPopupPositioner> positioner) 184 id<OmniboxPopupPositioner> positioner)
181 : OmniboxView( 185 : OmniboxView(
182 controller, 186 controller,
183 base::MakeUnique<ChromeOmniboxClientIOS>(controller, browser_state)), 187 base::MakeUnique<ChromeOmniboxClientIOS>(controller, browser_state)),
184 browser_state_(browser_state), 188 browser_state_(browser_state),
185 field_([field retain]), 189 field_(field),
186 controller_(controller), 190 controller_(controller),
187 preloader_(preloader), 191 preloader_(preloader),
188 ignore_popup_updates_(false) { 192 ignore_popup_updates_(false) {
189 popup_view_.reset(new OmniboxPopupViewIOS(this, model(), positioner)); 193 popup_view_.reset(new OmniboxPopupViewIOS(this, model(), positioner));
190 field_delegate_.reset( 194 field_delegate_.reset(
191 [[AutocompleteTextFieldDelegate alloc] initWithEditView:this]); 195 [[AutocompleteTextFieldDelegate alloc] initWithEditView:this]);
192 [field_ setDelegate:field_delegate_]; 196 [field_ setDelegate:field_delegate_];
193 [field_ addTarget:field_delegate_ 197 [field_ addTarget:field_delegate_
194 action:@selector(textFieldDidChange:) 198 action:@selector(textFieldDidChange:)
195 forControlEvents:UIControlEventEditingChanged]; 199 forControlEvents:UIControlEventEditingChanged];
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 bool OmniboxViewIOS::CanCopyURL() { 633 bool OmniboxViewIOS::CanCopyURL() {
630 return false; 634 return false;
631 } 635 }
632 636
633 void OmniboxViewIOS::WillPaste() { 637 void OmniboxViewIOS::WillPaste() {
634 model()->OnPaste(); 638 model()->OnPaste();
635 } 639 }
636 640
637 NSAttributedString* OmniboxViewIOS::ApplyTextAttributes( 641 NSAttributedString* OmniboxViewIOS::ApplyTextAttributes(
638 const base::string16& text) { 642 const base::string16& text) {
639 NSMutableAttributedString* as = [[[NSMutableAttributedString alloc] 643 NSMutableAttributedString* as = [[NSMutableAttributedString alloc]
640 initWithString:base::SysUTF16ToNSString(text)] autorelease]; 644 initWithString:base::SysUTF16ToNSString(text)];
641 url::Component scheme, host; 645 url::Component scheme, host;
642 AutocompleteInput::ParseForEmphasizeComponents( 646 AutocompleteInput::ParseForEmphasizeComponents(
643 text, AutocompleteSchemeClassifierImpl(), &scheme, &host); 647 text, AutocompleteSchemeClassifierImpl(), &scheme, &host);
644 648
645 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0); 649 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0);
646 if (emphasize) { 650 if (emphasize) {
647 [as addAttribute:NSForegroundColorAttributeName 651 [as addAttribute:NSForegroundColorAttributeName
648 value:BaseTextColor() 652 value:BaseTextColor()
649 range:NSMakeRange(0, [as length])]; 653 range:NSMakeRange(0, [as length])];
650 654
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 // is being left out for now because it was not present before the OmniboxView 870 // is being left out for now because it was not present before the OmniboxView
867 // rewrite. 871 // rewrite.
868 #if 0 872 #if 0
869 // When editing is in progress, the url text is not colored, so there is 873 // When editing is in progress, the url text is not colored, so there is
870 // nothing to emphasize. (Calling SetText() in that situation would also be 874 // nothing to emphasize. (Calling SetText() in that situation would also be
871 // harmful, as it would reset the carat position to the end of the text.) 875 // harmful, as it would reset the carat position to the end of the text.)
872 if (!IsEditingOrEmpty()) 876 if (!IsEditingOrEmpty())
873 SetText(GetText()); 877 SetText(GetText());
874 #endif 878 #endif
875 } 879 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698