Revert "Use a DictionaryValue everywhere instead of a string map."
This reverts commit 90cc10944a
.
This commit is contained in:
parent
90cc10944a
commit
f84a973d69
9 changed files with 38 additions and 37 deletions
|
@ -252,7 +252,7 @@ void App::OnFinishLaunching() {
|
||||||
|
|
||||||
void App::OnContinueUserActivity(bool* prevent_default,
|
void App::OnContinueUserActivity(bool* prevent_default,
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
const base::DictionaryValue& user_info) {
|
const std::map<std::string, std::string>& user_info) {
|
||||||
*prevent_default = Emit("continue-activity", type, user_info);
|
*prevent_default = Emit("continue-activity", type, user_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ class App : public AtomBrowserClient::Delegate,
|
||||||
void OnLogin(LoginHandler* login_handler) override;
|
void OnLogin(LoginHandler* login_handler) override;
|
||||||
void OnContinueUserActivity(bool* prevent_default,
|
void OnContinueUserActivity(bool* prevent_default,
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
const base::DictionaryValue& user_info) override;
|
const std::map<std::string, std::string>& user_info) override;
|
||||||
|
|
||||||
// content::ContentBrowserClient:
|
// content::ContentBrowserClient:
|
||||||
void AllowCertificateError(
|
void AllowCertificateError(
|
||||||
|
|
|
@ -139,7 +139,8 @@ void Browser::Activate(bool has_visible_windows) {
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
bool Browser::ContinueUserActivity(const std::string& type,
|
bool Browser::ContinueUserActivity(const std::string& type,
|
||||||
const base::DictionaryValue& user_info) {
|
const std::map<std::string,
|
||||||
|
std::string>& user_info) {
|
||||||
bool prevent_default = false;
|
bool prevent_default = false;
|
||||||
FOR_EACH_OBSERVER(BrowserObserver,
|
FOR_EACH_OBSERVER(BrowserObserver,
|
||||||
observers_,
|
observers_,
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "base/values.h"
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/observer_list.h"
|
#include "base/observer_list.h"
|
||||||
#include "base/strings/string16.h"
|
#include "base/strings/string16.h"
|
||||||
|
@ -96,11 +95,11 @@ class Browser : public WindowListObserver {
|
||||||
|
|
||||||
// Creates an activity and sets it as the one currently in use.
|
// Creates an activity and sets it as the one currently in use.
|
||||||
void SetUserActivity(const std::string& type,
|
void SetUserActivity(const std::string& type,
|
||||||
const base::DictionaryValue& user_info);
|
const std::map<std::string, std::string>& user_info);
|
||||||
|
|
||||||
// Resumes an activity via hand-off.
|
// Resumes an activity via hand-off.
|
||||||
bool ContinueUserActivity(const std::string& type,
|
bool ContinueUserActivity(const std::string& type,
|
||||||
const base::DictionaryValue& user_info);
|
const std::map<std::string, std::string>& user_info);
|
||||||
|
|
||||||
// Bounce the dock icon.
|
// Bounce the dock icon.
|
||||||
enum BounceType {
|
enum BounceType {
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include "atom/browser/mac/atom_application.h"
|
#include "atom/browser/mac/atom_application.h"
|
||||||
#include "atom/browser/mac/atom_application_delegate.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/native_window.h"
|
||||||
#include "atom/browser/window_list.h"
|
#include "atom/browser/window_list.h"
|
||||||
#include "base/mac/bundle_locations.h"
|
#include "base/mac/bundle_locations.h"
|
||||||
|
@ -88,12 +87,20 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol) {
|
||||||
void Browser::SetAppUserModelID(const base::string16& name) {
|
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 std::map<std::string, std::string>& user_info) {
|
||||||
NSString* type_ns = [NSString stringWithUTF8String:type.c_str()];
|
NSString* type_ns = [NSString stringWithUTF8String:type.c_str()];
|
||||||
NSUserActivity *user_activity = [[NSUserActivity alloc] initWithActivityType:type_ns];
|
NSUserActivity *user_activity = [[NSUserActivity alloc] initWithActivityType:type_ns];
|
||||||
MacNativeConverter* converter = [[MacNativeConverter alloc] init];
|
|
||||||
|
|
||||||
user_activity.userInfo = [converter dictionaryFromDictionaryValue:user_info];
|
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 becomeCurrent];
|
[user_activity becomeCurrent];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "base/values.h"
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
class LoginHandler;
|
class LoginHandler;
|
||||||
|
@ -51,7 +49,7 @@ class BrowserObserver {
|
||||||
// The browser wants to resume a user activity via handoff. (OS X only)
|
// The browser wants to resume a user activity via handoff. (OS X only)
|
||||||
virtual void OnContinueUserActivity(bool* prevent_default,
|
virtual void OnContinueUserActivity(bool* prevent_default,
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
const base::DictionaryValue& user_info) {}
|
const std::map<std::string, std::string>& user_info) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~BrowserObserver() {}
|
virtual ~BrowserObserver() {}
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#import "atom/browser/mac/atom_application_delegate.h"
|
#import "atom/browser/mac/atom_application_delegate.h"
|
||||||
#import "atom/browser/mac/atom_application.h"
|
|
||||||
#import "atom/browser/mac/mac_native_converter.h"
|
|
||||||
|
|
||||||
|
#import "atom/browser/mac/atom_application.h"
|
||||||
#include "atom/browser/browser.h"
|
#include "atom/browser/browser.h"
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
|
|
||||||
|
@ -65,11 +64,19 @@ continueUserActivity:(NSUserActivity *)userActivity
|
||||||
restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
|
restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
|
||||||
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
||||||
|
|
||||||
MacNativeConverter* converter = [[MacNativeConverter alloc] init];
|
std::map<std::string, std::string> user_info;
|
||||||
const base::DictionaryValue* user_info = [converter dictionaryToDictionaryValue:userActivity.userInfo];
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
atom::Browser* browser = atom::Browser::Get();
|
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
|
@end
|
||||||
|
|
|
@ -5,10 +5,7 @@
|
||||||
|
|
||||||
@interface MacNativeConverter : NSObject
|
@interface MacNativeConverter : NSObject
|
||||||
|
|
||||||
- (base::ListValue*)arrayToListValue:(NSArray*)nsArray;
|
- (base::ListValue*)arrayToV8:(NSArray*)nsArray;
|
||||||
- (base::DictionaryValue*)dictionaryToDictionaryValue:(NSDictionary*)nsDictionary;
|
- (base::DictionaryValue*)dictionaryToV8:(NSDictionary*)nsDictionary;
|
||||||
|
|
||||||
- (NSArray*)arrayFromListValue:(const base::ListValue&)list;
|
|
||||||
- (NSDictionary*)dictionaryFromDictionaryValue:(const base::DictionaryValue&)dict;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
|
|
||||||
@implementation MacNativeConverter
|
@implementation MacNativeConverter
|
||||||
|
|
||||||
- (base::ListValue*)arrayToListValue:(NSArray*)nsArray {
|
- (base::ListValue*)arrayToV8:(NSArray*)nsArray {
|
||||||
scoped_ptr<base::ListValue> list(new base::ListValue);
|
scoped_ptr<base::ListValue> list(new base::ListValue);
|
||||||
|
|
||||||
for (id value in nsArray) {
|
for (id value in nsArray) {
|
||||||
if ([value isKindOfClass:[NSArray class]]) {
|
if ([value isKindOfClass:[NSArray class]]) {
|
||||||
list->Append([self arrayToListValue:value]);
|
list->Append([self arrayToV8:value]);
|
||||||
} else if ([value isKindOfClass:[NSDictionary class]]) {
|
} else if ([value isKindOfClass:[NSDictionary class]]) {
|
||||||
list->Append([self dictionaryToDictionaryValue:value]);
|
list->Append([self dictionaryToV8:value]);
|
||||||
} else if ([value isKindOfClass:[NSString class]]) {
|
} else if ([value isKindOfClass:[NSString class]]) {
|
||||||
list->AppendString(base::SysNSStringToUTF8(value));
|
list->AppendString(base::SysNSStringToUTF8(value));
|
||||||
} else if ([value isKindOfClass:[NSNumber class]]) {
|
} else if ([value isKindOfClass:[NSNumber class]]) {
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
return list.get();
|
return list.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (base::DictionaryValue*)dictionaryToDictionaryValue:(NSDictionary*)nsDictionary {
|
- (base::DictionaryValue*)dictionaryToV8:(NSDictionary*)nsDictionary {
|
||||||
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
|
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
|
||||||
|
|
||||||
NSEnumerator *it = [nsDictionary keyEnumerator];
|
NSEnumerator *it = [nsDictionary keyEnumerator];
|
||||||
|
@ -30,9 +30,9 @@
|
||||||
std::string key_str(base::SysNSStringToUTF8(key));
|
std::string key_str(base::SysNSStringToUTF8(key));
|
||||||
|
|
||||||
if ([value isKindOfClass:[NSArray class]]) {
|
if ([value isKindOfClass:[NSArray class]]) {
|
||||||
dict->Set(key_str, [self arrayToListValue:value]);
|
dict->Set(key_str, [self arrayToV8:value]);
|
||||||
} else if ([value isKindOfClass:[NSDictionary class]]) {
|
} else if ([value isKindOfClass:[NSDictionary class]]) {
|
||||||
dict->Set(key_str, [self dictionaryToDictionaryValue:value]);
|
dict->Set(key_str, [self dictionaryToV8:value]);
|
||||||
} else if ([value isKindOfClass:[NSString class]]) {
|
} else if ([value isKindOfClass:[NSString class]]) {
|
||||||
dict->SetString(key_str, base::SysNSStringToUTF8(value));
|
dict->SetString(key_str, base::SysNSStringToUTF8(value));
|
||||||
} else if ([value isKindOfClass:[NSNumber class]]) {
|
} else if ([value isKindOfClass:[NSNumber class]]) {
|
||||||
|
@ -43,12 +43,4 @@
|
||||||
return dict.get();
|
return dict.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray*)arrayFromListValue:(const base::ListValue&)list {
|
|
||||||
return [[NSArray alloc] init];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSDictionary*)dictionaryFromDictionaryValue:(const base::DictionaryValue&)dict {
|
|
||||||
return [[NSDictionary alloc] init];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in a new issue