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,
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ class App : public AtomBrowserClient::Delegate,
|
|||
void OnLogin(LoginHandler* login_handler) override;
|
||||
void OnContinueUserActivity(bool* prevent_default,
|
||||
const std::string& type,
|
||||
const base::DictionaryValue& user_info) override;
|
||||
const std::map<std::string, std::string>& user_info) override;
|
||||
|
||||
// content::ContentBrowserClient:
|
||||
void AllowCertificateError(
|
||||
|
|
|
@ -139,7 +139,8 @@ void Browser::Activate(bool has_visible_windows) {
|
|||
|
||||
#if defined(OS_MACOSX)
|
||||
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;
|
||||
FOR_EACH_OBSERVER(BrowserObserver,
|
||||
observers_,
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#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"
|
||||
|
@ -96,11 +95,11 @@ 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 std::map<std::string, std::string>& user_info);
|
||||
|
||||
// Resumes an activity via hand-off.
|
||||
bool ContinueUserActivity(const std::string& type,
|
||||
const base::DictionaryValue& user_info);
|
||||
const std::map<std::string, std::string>& user_info);
|
||||
|
||||
// Bounce the dock icon.
|
||||
enum BounceType {
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#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"
|
||||
|
@ -88,12 +87,20 @@ 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 std::map<std::string, std::string>& user_info) {
|
||||
NSString* type_ns = [NSString stringWithUTF8String:type.c_str()];
|
||||
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];
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "base/values.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class LoginHandler;
|
||||
|
@ -51,7 +49,7 @@ class BrowserObserver {
|
|||
// The browser wants to resume a user activity via handoff. (OS X only)
|
||||
virtual void OnContinueUserActivity(bool* prevent_default,
|
||||
const std::string& type,
|
||||
const base::DictionaryValue& user_info) {}
|
||||
const std::map<std::string, std::string>& user_info) {}
|
||||
|
||||
protected:
|
||||
virtual ~BrowserObserver() {}
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
// 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"
|
||||
|
||||
#import "atom/browser/mac/atom_application.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
|
||||
|
@ -65,11 +64,19 @@ continueUserActivity:(NSUserActivity *)userActivity
|
|||
restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
|
||||
std::string activity_type(base::SysNSStringToUTF8(userActivity.activityType));
|
||||
|
||||
MacNativeConverter* converter = [[MacNativeConverter alloc] init];
|
||||
const base::DictionaryValue* user_info = [converter dictionaryToDictionaryValue:userActivity.userInfo];
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -5,10 +5,7 @@
|
|||
|
||||
@interface MacNativeConverter : NSObject
|
||||
|
||||
- (base::ListValue*)arrayToListValue:(NSArray*)nsArray;
|
||||
- (base::DictionaryValue*)dictionaryToDictionaryValue:(NSDictionary*)nsDictionary;
|
||||
|
||||
- (NSArray*)arrayFromListValue:(const base::ListValue&)list;
|
||||
- (NSDictionary*)dictionaryFromDictionaryValue:(const base::DictionaryValue&)dict;
|
||||
- (base::ListValue*)arrayToV8:(NSArray*)nsArray;
|
||||
- (base::DictionaryValue*)dictionaryToV8:(NSDictionary*)nsDictionary;
|
||||
|
||||
@end
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
@implementation MacNativeConverter
|
||||
|
||||
- (base::ListValue*)arrayToListValue:(NSArray*)nsArray {
|
||||
- (base::ListValue*)arrayToV8:(NSArray*)nsArray {
|
||||
scoped_ptr<base::ListValue> list(new base::ListValue);
|
||||
|
||||
for (id value in nsArray) {
|
||||
if ([value isKindOfClass:[NSArray class]]) {
|
||||
list->Append([self arrayToListValue:value]);
|
||||
list->Append([self arrayToV8:value]);
|
||||
} else if ([value isKindOfClass:[NSDictionary class]]) {
|
||||
list->Append([self dictionaryToDictionaryValue:value]);
|
||||
list->Append([self dictionaryToV8:value]);
|
||||
} else if ([value isKindOfClass:[NSString class]]) {
|
||||
list->AppendString(base::SysNSStringToUTF8(value));
|
||||
} else if ([value isKindOfClass:[NSNumber class]]) {
|
||||
|
@ -20,7 +20,7 @@
|
|||
return list.get();
|
||||
}
|
||||
|
||||
- (base::DictionaryValue*)dictionaryToDictionaryValue:(NSDictionary*)nsDictionary {
|
||||
- (base::DictionaryValue*)dictionaryToV8:(NSDictionary*)nsDictionary {
|
||||
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
|
||||
|
||||
NSEnumerator *it = [nsDictionary keyEnumerator];
|
||||
|
@ -30,9 +30,9 @@
|
|||
std::string key_str(base::SysNSStringToUTF8(key));
|
||||
|
||||
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]]) {
|
||||
dict->Set(key_str, [self dictionaryToDictionaryValue:value]);
|
||||
dict->Set(key_str, [self dictionaryToV8:value]);
|
||||
} else if ([value isKindOfClass:[NSString class]]) {
|
||||
dict->SetString(key_str, base::SysNSStringToUTF8(value));
|
||||
} else if ([value isKindOfClass:[NSNumber class]]) {
|
||||
|
@ -43,12 +43,4 @@
|
|||
return dict.get();
|
||||
}
|
||||
|
||||
- (NSArray*)arrayFromListValue:(const base::ListValue&)list {
|
||||
return [[NSArray alloc] init];
|
||||
}
|
||||
|
||||
- (NSDictionary*)dictionaryFromDictionaryValue:(const base::DictionaryValue&)dict {
|
||||
return [[NSDictionary alloc] init];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue