Implement app.setUserActivity(type, userInfo).
This commit is contained in:
parent
92606579d3
commit
6df4bb176d
3 changed files with 22 additions and 0 deletions
|
@ -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",
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#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<std::string, std::string>& user_info);
|
||||
|
||||
// Bounce the dock icon.
|
||||
enum BounceType {
|
||||
BOUNCE_CRITICAL = 0,
|
||||
|
|
|
@ -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<std::string, std::string>& 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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue