From: Charlie Hess Date: Sat, 30 Apr 2016 00:35:07 +0000 (-0700) Subject: Implement app.setUserActivity(type, userInfo). X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6df4bb176dce4903e105690deb54627ad8c4d1d0;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Implement app.setUserActivity(type, userInfo). --- diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 304e53a..8e7d8c3 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -460,6 +460,7 @@ void App::BuildPrototype( #if defined(OS_MACOSX) .SetMethod("hide", base::Bind(&Browser::Hide, browser)) .SetMethod("show", base::Bind(&Browser::Show, browser)) + .SetMethod("setUserActivity", base::Bind(&Browser::SetUserActivity, browser)) #endif #if defined(OS_WIN) .SetMethod("setUserTasks", diff --git a/atom/browser/browser.h b/atom/browser/browser.h index 8329b14..b0dd829 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -7,6 +7,7 @@ #include #include +#include #include "base/macros.h" #include "base/compiler_specific.h" @@ -92,6 +93,9 @@ class Browser : public WindowListObserver { // Show the application. void Show(); + // Creates an activity and sets it as the one currently in use. + void SetUserActivity(const std::string& type, const std::map& user_info); + // Bounce the dock icon. enum BounceType { BOUNCE_CRITICAL = 0, diff --git a/atom/browser/browser_mac.mm b/atom/browser/browser_mac.mm index c10369a..627ed65 100644 --- a/atom/browser/browser_mac.mm +++ b/atom/browser/browser_mac.mm @@ -87,6 +87,23 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol) { void Browser::SetAppUserModelID(const base::string16& name) { } +void Browser::SetUserActivity(const std::string& type, const std::map& user_info) { + NSString* type_ns = [NSString stringWithUTF8String:type.c_str()]; + NSUserActivity *user_activity = [[NSUserActivity alloc] initWithActivityType:type_ns]; + + NSMutableArray* user_info_args = [[NSMutableArray alloc] init]; + for (auto const &pair : user_info) { + NSString* key_ns = [NSString stringWithUTF8String:pair.first.c_str()]; + NSString* value_ns = [NSString stringWithUTF8String:pair.second.c_str()]; + + [user_info_args addObject:key_ns]; + [user_info_args addObject:value_ns]; + } + + user_activity.userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:user_info_args, nil]; + [user_activity becomeCurrent]; +} + std::string Browser::GetExecutableFileVersion() const { return brightray::GetApplicationVersion(); }