Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: chrome/browser/ui/cocoa/applescript/tab_applescript.mm

Issue 8983010: Convert WebContents to return a content::NavigationController instead of the implementation. Upda... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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" 16 #include "chrome/browser/sessions/restore_tab_helper.h"
17 #include "chrome/browser/sessions/session_id.h" 17 #include "chrome/browser/sessions/session_id.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_wrapper.h" 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
20 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
21 #include "content/browser/download/save_package.h" 21 #include "content/browser/download/save_package.h"
22 #include "content/browser/renderer_host/render_view_host.h" 22 #include "content/browser/renderer_host/render_view_host.h"
23 #include "content/browser/tab_contents/navigation_controller.h"
24 #include "content/browser/tab_contents/tab_contents.h" 23 #include "content/browser/tab_contents/tab_contents.h"
24 #include "content/public/browser/navigation_controller.h"
25 #include "content/public/browser/navigation_entry.h" 25 #include "content/public/browser/navigation_entry.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"
28 28
29 using content::NavigationEntry; 29 using content::NavigationEntry;
30 using content::OpenURLParams; 30 using content::OpenURLParams;
31 using content::Referrer; 31 using content::Referrer;
32 32
33 @interface AnyResultValue : NSObject { 33 @interface AnyResultValue : NSObject {
34 @private 34 @private
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 RenderViewHost* view = tabContents_->tab_contents()->GetRenderViewHost(); 301 RenderViewHost* view = tabContents_->tab_contents()->GetRenderViewHost();
302 if (!view) { 302 if (!view) {
303 NOTREACHED(); 303 NOTREACHED();
304 return; 304 return;
305 } 305 }
306 306
307 view->SelectAll(); 307 view->SelectAll();
308 } 308 }
309 309
310 - (void)handlesGoBackScriptCommand:(NSScriptCommand*)command { 310 - (void)handlesGoBackScriptCommand:(NSScriptCommand*)command {
311 NavigationController& navigationController = 311 content::NavigationController& navigationController =
312 tabContents_->tab_contents()->GetController(); 312 tabContents_->tab_contents()->GetController();
313 if (navigationController.CanGoBack()) 313 if (navigationController.CanGoBack())
314 navigationController.GoBack(); 314 navigationController.GoBack();
315 } 315 }
316 316
317 - (void)handlesGoForwardScriptCommand:(NSScriptCommand*)command { 317 - (void)handlesGoForwardScriptCommand:(NSScriptCommand*)command {
318 NavigationController& navigationController = 318 content::NavigationController& navigationController =
319 tabContents_->tab_contents()->GetController(); 319 tabContents_->tab_contents()->GetController();
320 if (navigationController.CanGoForward()) 320 if (navigationController.CanGoForward())
321 navigationController.GoForward(); 321 navigationController.GoForward();
322 } 322 }
323 323
324 - (void)handlesReloadScriptCommand:(NSScriptCommand*)command { 324 - (void)handlesReloadScriptCommand:(NSScriptCommand*)command {
325 NavigationController& navigationController = 325 content::NavigationController& navigationController =
326 tabContents_->tab_contents()->GetController(); 326 tabContents_->tab_contents()->GetController();
327 const bool checkForRepost = true; 327 const bool checkForRepost = true;
328 navigationController.Reload(checkForRepost); 328 navigationController.Reload(checkForRepost);
329 } 329 }
330 330
331 - (void)handlesStopScriptCommand:(NSScriptCommand*)command { 331 - (void)handlesStopScriptCommand:(NSScriptCommand*)command {
332 RenderViewHost* view = tabContents_->tab_contents()->GetRenderViewHost(); 332 RenderViewHost* view = tabContents_->tab_contents()->GetRenderViewHost();
333 if (!view) { 333 if (!view) {
334 // We tolerate Stop being called even before a view has been created. 334 // We tolerate Stop being called even before a view has been created.
335 // So just log a warning instead of a NOTREACHED(). 335 // So just log a warning instead of a NOTREACHED().
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } 412 }
413 413
414 string16 script = base::SysNSStringToUTF16( 414 string16 script = base::SysNSStringToUTF16(
415 [[command evaluatedArguments] objectForKey:@"javascript"]); 415 [[command evaluatedArguments] objectForKey:@"javascript"]);
416 Value* value = view->ExecuteJavascriptAndGetValue(string16(), script); 416 Value* value = view->ExecuteJavascriptAndGetValue(string16(), script);
417 NSAppleEventDescriptor* descriptor = valueToDescriptor(value); 417 NSAppleEventDescriptor* descriptor = valueToDescriptor(value);
418 return [[[AnyResultValue alloc] initWithDescriptor:descriptor] autorelease]; 418 return [[[AnyResultValue alloc] initWithDescriptor:descriptor] autorelease];
419 } 419 }
420 420
421 @end 421 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698