void App::OnContinueUserActivity(bool* prevent_default,
const std::string& type,
- const std::map<std::string, std::string>& user_info) {
+ const base::DictionaryValue& user_info) {
*prevent_default = Emit("continue-activity", type, user_info);
}
void OnLogin(LoginHandler* login_handler) override;
void OnContinueUserActivity(bool* prevent_default,
const std::string& type,
- const std::map<std::string, std::string>& user_info) override;
+ const base::DictionaryValue& user_info) override;
// content::ContentBrowserClient:
void AllowCertificateError(
#if defined(OS_MACOSX)
bool Browser::ContinueUserActivity(const std::string& type,
- const std::map<std::string,
- std::string>& user_info) {
+ const base::DictionaryValue& user_info) {
bool prevent_default = false;
FOR_EACH_OBSERVER(BrowserObserver,
observers_,
#include <map>
#include "base/macros.h"
+#include "base/values.h"
#include "base/compiler_specific.h"
#include "base/observer_list.h"
#include "base/strings/string16.h"
// 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);
+ const base::DictionaryValue& user_info);
// Resumes an activity via hand-off.
bool ContinueUserActivity(const std::string& type,
- const std::map<std::string, std::string>& user_info);
+ const base::DictionaryValue& user_info);
// Bounce the dock icon.
enum BounceType {
#include "atom/browser/mac/atom_application.h"
#include "atom/browser/mac/atom_application_delegate.h"
+#include "atom/browser/mac/mac_native_converter.h"
#include "atom/browser/native_window.h"
#include "atom/browser/window_list.h"
#include "base/mac/bundle_locations.h"
void Browser::SetAppUserModelID(const base::string16& name) {
}
-void Browser::SetUserActivity(const std::string& type, const std::map<std::string, std::string>& user_info) {
+void Browser::SetUserActivity(const std::string& type, const base::DictionaryValue& user_info) {
NSString* type_ns = [NSString stringWithUTF8String:type.c_str()];
NSUserActivity *user_activity = [[NSUserActivity alloc] initWithActivityType:type_ns];
+ MacNativeConverter* converter = [[MacNativeConverter alloc] init];
- NSMutableArray* user_info_args = [[NSMutableArray alloc] init];
- for (auto const &pair : user_info) {
- NSString* value_ns = [NSString stringWithUTF8String:pair.second.c_str()];
- NSString* key_ns = [NSString stringWithUTF8String:pair.first.c_str()];
-
- [user_info_args addObject:value_ns];
- [user_info_args addObject:key_ns];
- }
-
- user_activity.userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:user_info_args, nil];
+ user_activity.userInfo = [converter dictionaryFromDictionaryValue:user_info];
[user_activity becomeCurrent];
}
#include <string>
#include <map>
+#include "base/values.h"
+
namespace atom {
class LoginHandler;
// The browser wants to resume a user activity via handoff. (OS X only)
virtual void OnContinueUserActivity(bool* prevent_default,
const std::string& type,
- const std::map<std::string, std::string>& user_info) {}
+ const base::DictionaryValue& user_info) {}
protected:
virtual ~BrowserObserver() {}
// found in the LICENSE file.
#import "atom/browser/mac/atom_application_delegate.h"
-
#import "atom/browser/mac/atom_application.h"
+#import "atom/browser/mac/mac_native_converter.h"
+
#include "atom/browser/browser.h"
#include "base/strings/sys_string_conversions.h"
restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
- std::map<std::string, std::string> user_info;
-
- NSArray* keys = [userActivity.userInfo allKeys];
- for (NSString* key in keys)
- {
- NSString* value = [userActivity.userInfo objectForKey:key];
- std::string key_str(base::SysNSStringToUTF8(key));
- std::string value_str(base::SysNSStringToUTF8(value));
- user_info[key_str] = value_str;
- }
+ MacNativeConverter* converter = [[MacNativeConverter alloc] init];
+ const base::DictionaryValue* user_info = [converter dictionaryToDictionaryValue:userActivity.userInfo];
atom::Browser* browser = atom::Browser::Get();
- return browser->ContinueUserActivity(activity_type, user_info) ? YES : NO;
+ return browser->ContinueUserActivity(activity_type, *user_info) ? YES : NO;
}
@end
@interface MacNativeConverter : NSObject
-- (base::ListValue*)arrayToV8:(NSArray*)nsArray;
-- (base::DictionaryValue*)dictionaryToV8:(NSDictionary*)nsDictionary;
+- (base::ListValue*)arrayToListValue:(NSArray*)nsArray;
+- (base::DictionaryValue*)dictionaryToDictionaryValue:(NSDictionary*)nsDictionary;
+
+- (NSArray*)arrayFromListValue:(const base::ListValue&)list;
+- (NSDictionary*)dictionaryFromDictionaryValue:(const base::DictionaryValue&)dict;
@end
@implementation MacNativeConverter
-- (base::ListValue*)arrayToV8:(NSArray*)nsArray {
+- (base::ListValue*)arrayToListValue:(NSArray*)nsArray {
scoped_ptr<base::ListValue> list(new base::ListValue);
for (id value in nsArray) {
if ([value isKindOfClass:[NSArray class]]) {
- list->Append([self arrayToV8:value]);
+ list->Append([self arrayToListValue:value]);
} else if ([value isKindOfClass:[NSDictionary class]]) {
- list->Append([self dictionaryToV8:value]);
+ list->Append([self dictionaryToDictionaryValue:value]);
} else if ([value isKindOfClass:[NSString class]]) {
list->AppendString(base::SysNSStringToUTF8(value));
} else if ([value isKindOfClass:[NSNumber class]]) {
return list.get();
}
-- (base::DictionaryValue*)dictionaryToV8:(NSDictionary*)nsDictionary {
+- (base::DictionaryValue*)dictionaryToDictionaryValue:(NSDictionary*)nsDictionary {
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
NSEnumerator *it = [nsDictionary keyEnumerator];
std::string key_str(base::SysNSStringToUTF8(key));
if ([value isKindOfClass:[NSArray class]]) {
- dict->Set(key_str, [self arrayToV8:value]);
+ dict->Set(key_str, [self arrayToListValue:value]);
} else if ([value isKindOfClass:[NSDictionary class]]) {
- dict->Set(key_str, [self dictionaryToV8:value]);
+ dict->Set(key_str, [self dictionaryToDictionaryValue:value]);
} else if ([value isKindOfClass:[NSString class]]) {
dict->SetString(key_str, base::SysNSStringToUTF8(value));
} else if ([value isKindOfClass:[NSNumber class]]) {
return dict.get();
}
+- (NSArray*)arrayFromListValue:(const base::ListValue&)list {
+ return [[NSArray alloc] init];
+}
+
+- (NSDictionary*)dictionaryFromDictionaryValue:(const base::DictionaryValue&)dict {
+ return [[NSDictionary alloc] init];
+}
+
@end