🍎 Add fallback URL to handoff.
This commit is contained in:
parent
407a5d4415
commit
eb0889de38
5 changed files with 24 additions and 11 deletions
|
@ -14,6 +14,7 @@
|
|||
#include "base/strings/string16.h"
|
||||
#include "atom/browser/browser_observer.h"
|
||||
#include "atom/browser/window_list_observer.h"
|
||||
#include "native_mate/arguments.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "base/files/file_path.h"
|
||||
|
@ -94,7 +95,8 @@ class Browser : public WindowListObserver {
|
|||
|
||||
// Creates an activity and sets it as the one currently in use.
|
||||
void SetUserActivity(const std::string& type,
|
||||
const base::DictionaryValue& user_info);
|
||||
const base::DictionaryValue& user_info,
|
||||
mate::Arguments* args);
|
||||
|
||||
// Returns the type name of the current user activity.
|
||||
std::string GetCurrentActivityType();
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "base/mac/foundation_util.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "brightray/common/application_info.h"
|
||||
#include "net/base/mac/url_conversions.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -112,12 +114,16 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol) {
|
|||
void Browser::SetAppUserModelID(const base::string16& name) {
|
||||
}
|
||||
|
||||
void Browser::SetUserActivity(
|
||||
const std::string& type,
|
||||
const base::DictionaryValue& user_info) {
|
||||
void Browser::SetUserActivity(const std::string& type,
|
||||
const base::DictionaryValue& user_info,
|
||||
mate::Arguments* args) {
|
||||
std::string url_string;
|
||||
args->GetNext(&url_string);
|
||||
|
||||
[[AtomApplication sharedApplication]
|
||||
setCurrentActivity:base::SysUTF8ToNSString(type)
|
||||
withUserInfo:DictionaryValueToNSDictionary(user_info)];
|
||||
withUserInfo:DictionaryValueToNSDictionary(user_info)
|
||||
withWebpageURL:net::NSURLWithGURL(GURL(url_string))];
|
||||
}
|
||||
|
||||
std::string Browser::GetCurrentActivityType() {
|
||||
|
@ -126,9 +132,8 @@ std::string Browser::GetCurrentActivityType() {
|
|||
return base::SysNSStringToUTF8(userActivity.activityType);
|
||||
}
|
||||
|
||||
bool Browser::ContinueUserActivity(
|
||||
const std::string& type,
|
||||
const base::DictionaryValue& user_info) {
|
||||
bool Browser::ContinueUserActivity(const std::string& type,
|
||||
const base::DictionaryValue& user_info) {
|
||||
bool prevent_default = false;
|
||||
FOR_EACH_OBSERVER(BrowserObserver,
|
||||
observers_,
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
|
||||
|
||||
- (NSUserActivity*)getCurrentActivity;
|
||||
- (void)setCurrentActivity:(NSString*)type withUserInfo:(NSDictionary*)userInfo;
|
||||
- (void)setCurrentActivity:(NSString*)type
|
||||
withUserInfo:(NSDictionary*)userInfo
|
||||
withWebpageURL:(NSURL*)webpageURL;
|
||||
|
||||
@end
|
||||
|
|
|
@ -29,10 +29,12 @@
|
|||
}
|
||||
|
||||
- (void)setCurrentActivity:(NSString*)type
|
||||
withUserInfo:(NSDictionary*)userInfo {
|
||||
withUserInfo:(NSDictionary*)userInfo
|
||||
withWebpageURL:(NSURL*)webpageURL {
|
||||
currentActivity_ = base::scoped_nsobject<NSUserActivity>(
|
||||
[[NSUserActivity alloc] initWithActivityType:type]);
|
||||
[currentActivity_ setUserInfo:userInfo];
|
||||
[currentActivity_ setWebpageURL:webpageURL];
|
||||
[currentActivity_ becomeCurrent];
|
||||
}
|
||||
|
||||
|
|
|
@ -496,11 +496,13 @@ app.on('ready', () => {
|
|||
});
|
||||
```
|
||||
|
||||
### `app.setUserActivity(type, userInfo)` _OS X_
|
||||
### `app.setUserActivity(type, userInfo[, webpageURL])` _OS X_
|
||||
|
||||
* `type` String - Uniquely identifies the activity. Maps to
|
||||
[`NSUserActivity.activityType`][activity-type].
|
||||
* `userInfo` Object - App-specific state to store for use by another device.
|
||||
* `webpageURL` String - The webpage to load in a browser if no suitable app is
|
||||
installed on the resuming device. The scheme must be `http` or `https`.
|
||||
|
||||
Creates an `NSUserActivity` and sets it as the current activity. The activity
|
||||
is eligible for [Handoff][handoff] to another device afterward.
|
||||
|
|
Loading…
Reference in a new issue