| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/common/platform_util.h" | 5 #include "chrome/common/platform_util.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/sys_string_conversions.h" | 12 #include "base/sys_string_conversions.h" |
| 13 #include "chrome/browser/cocoa/tab_window_controller.h" | 13 #include "chrome/browser/cocoa/tab_window_controller.h" |
| 14 #include "googleurl/src/gurl.h" |
| 14 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 15 | 16 |
| 16 namespace platform_util { | 17 namespace platform_util { |
| 17 | 18 |
| 18 void ShowItemInFolder(const FilePath& full_path) { | 19 void ShowItemInFolder(const FilePath& full_path) { |
| 19 DCHECK_EQ([NSThread currentThread], [NSThread mainThread]); | 20 DCHECK_EQ([NSThread currentThread], [NSThread mainThread]); |
| 20 NSString* path_string = base::SysUTF8ToNSString(full_path.value()); | 21 NSString* path_string = base::SysUTF8ToNSString(full_path.value()); |
| 21 [[NSWorkspace sharedWorkspace] selectFile:path_string | 22 [[NSWorkspace sharedWorkspace] selectFile:path_string |
| 22 inFileViewerRootedAtPath:nil]; | 23 inFileViewerRootedAtPath:nil]; |
| 23 } | 24 } |
| 24 | 25 |
| 25 void OpenItem(const FilePath& full_path) { | 26 void OpenItem(const FilePath& full_path) { |
| 26 DCHECK_EQ([NSThread currentThread], [NSThread mainThread]); | 27 DCHECK_EQ([NSThread currentThread], [NSThread mainThread]); |
| 27 NSString* path_string = base::SysUTF8ToNSString(full_path.value()); | 28 NSString* path_string = base::SysUTF8ToNSString(full_path.value()); |
| 28 [[NSWorkspace sharedWorkspace] openFile:path_string]; | 29 [[NSWorkspace sharedWorkspace] openFile:path_string]; |
| 29 } | 30 } |
| 30 | 31 |
| 32 void OpenExternal(const GURL& url) { |
| 33 DCHECK_EQ([NSThread currentThread], [NSThread mainThread]); |
| 34 NSString* url_string = base::SysUTF8ToNSString(url.spec()); |
| 35 NSURL* ns_url = [NSURL URLWithString:url_string]; |
| 36 [[NSWorkspace sharedWorkspace] openURL:ns_url]; |
| 37 } |
| 38 |
| 31 gfx::NativeWindow GetTopLevel(gfx::NativeView view) { | 39 gfx::NativeWindow GetTopLevel(gfx::NativeView view) { |
| 32 return [view window]; | 40 return [view window]; |
| 33 } | 41 } |
| 34 | 42 |
| 35 string16 GetWindowTitle(gfx::NativeWindow window) { | 43 string16 GetWindowTitle(gfx::NativeWindow window) { |
| 36 NSString* title = nil; | 44 NSString* title = nil; |
| 37 if ([[window delegate] isKindOfClass:[TabWindowController class]]) | 45 if ([[window delegate] isKindOfClass:[TabWindowController class]]) |
| 38 title = [[window delegate] selectedTabTitle]; | 46 title = [[window delegate] selectedTabTitle]; |
| 39 else | 47 else |
| 40 title = [window title]; | 48 title = [window title]; |
| 41 // If we don't yet have a title, use "Untitled". | 49 // If we don't yet have a title, use "Untitled". |
| 42 if (![title length]) | 50 if (![title length]) |
| 43 return WideToUTF16(l10n_util::GetString( | 51 return WideToUTF16(l10n_util::GetString( |
| 44 IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED)); | 52 IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED)); |
| 45 | 53 |
| 46 return base::SysNSStringToUTF16(title); | 54 return base::SysNSStringToUTF16(title); |
| 47 } | 55 } |
| 48 | 56 |
| 49 bool IsWindowActive(gfx::NativeWindow window) { | 57 bool IsWindowActive(gfx::NativeWindow window) { |
| 50 NOTIMPLEMENTED(); | 58 NOTIMPLEMENTED(); |
| 51 return false; | 59 return false; |
| 52 } | 60 } |
| 53 | 61 |
| 54 bool IsVisible(gfx::NativeView view) { | 62 bool IsVisible(gfx::NativeView view) { |
| 55 NOTIMPLEMENTED(); | 63 NOTIMPLEMENTED(); |
| 56 return true; | 64 return true; |
| 57 } | 65 } |
| 58 | 66 |
| 59 } // namespace platform_util | 67 } // namespace platform_util |
| OLD | NEW |