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

Side by Side Diff: components/handoff/handoff_manager.mm

Issue 1000723003: handoff: Fix the origin so that it correctly reflects the sender. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from avi. Created 5 years, 8 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 | « components/handoff/handoff_manager.h ('k') | components/handoff/handoff_utility.h » ('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 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
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
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
OLDNEW
« no previous file with comments | « components/handoff/handoff_manager.h ('k') | components/handoff/handoff_utility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698