Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / platform_util.h
blob822e89d71473544592bf5610b0a7875ac62c7b6b
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PLATFORM_UTIL_H_
6 #define CHROME_BROWSER_PLATFORM_UTIL_H_
8 #include <string>
10 #include "base/callback_forward.h"
11 #include "base/strings/string16.h"
12 #include "ui/gfx/native_widget_types.h"
14 class GURL;
15 class Profile;
17 namespace base {
18 class FilePath;
21 namespace platform_util {
23 // Result of calling OpenFile() or OpenFolder() passed into OpenOperationResult.
24 enum OpenOperationResult {
25 OPEN_SUCCEEDED,
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.
37 // Type of item that is the target of the OpenItem() call.
38 enum OpenItemType { OPEN_FILE, OPEN_FOLDER };
40 // Callback used with OpenFile and OpenFolder.
41 typedef base::Callback<void(OpenOperationResult)> OpenOperationCallback;
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.
48 // It is an error if the object at |full_path| does not match the intended type
49 // specified in |item_type|. This error will be reported to |callback|.
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);
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. |profile| is not used in platforms other than Chrome OS. Must
64 // be called on the UI thread.
65 void ShowItemInFolder(Profile* profile, const base::FilePath& full_path);
67 // Open the given external protocol URL in the desktop's default manner.
68 // (For example, mailto: URLs in the default mail user agent.)
69 // Must be called from the UI thread.
70 void OpenExternal(Profile* profile, const GURL& url);
72 // Get the top level window for the native view. This can return NULL.
73 gfx::NativeWindow GetTopLevel(gfx::NativeView view);
75 // Returns a NativeView handle for parenting dialogs off |window|. This can be
76 // used to position a dialog using a NativeWindow, when a NativeView (e.g.
77 // browser tab) isn't available.
78 gfx::NativeView GetViewForWindow(gfx::NativeWindow window);
80 // Get the direct parent of |view|, may return NULL.
81 gfx::NativeView GetParent(gfx::NativeView view);
83 // Returns true if |window| is the foreground top level window.
84 bool IsWindowActive(gfx::NativeWindow window);
86 // Activate the window, bringing it to the foreground top level.
87 void ActivateWindow(gfx::NativeWindow window);
89 // Returns true if the view is visible. The exact definition of this is
90 // platform-specific, but it is generally not "visible to the user", rather
91 // whether the view has the visible attribute set.
92 bool IsVisible(gfx::NativeView view);
94 #if defined(OS_MACOSX)
95 // On 10.7+, back and forward swipe gestures can be triggered using a scroll
96 // gesture, if enabled in System Preferences. This function returns true if
97 // the feature is supported and enabled, and false otherwise.
98 bool IsSwipeTrackingFromScrollEventsEnabled();
99 #endif
101 } // namespace platform_util
103 #endif // CHROME_BROWSER_PLATFORM_UTIL_H_