| 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 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
| 11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 12 #include "chrome/browser/printing/print_view_manager.h" | 12 #include "chrome/browser/printing/print_view_manager.h" |
| 13 #include "chrome/browser/sessions/session_id.h" | 13 #include "chrome/browser/sessions/session_id.h" |
| 14 #include "chrome/browser/sessions/session_tab_helper.h" | 14 #include "chrome/browser/sessions/session_tab_helper.h" |
| 15 #include "chrome/browser/ui/cocoa/applescript/apple_event_util.h" | 15 #include "chrome/browser/ui/cocoa/applescript/apple_event_util.h" |
| 16 #include "chrome/browser/ui/cocoa/applescript/error_applescript.h" | 16 #include "chrome/browser/ui/cocoa/applescript/error_applescript.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "content/public/browser/navigation_controller.h" | 18 #include "content/public/browser/navigation_controller.h" |
| 19 #include "content/public/browser/navigation_entry.h" | 19 #include "content/public/browser/navigation_entry.h" |
| 20 #include "content/public/browser/render_frame_host.h" |
| 20 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
| 21 #include "content/public/browser/save_page_type.h" | 22 #include "content/public/browser/save_page_type.h" |
| 22 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/browser/web_contents_delegate.h" | 24 #include "content/public/browser/web_contents_delegate.h" |
| 24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 25 | 26 |
| 26 using content::NavigationController; | 27 using content::NavigationController; |
| 27 using content::NavigationEntry; | 28 using content::NavigationEntry; |
| 28 using content::OpenURLParams; | 29 using content::OpenURLParams; |
| 30 using content::RenderFrameHost; |
| 29 using content::RenderViewHost; | 31 using content::RenderViewHost; |
| 30 using content::Referrer; | 32 using content::Referrer; |
| 31 using content::WebContents; | 33 using content::WebContents; |
| 32 | 34 |
| 33 namespace { | 35 namespace { |
| 34 | 36 |
| 35 void ResumeAppleEventAndSendReply(NSAppleEventManagerSuspensionID suspension_id, | 37 void ResumeAppleEventAndSendReply(NSAppleEventManagerSuspensionID suspension_id, |
| 36 const base::Value* result_value) { | 38 const base::Value* result_value) { |
| 37 NSAppleEventDescriptor* result_descriptor = | 39 NSAppleEventDescriptor* result_descriptor = |
| 38 chrome::mac::ValueToAppleEventDescriptor(result_value); | 40 chrome::mac::ValueToAppleEventDescriptor(result_value); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 RenderViewHost* view = webContents_->GetRenderViewHost(); | 179 RenderViewHost* view = webContents_->GetRenderViewHost(); |
| 178 if (!view) { | 180 if (!view) { |
| 179 NOTREACHED(); | 181 NOTREACHED(); |
| 180 return; | 182 return; |
| 181 } | 183 } |
| 182 | 184 |
| 183 view->Redo(); | 185 view->Redo(); |
| 184 } | 186 } |
| 185 | 187 |
| 186 - (void)handlesCutScriptCommand:(NSScriptCommand*)command { | 188 - (void)handlesCutScriptCommand:(NSScriptCommand*)command { |
| 187 RenderViewHost* view = webContents_->GetRenderViewHost(); | 189 RenderFrameHost* frame = webContents_->GetFocusedFrame(); |
| 188 if (!view) { | 190 if (!frame) { |
| 189 NOTREACHED(); | 191 NOTREACHED(); |
| 190 return; | 192 return; |
| 191 } | 193 } |
| 192 | 194 |
| 193 view->Cut(); | 195 frame->Cut(); |
| 194 } | 196 } |
| 195 | 197 |
| 196 - (void)handlesCopyScriptCommand:(NSScriptCommand*)command { | 198 - (void)handlesCopyScriptCommand:(NSScriptCommand*)command { |
| 197 RenderViewHost* view = webContents_->GetRenderViewHost(); | 199 RenderFrameHost* frame = webContents_->GetFocusedFrame(); |
| 198 if (!view) { | 200 if (!frame) { |
| 199 NOTREACHED(); | 201 NOTREACHED(); |
| 200 return; | 202 return; |
| 201 } | 203 } |
| 202 | 204 |
| 203 view->Copy(); | 205 frame->Copy(); |
| 204 } | 206 } |
| 205 | 207 |
| 206 - (void)handlesPasteScriptCommand:(NSScriptCommand*)command { | 208 - (void)handlesPasteScriptCommand:(NSScriptCommand*)command { |
| 207 RenderViewHost* view = webContents_->GetRenderViewHost(); | 209 RenderFrameHost* frame = webContents_->GetFocusedFrame(); |
| 208 if (!view) { | 210 if (!frame) { |
| 209 NOTREACHED(); | 211 NOTREACHED(); |
| 210 return; | 212 return; |
| 211 } | 213 } |
| 212 | 214 |
| 213 view->Paste(); | 215 frame->Paste(); |
| 214 } | 216 } |
| 215 | 217 |
| 216 - (void)handlesSelectAllScriptCommand:(NSScriptCommand*)command { | 218 - (void)handlesSelectAllScriptCommand:(NSScriptCommand*)command { |
| 217 RenderViewHost* view = webContents_->GetRenderViewHost(); | 219 RenderViewHost* view = webContents_->GetRenderViewHost(); |
| 218 if (!view) { | 220 if (!view) { |
| 219 NOTREACHED(); | 221 NOTREACHED(); |
| 220 return; | 222 return; |
| 221 } | 223 } |
| 222 | 224 |
| 223 view->SelectAll(); | 225 view->SelectAll(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 [[command evaluatedArguments] objectForKey:@"javascript"]); | 333 [[command evaluatedArguments] objectForKey:@"javascript"]); |
| 332 view->ExecuteJavascriptInWebFrameCallbackResult( | 334 view->ExecuteJavascriptInWebFrameCallbackResult( |
| 333 base::string16(), // frame_xpath | 335 base::string16(), // frame_xpath |
| 334 script, | 336 script, |
| 335 callback); | 337 callback); |
| 336 | 338 |
| 337 return nil; | 339 return nil; |
| 338 } | 340 } |
| 339 | 341 |
| 340 @end | 342 @end |
| OLD | NEW |