| 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" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 NavigationEntry* entry = webContents_->GetController().GetActiveEntry(); | 141 NavigationEntry* entry = webContents_->GetController().GetActiveEntry(); |
| 142 if (!entry) | 142 if (!entry) |
| 143 return; | 143 return; |
| 144 | 144 |
| 145 const GURL& previousURL = entry->GetVirtualURL(); | 145 const GURL& previousURL = entry->GetVirtualURL(); |
| 146 webContents_->OpenURL(OpenURLParams( | 146 webContents_->OpenURL(OpenURLParams( |
| 147 url, | 147 url, |
| 148 content::Referrer(previousURL, blink::WebReferrerPolicyDefault), | 148 content::Referrer(previousURL, blink::WebReferrerPolicyDefault), |
| 149 CURRENT_TAB, | 149 CURRENT_TAB, |
| 150 content::PAGE_TRANSITION_TYPED, | 150 ui::PAGE_TRANSITION_TYPED, |
| 151 false)); | 151 false)); |
| 152 } | 152 } |
| 153 | 153 |
| 154 - (NSString*)title { | 154 - (NSString*)title { |
| 155 NavigationEntry* entry = webContents_->GetController().GetActiveEntry(); | 155 NavigationEntry* entry = webContents_->GetController().GetActiveEntry(); |
| 156 if (!entry) | 156 if (!entry) |
| 157 return nil; | 157 return nil; |
| 158 | 158 |
| 159 base::string16 title = entry ? entry->GetTitle() : base::string16(); | 159 base::string16 title = entry ? entry->GetTitle() : base::string16(); |
| 160 return base::SysUTF16ToNSString(title); | 160 return base::SysUTF16ToNSString(title); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 260 |
| 261 - (void)handlesViewSourceScriptCommand:(NSScriptCommand*)command { | 261 - (void)handlesViewSourceScriptCommand:(NSScriptCommand*)command { |
| 262 NavigationEntry* entry = | 262 NavigationEntry* entry = |
| 263 webContents_->GetController().GetLastCommittedEntry(); | 263 webContents_->GetController().GetLastCommittedEntry(); |
| 264 if (entry) { | 264 if (entry) { |
| 265 webContents_->OpenURL( | 265 webContents_->OpenURL( |
| 266 OpenURLParams(GURL(content::kViewSourceScheme + std::string(":") + | 266 OpenURLParams(GURL(content::kViewSourceScheme + std::string(":") + |
| 267 entry->GetURL().spec()), | 267 entry->GetURL().spec()), |
| 268 Referrer(), | 268 Referrer(), |
| 269 NEW_FOREGROUND_TAB, | 269 NEW_FOREGROUND_TAB, |
| 270 content::PAGE_TRANSITION_LINK, | 270 ui::PAGE_TRANSITION_LINK, |
| 271 false)); | 271 false)); |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 | 274 |
| 275 - (id)handlesExecuteJavascriptScriptCommand:(NSScriptCommand*)command { | 275 - (id)handlesExecuteJavascriptScriptCommand:(NSScriptCommand*)command { |
| 276 content::RenderFrameHost* frame = webContents_->GetMainFrame(); | 276 content::RenderFrameHost* frame = webContents_->GetMainFrame(); |
| 277 if (!frame) { | 277 if (!frame) { |
| 278 NOTREACHED(); | 278 NOTREACHED(); |
| 279 return nil; | 279 return nil; |
| 280 } | 280 } |
| 281 | 281 |
| 282 NSAppleEventManager* manager = [NSAppleEventManager sharedAppleEventManager]; | 282 NSAppleEventManager* manager = [NSAppleEventManager sharedAppleEventManager]; |
| 283 NSAppleEventManagerSuspensionID suspensionID = | 283 NSAppleEventManagerSuspensionID suspensionID = |
| 284 [manager suspendCurrentAppleEvent]; | 284 [manager suspendCurrentAppleEvent]; |
| 285 content::RenderFrameHost::JavaScriptResultCallback callback = | 285 content::RenderFrameHost::JavaScriptResultCallback callback = |
| 286 base::Bind(&ResumeAppleEventAndSendReply, suspensionID); | 286 base::Bind(&ResumeAppleEventAndSendReply, suspensionID); |
| 287 | 287 |
| 288 base::string16 script = base::SysNSStringToUTF16( | 288 base::string16 script = base::SysNSStringToUTF16( |
| 289 [[command evaluatedArguments] objectForKey:@"javascript"]); | 289 [[command evaluatedArguments] objectForKey:@"javascript"]); |
| 290 frame->ExecuteJavaScript(script, callback); | 290 frame->ExecuteJavaScript(script, callback); |
| 291 | 291 |
| 292 return nil; | 292 return nil; |
| 293 } | 293 } |
| 294 | 294 |
| 295 @end | 295 @end |
| OLD | NEW |