Commit 56915573 authored by erikchen's avatar erikchen Committed by Commit bot

handoff: Fix the origin so that it correctly reflects the sender.

This broke when I migrated the Handoff Manager from chrome/ into
components/

BUG=

Review URL: https://codereview.chromium.org/1000723003

Cr-Commit-Position: refs/heads/master@{#322581}
parent 8765e8c4
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <Foundation/Foundation.h> #include <Foundation/Foundation.h>
#include "base/mac/objc_property_releaser.h" #include "base/mac/objc_property_releaser.h"
#include "components/handoff/handoff_utility.h"
#include "url/gurl.h" #include "url/gurl.h"
@class NSUserActivity; @class NSUserActivity;
...@@ -20,6 +21,7 @@ ...@@ -20,6 +21,7 @@
GURL _activeURL; GURL _activeURL;
NSUserActivity* _userActivity; NSUserActivity* _userActivity;
handoff::Origin _origin;
} }
// The active URL is defined as the URL of the most recently accessed tab. This // The active URL is defined as the URL of the most recently accessed tab. This
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/scoped_nsobject.h" #include "base/mac/scoped_nsobject.h"
#include "components/handoff/handoff_utility.h"
#include "net/base/mac/url_conversions.h" #include "net/base/mac/url_conversions.h"
#if defined(OS_IOS) #if defined(OS_IOS)
...@@ -39,6 +38,13 @@ ...@@ -39,6 +38,13 @@
self = [super init]; self = [super init];
if (self) { if (self) {
_propertyReleaser_HandoffManager.Init(self, [HandoffManager class]); _propertyReleaser_HandoffManager.Init(self, [HandoffManager class]);
#if defined(OS_MACOSX) && !defined(OS_IOS)
_origin = handoff::ORIGIN_MAC;
#elif defined(OS_IOS)
_origin = handoff::ORIGIN_IOS;
#else
NOTREACHED();
#endif
} }
return self; return self;
} }
...@@ -84,7 +90,9 @@ ...@@ -84,7 +90,9 @@
withObject:handoff::kChromeHandoffActivityType]; withObject:handoff::kChromeHandoffActivityType];
self.userActivity = base::scoped_nsobject<NSUserActivity>(userActivity); self.userActivity = base::scoped_nsobject<NSUserActivity>(userActivity);
self.userActivity.webpageURL = net::NSURLWithGURL(_activeURL); self.userActivity.webpageURL = net::NSURLWithGURL(_activeURL);
self.userActivity.userInfo = @{ handoff::kOriginKey : handoff::kOriginiOS }; NSString* origin = handoff::StringFromOrigin(_origin);
DCHECK(origin);
self.userActivity.userInfo = @{ handoff::kOriginKey : origin };
[self.userActivity becomeCurrent]; [self.userActivity becomeCurrent];
} }
......
...@@ -35,6 +35,9 @@ enum Origin { ...@@ -35,6 +35,9 @@ enum Origin {
// Returns ORIGIN_UNKNOWN if |string| is nil or unrecognized. // Returns ORIGIN_UNKNOWN if |string| is nil or unrecognized.
Origin OriginFromString(NSString* string); Origin OriginFromString(NSString* string);
// Returns nil if |origin| is not ORIGIN_IOS or ORIGIN_MAC.
NSString* StringFromOrigin(Origin origin);
} // namespace handoff } // namespace handoff
#endif // COMPONENTS_HANDOFF_HANDOFF_UTILITY_H_ #endif // COMPONENTS_HANDOFF_HANDOFF_UTILITY_H_
...@@ -21,4 +21,15 @@ Origin OriginFromString(NSString* string) { ...@@ -21,4 +21,15 @@ Origin OriginFromString(NSString* string) {
return ORIGIN_UNKNOWN; return ORIGIN_UNKNOWN;
} }
NSString* StringFromOrigin(Origin origin) {
switch (origin) {
case ORIGIN_IOS:
return kOriginiOS;
case ORIGIN_MAC:
return kOriginMac;
default:
return nil;
}
}
} // namespace handoff } // namespace handoff
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment