mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@730 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
		
			
				
	
	
		
			43 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| // Copyright (c) 2012 The Chromium Embedded Framework Authors.
 | |
| // Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
 | |
| // Use of this source code is governed by a BSD-style license that can be
 | |
| // found in the LICENSE file.
 | |
| 
 | |
| #include "libcef/browser/download_manager_delegate.h"
 | |
| 
 | |
| #import <Cocoa/Cocoa.h>
 | |
| 
 | |
| #include "base/sys_string_conversions.h"
 | |
| #include "content/public/browser/web_contents.h"
 | |
| 
 | |
| // static
 | |
| FilePath CefDownloadManagerDelegate::PlatformChooseDownloadPath(
 | |
|     content::WebContents* web_contents,
 | |
|     const FilePath& suggested_path) {
 | |
|   FilePath result;
 | |
|   NSSavePanel* savePanel = [NSSavePanel savePanel];
 | |
| 
 | |
|   if (!suggested_path.BaseName().empty()) {
 | |
|     NSString* defaultName = base::SysUTF8ToNSString(
 | |
|         suggested_path.BaseName().value());
 | |
|     [savePanel setNameFieldStringValue:defaultName];
 | |
|   }
 | |
| 
 | |
|   if (!suggested_path.DirName().empty()) {
 | |
|     NSString* defaultDir = base::SysUTF8ToNSString(
 | |
|         suggested_path.DirName().value());
 | |
|     [savePanel setDirectoryURL:[NSURL fileURLWithPath:defaultDir]];
 | |
|   }
 | |
| 
 | |
|   NSView* view = web_contents->GetNativeView();
 | |
|   [savePanel beginSheetModalForWindow:[view window] completionHandler:nil];
 | |
|   if ([savePanel runModal] == NSFileHandlingPanelOKButton) {
 | |
|     NSURL * url = [savePanel URL];
 | |
|     NSString* path = [url path];
 | |
|     result = FilePath([path UTF8String]);
 | |
|   }
 | |
|   [NSApp endSheet:savePanel];
 | |
| 
 | |
|   return result;
 | |
| }
 |