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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 navigationController.GoForward(); | 201 navigationController.GoForward(); |
202 } | 202 } |
203 | 203 |
204 - (void)handlesReloadScriptCommand:(NSScriptCommand*)command { | 204 - (void)handlesReloadScriptCommand:(NSScriptCommand*)command { |
205 NavigationController& navigationController = webContents_->GetController(); | 205 NavigationController& navigationController = webContents_->GetController(); |
206 const bool checkForRepost = true; | 206 const bool checkForRepost = true; |
207 navigationController.Reload(checkForRepost); | 207 navigationController.Reload(checkForRepost); |
208 } | 208 } |
209 | 209 |
210 - (void)handlesStopScriptCommand:(NSScriptCommand*)command { | 210 - (void)handlesStopScriptCommand:(NSScriptCommand*)command { |
211 webContents_->Stop(); | 211 RenderViewHost* view = webContents_->GetRenderViewHost(); |
| 212 if (!view) { |
| 213 // We tolerate Stop being called even before a view has been created. |
| 214 // So just log a warning instead of a NOTREACHED(). |
| 215 DLOG(WARNING) << "Stop: no view for handle "; |
| 216 return; |
| 217 } |
| 218 |
| 219 view->Stop(); |
212 } | 220 } |
213 | 221 |
214 - (void)handlesPrintScriptCommand:(NSScriptCommand*)command { | 222 - (void)handlesPrintScriptCommand:(NSScriptCommand*)command { |
215 bool initiated = | 223 bool initiated = |
216 printing::PrintViewManager::FromWebContents(webContents_)->PrintNow(); | 224 printing::PrintViewManager::FromWebContents(webContents_)->PrintNow(); |
217 if (!initiated) { | 225 if (!initiated) { |
218 AppleScript::SetError(AppleScript::errInitiatePrinting); | 226 AppleScript::SetError(AppleScript::errInitiatePrinting); |
219 } | 227 } |
220 } | 228 } |
221 | 229 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 base::Bind(&ResumeAppleEventAndSendReply, suspensionID); | 294 base::Bind(&ResumeAppleEventAndSendReply, suspensionID); |
287 | 295 |
288 base::string16 script = base::SysNSStringToUTF16( | 296 base::string16 script = base::SysNSStringToUTF16( |
289 [[command evaluatedArguments] objectForKey:@"javascript"]); | 297 [[command evaluatedArguments] objectForKey:@"javascript"]); |
290 frame->ExecuteJavaScript(script, callback); | 298 frame->ExecuteJavaScript(script, callback); |
291 | 299 |
292 return nil; | 300 return nil; |
293 } | 301 } |
294 | 302 |
295 @end | 303 @end |
OLD | NEW |