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

Side by Side Diff: ios/chrome/app/chrome_app_startup_parameters.mm

Issue 2933823002: [ObjC ARC] Converts ios/chrome/app:app_internal to ARC. (Closed)
Patch Set: Rebased 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/app/BUILD.gn ('k') | ios/chrome/app/chrome_overlay_window.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ios/chrome/app/chrome_app_startup_parameters.h" 5 #import "ios/chrome/app/chrome_app_startup_parameters.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/mac/scoped_nsobject.h"
10 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
11 #include "base/metrics/user_metrics_action.h" 10 #include "base/metrics/user_metrics_action.h"
12 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
13 #include "ios/chrome/browser/chrome_url_constants.h" 12 #include "ios/chrome/browser/chrome_url_constants.h"
14 #include "ios/chrome/browser/xcallback_parameters.h" 13 #include "ios/chrome/browser/xcallback_parameters.h"
15 #include "ios/chrome/common/app_group/app_group_constants.h" 14 #include "ios/chrome/common/app_group/app_group_constants.h"
16 #include "ios/chrome/common/x_callback_url.h" 15 #include "ios/chrome/common/x_callback_url.h"
17 #import "net/base/mac/url_conversions.h" 16 #import "net/base/mac/url_conversions.h"
18 #include "url/gurl.h" 17 #include "url/gurl.h"
19 18
19 #if !defined(__has_feature) || !__has_feature(objc_arc)
20 #error "This file requires ARC support."
21 #endif
22
20 namespace { 23 namespace {
21 24
22 // Key of the UMA Startup.MobileSessionStartAction histogram. 25 // Key of the UMA Startup.MobileSessionStartAction histogram.
23 const char kUMAMobileSessionStartActionHistogram[] = 26 const char kUMAMobileSessionStartActionHistogram[] =
24 "Startup.MobileSessionStartAction"; 27 "Startup.MobileSessionStartAction";
25 28
26 const char kApplicationGroupCommandDelay[] = 29 const char kApplicationGroupCommandDelay[] =
27 "Startup.ApplicationGroupCommandDelay"; 30 "Startup.ApplicationGroupCommandDelay";
28 31
29 // URL Query String parameter to indicate that this openURL: request arrived 32 // URL Query String parameter to indicate that this openURL: request arrived
(...skipping 10 matching lines...) Expand all
40 START_ACTION_XCALLBACK_OPEN, 43 START_ACTION_XCALLBACK_OPEN,
41 START_ACTION_XCALLBACK_OTHER, 44 START_ACTION_XCALLBACK_OTHER,
42 START_ACTION_OTHER, 45 START_ACTION_OTHER,
43 START_ACTION_XCALLBACK_APPGROUP_COMMAND, 46 START_ACTION_XCALLBACK_APPGROUP_COMMAND,
44 MOBILE_SESSION_START_ACTION_COUNT, 47 MOBILE_SESSION_START_ACTION_COUNT,
45 }; 48 };
46 49
47 } // namespace 50 } // namespace
48 51
49 @implementation ChromeAppStartupParameters { 52 @implementation ChromeAppStartupParameters {
50 base::scoped_nsobject<NSString> _secureSourceApp; 53 NSString* _secureSourceApp;
51 base::scoped_nsobject<NSString> _declaredSourceApp; 54 NSString* _declaredSourceApp;
52 base::scoped_nsobject<NSURL> _completeURL; 55 NSURL* _completeURL;
53 } 56 }
54 57
55 - (instancetype)initWithExternalURL:(const GURL&)externalURL 58 - (instancetype)initWithExternalURL:(const GURL&)externalURL
56 xCallbackParameters:(XCallbackParameters*)xCallbackParameters { 59 xCallbackParameters:(XCallbackParameters*)xCallbackParameters {
57 NOTREACHED(); 60 NOTREACHED();
58 return nil; 61 return nil;
59 } 62 }
60 63
61 - (instancetype)initWithExternalURL:(const GURL&)externalURL 64 - (instancetype)initWithExternalURL:(const GURL&)externalURL
62 xCallbackParameters:(XCallbackParameters*)xCallbackParameters 65 xCallbackParameters:(XCallbackParameters*)xCallbackParameters
63 declaredSourceApp:(NSString*)declaredSourceApp 66 declaredSourceApp:(NSString*)declaredSourceApp
64 secureSourceApp:(NSString*)secureSourceApp 67 secureSourceApp:(NSString*)secureSourceApp
65 completeURL:(NSURL*)completeURL { 68 completeURL:(NSURL*)completeURL {
66 self = [super initWithExternalURL:externalURL 69 self = [super initWithExternalURL:externalURL
67 xCallbackParameters:xCallbackParameters]; 70 xCallbackParameters:xCallbackParameters];
68 if (self) { 71 if (self) {
69 _declaredSourceApp.reset([declaredSourceApp copy]); 72 _declaredSourceApp = [declaredSourceApp copy];
70 _secureSourceApp.reset([secureSourceApp copy]); 73 _secureSourceApp = [secureSourceApp copy];
71 _completeURL.reset([completeURL retain]); 74 _completeURL = completeURL;
72 } 75 }
73 return self; 76 return self;
74 } 77 }
75 78
76 + (instancetype)newChromeAppStartupParametersWithURL:(NSURL*)completeURL 79 + (instancetype)newChromeAppStartupParametersWithURL:(NSURL*)completeURL
77 fromSourceApplication:(NSString*)appId { 80 fromSourceApplication:(NSString*)appId {
78 GURL gurl = net::GURLWithNSURL(completeURL); 81 GURL gurl = net::GURLWithNSURL(completeURL);
79 82
80 if (!gurl.is_valid() || gurl.scheme().length() == 0) 83 if (!gurl.is_valid() || gurl.scheme().length() == 0)
81 return nil; 84 return nil;
(...skipping 28 matching lines...) Expand all
110 MOBILE_SESSION_START_ACTION_COUNT); 113 MOBILE_SESSION_START_ACTION_COUNT);
111 114
112 std::map<std::string, std::string> parameters = 115 std::map<std::string, std::string> parameters =
113 ExtractQueryParametersFromXCallbackURL(gurl); 116 ExtractQueryParametersFromXCallbackURL(gurl);
114 GURL url = GURL(parameters["url"]); 117 GURL url = GURL(parameters["url"]);
115 if (!url.is_valid() || 118 if (!url.is_valid() ||
116 (!url.SchemeIs(url::kHttpScheme) && !url.SchemeIs(url::kHttpsScheme))) { 119 (!url.SchemeIs(url::kHttpScheme) && !url.SchemeIs(url::kHttpsScheme))) {
117 return nil; 120 return nil;
118 } 121 }
119 122
120 base::scoped_nsobject<XCallbackParameters> xcallbackParameters( 123 XCallbackParameters* xcallbackParameters =
121 [[XCallbackParameters alloc] initWithSourceAppId:appId]); 124 [[XCallbackParameters alloc] initWithSourceAppId:appId];
122 125
123 return [[ChromeAppStartupParameters alloc] 126 return [[ChromeAppStartupParameters alloc]
124 initWithExternalURL:url 127 initWithExternalURL:url
125 xCallbackParameters:xcallbackParameters 128 xCallbackParameters:xcallbackParameters
126 declaredSourceApp:appId 129 declaredSourceApp:appId
127 secureSourceApp:nil 130 secureSourceApp:nil
128 completeURL:completeURL]; 131 completeURL:completeURL];
129 132
130 } else if (gurl.SchemeIsFile()) { 133 } else if (gurl.SchemeIsFile()) {
131 UMA_HISTOGRAM_ENUMERATION(kUMAMobileSessionStartActionHistogram, 134 UMA_HISTOGRAM_ENUMERATION(kUMAMobileSessionStartActionHistogram,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 declaredSourceApp:appId 170 declaredSourceApp:appId
168 secureSourceApp:nil 171 secureSourceApp:nil
169 completeURL:completeURL]; 172 completeURL:completeURL];
170 } 173 }
171 } 174 }
172 175
173 + (instancetype)newExtensionCommandAppStartupParametersFromWithURL:(NSURL*)url 176 + (instancetype)newExtensionCommandAppStartupParametersFromWithURL:(NSURL*)url
174 fromSourceApplication: 177 fromSourceApplication:
175 (NSString*)appId { 178 (NSString*)appId {
176 NSString* appGroup = app_group::ApplicationGroup(); 179 NSString* appGroup = app_group::ApplicationGroup();
177 base::scoped_nsobject<NSUserDefaults> sharedDefaults( 180 NSUserDefaults* sharedDefaults =
178 [[NSUserDefaults alloc] initWithSuiteName:appGroup]); 181 [[NSUserDefaults alloc] initWithSuiteName:appGroup];
179 182
180 NSString* commandDictionaryPreference = 183 NSString* commandDictionaryPreference =
181 base::SysUTF8ToNSString(app_group::kChromeAppGroupCommandPreference); 184 base::SysUTF8ToNSString(app_group::kChromeAppGroupCommandPreference);
182 NSDictionary* commandDictionary = base::mac::ObjCCast<NSDictionary>( 185 NSDictionary* commandDictionary = base::mac::ObjCCast<NSDictionary>(
183 [sharedDefaults objectForKey:commandDictionaryPreference]); 186 [sharedDefaults objectForKey:commandDictionaryPreference]);
184 187
185 [sharedDefaults removeObjectForKey:commandDictionaryPreference]; 188 [sharedDefaults removeObjectForKey:commandDictionaryPreference];
186 189
187 // |sharedDefaults| is used for communication between apps. Synchronize to 190 // |sharedDefaults| is used for communication between apps. Synchronize to
188 // avoid synchronization issues (like removing the next order). 191 // avoid synchronization issues (like removing the next order).
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 } 374 }
372 if (found.location > 0) { 375 if (found.location > 0) {
373 unichar charBefore = [query characterAtIndex:(found.location - 1)]; 376 unichar charBefore = [query characterAtIndex:(found.location - 1)];
374 if (charBefore != '&') 377 if (charBefore != '&')
375 return first_run::LAUNCH_BY_MOBILESAFARI; 378 return first_run::LAUNCH_BY_MOBILESAFARI;
376 } 379 }
377 return first_run::LAUNCH_BY_SMARTAPPBANNER; 380 return first_run::LAUNCH_BY_SMARTAPPBANNER;
378 } 381 }
379 382
380 @end 383 @end
OLDNEW
« no previous file with comments | « ios/chrome/app/BUILD.gn ('k') | ios/chrome/app/chrome_overlay_window.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698