| 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/objc_property_releaser.h" | 8 #include "base/mac/objc_property_releaser.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "net/base/mac/url_conversions.h" | 10 #include "net/base/mac/url_conversions.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 // No change to the user activity. | 90 // No change to the user activity. |
| 91 const GURL userActivityURL(net::GURLWithNSURL(self.userActivity.webpageURL)); | 91 const GURL userActivityURL(net::GURLWithNSURL(self.userActivity.webpageURL)); |
| 92 if (userActivityURL == _activeURL) | 92 if (userActivityURL == _activeURL) |
| 93 return; | 93 return; |
| 94 | 94 |
| 95 // Invalidate the old user activity and make a new one. | 95 // Invalidate the old user activity and make a new one. |
| 96 [self.userActivity invalidate]; | 96 [self.userActivity invalidate]; |
| 97 | 97 |
| 98 Class aClass = NSClassFromString(@"NSUserActivity"); | 98 Class aClass = NSClassFromString(@"NSUserActivity"); |
| 99 NSUserActivity* userActivity = [[aClass performSelector:@selector(alloc)] | 99 base::scoped_nsobject<NSUserActivity> userActivity( |
| 100 performSelector:@selector(initWithActivityType:) | 100 [[aClass performSelector:@selector(alloc)] |
| 101 withObject:handoff::kChromeHandoffActivityType]; | 101 performSelector:@selector(initWithActivityType:) |
| 102 self.userActivity = base::scoped_nsobject<NSUserActivity>(userActivity); | 102 withObject:handoff::kChromeHandoffActivityType]); |
| 103 self.userActivity = userActivity; |
| 103 self.userActivity.webpageURL = net::NSURLWithGURL(_activeURL); | 104 self.userActivity.webpageURL = net::NSURLWithGURL(_activeURL); |
| 104 NSString* origin = handoff::StringFromOrigin(_origin); | 105 NSString* origin = handoff::StringFromOrigin(_origin); |
| 105 DCHECK(origin); | 106 DCHECK(origin); |
| 106 self.userActivity.userInfo = @{ handoff::kOriginKey : origin }; | 107 self.userActivity.userInfo = @{ handoff::kOriginKey : origin }; |
| 107 [self.userActivity becomeCurrent]; | 108 [self.userActivity becomeCurrent]; |
| 108 } | 109 } |
| 109 | 110 |
| 110 @end | 111 @end |
| 111 | 112 |
| 112 @implementation HandoffManager (TestingOnly) | 113 @implementation HandoffManager (TestingOnly) |
| 113 | 114 |
| 114 - (NSURL*)userActivityWebpageURL { | 115 - (NSURL*)userActivityWebpageURL { |
| 115 return self.userActivity.webpageURL; | 116 return self.userActivity.webpageURL; |
| 116 } | 117 } |
| 117 | 118 |
| 118 @end | 119 @end |
| OLD | NEW |