| Index: chrome/browser/ui/cocoa/applescript/tab_applescript.mm
|
| diff --git a/chrome/browser/ui/cocoa/applescript/tab_applescript.mm b/chrome/browser/ui/cocoa/applescript/tab_applescript.mm
|
| index 5e806f9d0314ad3b59ebd7df7d4d0b7961c1013e..57239574f8c3de952aed406446d9798b923515ac 100644
|
| --- a/chrome/browser/ui/cocoa/applescript/tab_applescript.mm
|
| +++ b/chrome/browser/ui/cocoa/applescript/tab_applescript.mm
|
| @@ -4,18 +4,15 @@
|
|
|
| #import "chrome/browser/ui/cocoa/applescript/tab_applescript.h"
|
|
|
| -#import <Carbon/Carbon.h>
|
| -#import <Foundation/NSAppleEventDescriptor.h>
|
| -
|
| #include "base/bind.h"
|
| #include "base/file_path.h"
|
| #include "base/logging.h"
|
| #import "base/memory/scoped_nsobject.h"
|
| #include "base/sys_string_conversions.h"
|
| -#include "base/utf_string_conversions.h"
|
| #include "chrome/browser/printing/print_view_manager.h"
|
| #include "chrome/browser/sessions/session_id.h"
|
| #include "chrome/browser/sessions/session_tab_helper.h"
|
| +#include "chrome/browser/ui/cocoa/applescript/apple_event_util.h"
|
| #include "chrome/browser/ui/cocoa/applescript/error_applescript.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "content/public/browser/navigation_controller.h"
|
| @@ -35,82 +32,10 @@ using content::WebContents;
|
|
|
| namespace {
|
|
|
| -NSAppleEventDescriptor* valueToDescriptor(const base::Value* value) {
|
| - NSAppleEventDescriptor* descriptor = nil;
|
| - switch (value->GetType()) {
|
| - case base::Value::TYPE_NULL:
|
| - descriptor = [NSAppleEventDescriptor
|
| - descriptorWithTypeCode:cMissingValue];
|
| - break;
|
| - case base::Value::TYPE_BOOLEAN: {
|
| - bool bool_value;
|
| - value->GetAsBoolean(&bool_value);
|
| - descriptor = [NSAppleEventDescriptor descriptorWithBoolean:bool_value];
|
| - break;
|
| - }
|
| - case base::Value::TYPE_INTEGER: {
|
| - int int_value;
|
| - value->GetAsInteger(&int_value);
|
| - descriptor = [NSAppleEventDescriptor descriptorWithInt32:int_value];
|
| - break;
|
| - }
|
| - case base::Value::TYPE_DOUBLE: {
|
| - double double_value;
|
| - value->GetAsDouble(&double_value);
|
| - descriptor = [NSAppleEventDescriptor
|
| - descriptorWithDescriptorType:typeIEEE64BitFloatingPoint
|
| - bytes:&double_value
|
| - length:sizeof(double_value)];
|
| - break;
|
| - }
|
| - case base::Value::TYPE_STRING: {
|
| - std::string string_value;
|
| - value->GetAsString(&string_value);
|
| - descriptor = [NSAppleEventDescriptor descriptorWithString:
|
| - base::SysUTF8ToNSString(string_value)];
|
| - break;
|
| - }
|
| - case base::Value::TYPE_BINARY:
|
| - NOTREACHED();
|
| - break;
|
| - case base::Value::TYPE_DICTIONARY: {
|
| - const base::DictionaryValue* dictionary_value =
|
| - static_cast<const base::DictionaryValue*>(value);
|
| - descriptor = [NSAppleEventDescriptor recordDescriptor];
|
| - NSAppleEventDescriptor* userRecord = [NSAppleEventDescriptor
|
| - listDescriptor];
|
| - for (DictionaryValue::key_iterator iter(dictionary_value->begin_keys());
|
| - iter != dictionary_value->end_keys(); ++iter) {
|
| - const base::Value* item;
|
| - if (dictionary_value->Get(*iter, &item)) {
|
| - [userRecord insertDescriptor:[NSAppleEventDescriptor
|
| - descriptorWithString:base::SysUTF8ToNSString(*iter)] atIndex:0];
|
| - [userRecord insertDescriptor:valueToDescriptor(item) atIndex:0];
|
| - }
|
| - }
|
| - // Description of what keyASUserRecordFields does.
|
| - // http://www.mail-archive.com/cocoa-dev%40lists.apple.com/msg40149.html
|
| - [descriptor setDescriptor:userRecord forKeyword:keyASUserRecordFields];
|
| - break;
|
| - }
|
| - case base::Value::TYPE_LIST: {
|
| - const base::ListValue* list_value;
|
| - value->GetAsList(&list_value);
|
| - descriptor = [NSAppleEventDescriptor listDescriptor];
|
| - for (unsigned i = 0; i < list_value->GetSize(); ++i) {
|
| - const base::Value* item;
|
| - list_value->Get(i, &item);
|
| - [descriptor insertDescriptor:valueToDescriptor(item) atIndex:0];
|
| - }
|
| - break;
|
| - }
|
| - }
|
| - return descriptor;
|
| -}
|
| -
|
| void ResumeAppleEventAndSendReply(NSAppleEventManagerSuspensionID suspension_id,
|
| const base::Value* result_value) {
|
| - NSAppleEventDescriptor* result_descriptor = valueToDescriptor(result_value);
|
| + NSAppleEventDescriptor* result_descriptor =
|
| + ValueToAppleEventDescriptor(result_value);
|
|
|
| NSAppleEventManager* manager = [NSAppleEventManager sharedAppleEventManager];
|
| NSAppleEventDescriptor* reply_event =
|
|
|