| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/applescript/tab_applescript.h" | 5 #import "chrome/browser/ui/cocoa/applescript/tab_applescript.h" |
| 6 | 6 |
| 7 #import <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
| 8 #import <Foundation/NSAppleEventDescriptor.h> | 8 #import <Foundation/NSAppleEventDescriptor.h> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #import "base/memory/scoped_nsobject.h" | 12 #import "base/memory/scoped_nsobject.h" |
| 13 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/printing/print_view_manager.h" | 15 #include "chrome/browser/printing/print_view_manager.h" |
| 16 #include "chrome/browser/sessions/restore_tab_helper.h" | |
| 17 #include "chrome/browser/sessions/session_id.h" | 16 #include "chrome/browser/sessions/session_id.h" |
| 17 #include "chrome/browser/sessions/session_tab_helper.h" |
| 18 #include "chrome/browser/ui/cocoa/applescript/error_applescript.h" | 18 #include "chrome/browser/ui/cocoa/applescript/error_applescript.h" |
| 19 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 20 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
| 21 #include "content/public/browser/navigation_controller.h" | 21 #include "content/public/browser/navigation_controller.h" |
| 22 #include "content/public/browser/navigation_entry.h" | 22 #include "content/public/browser/navigation_entry.h" |
| 23 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
| 24 #include "content/public/browser/save_page_type.h" | 24 #include "content/public/browser/save_page_type.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "content/public/browser/web_contents_delegate.h" | 26 #include "content/public/browser/web_contents_delegate.h" |
| 27 #include "googleurl/src/gurl.h" | 27 #include "googleurl/src/gurl.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 return nil; | 160 return nil; |
| 161 } | 161 } |
| 162 | 162 |
| 163 if ((self = [super init])) { | 163 if ((self = [super init])) { |
| 164 // It is safe to be weak, if a tab goes away (eg user closing a tab) | 164 // It is safe to be weak, if a tab goes away (eg user closing a tab) |
| 165 // the applescript runtime calls tabs in AppleScriptWindow and this | 165 // the applescript runtime calls tabs in AppleScriptWindow and this |
| 166 // particular tab is never returned. | 166 // particular tab is never returned. |
| 167 tabContents_ = aTabContent; | 167 tabContents_ = aTabContent; |
| 168 scoped_nsobject<NSNumber> numID( | 168 scoped_nsobject<NSNumber> numID( |
| 169 [[NSNumber alloc] | 169 [[NSNumber alloc] |
| 170 initWithInt:tabContents_->restore_tab_helper()->session_id().id()]); | 170 initWithInt:tabContents_->session_tab_helper()->session_id().id()]); |
| 171 [self setUniqueID:numID]; | 171 [self setUniqueID:numID]; |
| 172 } | 172 } |
| 173 return self; | 173 return self; |
| 174 } | 174 } |
| 175 | 175 |
| 176 - (void)setTabContent:(TabContents*)aTabContent { | 176 - (void)setTabContent:(TabContents*)aTabContent { |
| 177 DCHECK(aTabContent); | 177 DCHECK(aTabContent); |
| 178 // It is safe to be weak, if a tab goes away (eg user closing a tab) | 178 // It is safe to be weak, if a tab goes away (eg user closing a tab) |
| 179 // the applescript runtime calls tabs in AppleScriptWindow and this | 179 // the applescript runtime calls tabs in AppleScriptWindow and this |
| 180 // particular tab is never returned. | 180 // particular tab is never returned. |
| 181 tabContents_ = aTabContent; | 181 tabContents_ = aTabContent; |
| 182 scoped_nsobject<NSNumber> numID( | 182 scoped_nsobject<NSNumber> numID( |
| 183 [[NSNumber alloc] | 183 [[NSNumber alloc] |
| 184 initWithInt:tabContents_->restore_tab_helper()->session_id().id()]); | 184 initWithInt:tabContents_->session_tab_helper()->session_id().id()]); |
| 185 [self setUniqueID:numID]; | 185 [self setUniqueID:numID]; |
| 186 | 186 |
| 187 if ([self tempURL]) | 187 if ([self tempURL]) |
| 188 [self setURL:[self tempURL]]; | 188 [self setURL:[self tempURL]]; |
| 189 } | 189 } |
| 190 | 190 |
| 191 - (NSString*)URL { | 191 - (NSString*)URL { |
| 192 if (!tabContents_) { | 192 if (!tabContents_) { |
| 193 return nil; | 193 return nil; |
| 194 } | 194 } |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 } | 408 } |
| 409 | 409 |
| 410 string16 script = base::SysNSStringToUTF16( | 410 string16 script = base::SysNSStringToUTF16( |
| 411 [[command evaluatedArguments] objectForKey:@"javascript"]); | 411 [[command evaluatedArguments] objectForKey:@"javascript"]); |
| 412 Value* value = view->ExecuteJavascriptAndGetValue(string16(), script); | 412 Value* value = view->ExecuteJavascriptAndGetValue(string16(), script); |
| 413 NSAppleEventDescriptor* descriptor = valueToDescriptor(value); | 413 NSAppleEventDescriptor* descriptor = valueToDescriptor(value); |
| 414 return [[[AnyResultValue alloc] initWithDescriptor:descriptor] autorelease]; | 414 return [[[AnyResultValue alloc] initWithDescriptor:descriptor] autorelease]; |
| 415 } | 415 } |
| 416 | 416 |
| 417 @end | 417 @end |
| OLD | NEW |