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

Side by Side Diff: chrome/browser/platform_util.h

Issue 352393002: Be explicit about target type in platform_util::OpenItem() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with trunk Created 5 years, 10 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) 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 #ifndef CHROME_BROWSER_PLATFORM_UTIL_H_ 5 #ifndef CHROME_BROWSER_PLATFORM_UTIL_H_
6 #define CHROME_BROWSER_PLATFORM_UTIL_H_ 6 #define CHROME_BROWSER_PLATFORM_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback_forward.h"
10 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
11 #include "ui/gfx/native_widget_types.h" 12 #include "ui/gfx/native_widget_types.h"
12 13
13 class GURL; 14 class GURL;
14 class Profile; 15 class Profile;
15 16
16 namespace base { 17 namespace base {
17 class FilePath; 18 class FilePath;
18 } 19 }
19 20
20 namespace platform_util { 21 namespace platform_util {
21 22
22 // Show the given file in a file manager. If possible, select the file. 23 // Result of calling OpenFile() or OpenFolder() passed into OpenOperationResult.
23 // The |profile| is used to determine the running profile of file manager app 24 enum OpenOperationResult {
24 // in Chrome OS only. Not used in other platforms. 25 OPEN_SUCCEEDED,
25 // Must be called from the UI thread. 26 OPEN_FAILED_PATH_NOT_FOUND, // Specified path does not exist.
27 OPEN_FAILED_INVALID_TYPE, // Type of object found at path did not match what
28 // was expected. I.e. OpenFile was called on a
29 // folder or OpenFolder called on a file.
30 OPEN_FAILED_NO_HANLDER_FOR_FILE_TYPE, // There was no file handler capable of
31 // opening file. Only returned on
32 // ChromeOS.
33 OPEN_FAILED_FILE_ERROR, // Open operation failed due to some other file
34 // error.
35 };
36
37 // Type of item that is the target of the OpenItem() call.
38 enum OpenItemType { OPEN_FILE, OPEN_FOLDER };
39
40 // Callback used with OpenFile and OpenFolder.
41 typedef base::Callback<void(OpenOperationResult)> OpenOperationCallback;
42
43 // Opens the item specified by |full_path|, which is expected to be the type
44 // indicated by |item_type| in the desktop's default manner.
45 // |callback| will be invoked on the UI thread with the result of the open
46 // operation.
47 //
48 // It is an error if the object at |full_path| does not match the intended type
49 // specifeid in |item_type|. This error will be reported to |callback|.
James Hawkins 2015/03/06 15:37:34 s/specifeid/specified/
asanka 2015/03/06 21:09:40 Done.
50 //
51 // Note: On all platforms, the user may be shown additional UI if there is no
52 // suitable handler for |full_path|. On Chrome OS, all errors will result in
53 // visible error messages iff |callback| is not specified.
54 // Must be called on the UI thread.
55 void OpenItem(Profile* profile,
56 const base::FilePath& full_path,
57 OpenItemType item_type,
58 const OpenOperationCallback& callback);
59
60 // Opens the folder containing the item specified by |full_path| in the
61 // desktop's default manner. If possible, the item will be selected. The
62 // |profile| is used to determine the running profile of file manager app in
63 // Chrome OS only. Not used in other platforms. Must be called on the UI
James Hawkins 2015/03/06 15:37:33 nit: The sentence "Not used in other platforms" is
asanka 2015/03/06 21:09:40 Clarified. Thanks!
64 // thread.
26 void ShowItemInFolder(Profile* profile, const base::FilePath& full_path); 65 void ShowItemInFolder(Profile* profile, const base::FilePath& full_path);
27 66
28 // Open the given file in the desktop's default manner.
29 // Must be called from the UI thread.
30 void OpenItem(Profile* profile, const base::FilePath& full_path);
31
32 // Open the given external protocol URL in the desktop's default manner. 67 // Open the given external protocol URL in the desktop's default manner.
33 // (For example, mailto: URLs in the default mail user agent.) 68 // (For example, mailto: URLs in the default mail user agent.)
34 // Must be called from the UI thread. 69 // Must be called from the UI thread.
35 void OpenExternal(Profile* profile, const GURL& url); 70 void OpenExternal(Profile* profile, const GURL& url);
36 71
37 // Get the top level window for the native view. This can return NULL. 72 // Get the top level window for the native view. This can return NULL.
38 gfx::NativeWindow GetTopLevel(gfx::NativeView view); 73 gfx::NativeWindow GetTopLevel(gfx::NativeView view);
39 74
40 // Returns a NativeView handle for parenting dialogs off |window|. This can be 75 // Returns a NativeView handle for parenting dialogs off |window|. This can be
41 // used to position a dialog using a NativeWindow, when a NativeView (e.g. 76 // used to position a dialog using a NativeWindow, when a NativeView (e.g.
(...skipping 17 matching lines...) Expand all
59 #if defined(OS_MACOSX) 94 #if defined(OS_MACOSX)
60 // On 10.7+, back and forward swipe gestures can be triggered using a scroll 95 // On 10.7+, back and forward swipe gestures can be triggered using a scroll
61 // gesture, if enabled in System Preferences. This function returns true if 96 // gesture, if enabled in System Preferences. This function returns true if
62 // the feature is supported and enabled, and false otherwise. 97 // the feature is supported and enabled, and false otherwise.
63 bool IsSwipeTrackingFromScrollEventsEnabled(); 98 bool IsSwipeTrackingFromScrollEventsEnabled();
64 #endif 99 #endif
65 100
66 } // namespace platform_util 101 } // namespace platform_util
67 102
68 #endif // CHROME_BROWSER_PLATFORM_UTIL_H_ 103 #endif // CHROME_BROWSER_PLATFORM_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698