OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/handoff/handoff_manager.h" | 5 #include "components/handoff/handoff_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
9 #include "components/handoff/handoff_utility.h" | |
10 #include "net/base/mac/url_conversions.h" | 9 #include "net/base/mac/url_conversions.h" |
11 | 10 |
12 #if defined(OS_IOS) | 11 #if defined(OS_IOS) |
13 #include "base/ios/ios_util.h" | 12 #include "base/ios/ios_util.h" |
14 #endif | 13 #endif |
15 | 14 |
16 #if defined(OS_MACOSX) && !defined(OS_IOS) | 15 #if defined(OS_MACOSX) && !defined(OS_IOS) |
17 #include "base/mac/mac_util.h" | 16 #include "base/mac/mac_util.h" |
18 #include "base/mac/sdk_forward_declarations.h" | 17 #include "base/mac/sdk_forward_declarations.h" |
19 #endif | 18 #endif |
(...skipping 12 matching lines...) Expand all Loading... | |
32 @end | 31 @end |
33 | 32 |
34 @implementation HandoffManager | 33 @implementation HandoffManager |
35 | 34 |
36 @synthesize userActivity = _userActivity; | 35 @synthesize userActivity = _userActivity; |
37 | 36 |
38 - (instancetype)init { | 37 - (instancetype)init { |
39 self = [super init]; | 38 self = [super init]; |
40 if (self) { | 39 if (self) { |
41 _propertyReleaser_HandoffManager.Init(self, [HandoffManager class]); | 40 _propertyReleaser_HandoffManager.Init(self, [HandoffManager class]); |
41 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
42 _origin = handoff::ORIGIN_MAC; | |
43 #elif defined(OS_IOS) | |
44 _origin = handoff::ORIGIN_IOS; | |
Avi (use Gerrit)
2015/03/26 18:40:21
#if defined(OS_IOS)
_origin = handoff::ORIGIN_
erikchen
2015/03/27 14:52:24
I'm generally a fan of shorter code, but in this c
Avi (use Gerrit)
2015/03/27 15:16:38
That makes sense.
| |
45 #else | |
46 NOTREACHED(); | |
47 #endif | |
42 } | 48 } |
43 return self; | 49 return self; |
44 } | 50 } |
45 | 51 |
46 - (void)updateActiveURL:(const GURL&)url { | 52 - (void)updateActiveURL:(const GURL&)url { |
47 #if defined(OS_IOS) | 53 #if defined(OS_IOS) |
48 // Handoff is only available on iOS 8+. | 54 // Handoff is only available on iOS 8+. |
49 DCHECK(base::ios::IsRunningOnIOS8OrLater()); | 55 DCHECK(base::ios::IsRunningOnIOS8OrLater()); |
50 #endif | 56 #endif |
51 | 57 |
(...skipping 25 matching lines...) Expand all Loading... | |
77 | 83 |
78 // Invalidate the old user activity and make a new one. | 84 // Invalidate the old user activity and make a new one. |
79 [self.userActivity invalidate]; | 85 [self.userActivity invalidate]; |
80 | 86 |
81 Class aClass = NSClassFromString(@"NSUserActivity"); | 87 Class aClass = NSClassFromString(@"NSUserActivity"); |
82 NSUserActivity* userActivity = [[aClass performSelector:@selector(alloc)] | 88 NSUserActivity* userActivity = [[aClass performSelector:@selector(alloc)] |
83 performSelector:@selector(initWithActivityType:) | 89 performSelector:@selector(initWithActivityType:) |
84 withObject:handoff::kChromeHandoffActivityType]; | 90 withObject:handoff::kChromeHandoffActivityType]; |
85 self.userActivity = base::scoped_nsobject<NSUserActivity>(userActivity); | 91 self.userActivity = base::scoped_nsobject<NSUserActivity>(userActivity); |
86 self.userActivity.webpageURL = net::NSURLWithGURL(_activeURL); | 92 self.userActivity.webpageURL = net::NSURLWithGURL(_activeURL); |
87 self.userActivity.userInfo = @{ handoff::kOriginKey : handoff::kOriginiOS }; | 93 NSString* origin = handoff::StringFromOrigin(_origin); |
94 DCHECK(origin); | |
95 self.userActivity.userInfo = @{ handoff::kOriginKey : origin }; | |
88 [self.userActivity becomeCurrent]; | 96 [self.userActivity becomeCurrent]; |
89 } | 97 } |
90 | 98 |
91 @end | 99 @end |
OLD | NEW |