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

Side by Side Diff: chrome/browser/chromeos/extensions/file_browser_handler_api.h

Issue 10664002: Add support for drive files to chrome.fileBrowserHandler.selectFile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/extensions/file_browser_handler_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_CHROMEOS_EXTENSIONS_FILE_BROWSER_HANDLER_API_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_HANDLER_API_H_
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_HANDLER_API_H_ 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_HANDLER_API_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector>
9 10
10 #include "base/file_path.h" 11 #include "base/file_path.h"
11 #include "chrome/browser/extensions/extension_function.h" 12 #include "chrome/browser/extensions/extension_function.h"
12 13
13 class Browser; 14 class Browser;
14 class FileHandlerSelectFileFunction; 15 class FileHandlerSelectFileFunction;
15 16
16 namespace file_handler { 17 namespace file_handler {
17 18
18 class FileSelector { 19 class FileSelector {
(...skipping 25 matching lines...) Expand all
44 file_handler::FileSelector* file_selector); 45 file_handler::FileSelector* file_selector);
45 46
46 // Used in test. 47 // Used in test.
47 static void set_gesture_check_disabled_for_test(bool disabled); 48 static void set_gesture_check_disabled_for_test(bool disabled);
48 49
49 protected: 50 protected:
50 virtual ~FileHandlerSelectFileFunction() OVERRIDE; 51 virtual ~FileHandlerSelectFileFunction() OVERRIDE;
51 virtual bool RunImpl() OVERRIDE; 52 virtual bool RunImpl() OVERRIDE;
52 53
53 private: 54 private:
54 // Calls |DoCreateFile| on file thread and invokes the callback. 55 typedef base::Callback<void(const FilePath& virtual_path)>
55 void CreateFileOnFileThread(bool success, 56 GrantPermissionsCallback;
56 const std::string& file_system_name,
57 const GURL& file_system_root);
58 57
59 // Called on UI thread after the file gets created. 58 // Called on UI thread after the file gets created.
60 void OnFileCreated(bool success, 59 void OnFileSystemOpened(bool success,
61 const std::string& file_system_name, 60 const std::string& file_system_name,
62 const GURL& file_system_root); 61 const GURL& file_system_root);
63 62
64 // Grants file access permissions for the created file to the extension with 63 // Grants file access permissions for the created file to the extension with
65 // cros mount point provider and child process security policy. 64 // cros mount point provider and child process security policy.
66 // Returns virtual path for which has been given permission. 65 void GrantPermissions(const GrantPermissionsCallback& callback);
67 FilePath GrantPermissions(); 66
67 // Callback called when we collect all paths and permissions that should be
68 // given to the caller render process in order for it to normally access file.
69 void OnGotPermissionsToGrant(
70 const GrantPermissionsCallback& callback,
71 const FilePath& virtual_path);
68 72
69 // Sends response to the extension. 73 // Sends response to the extension.
70 void Respond(bool success, 74 void Respond(bool success,
71 const std::string& file_system_name, 75 const std::string& file_system_name,
72 const GURL& file_system_root, 76 const GURL& file_system_root,
73 const FilePath& virtual_path); 77 const FilePath& virtual_path);
74 78
75 // Gets file selector that should be used to select the file. 79 // Gets file selector that should be used to select the file.
76 // We should not take the ownership of the selector. 80 // We should not take the ownership of the selector.
77 file_handler::FileSelector* GetFileSelector(); 81 file_handler::FileSelector* GetFileSelector();
78 82
79 // Full file system path of the selected file. 83 // Full file system path of the selected file.
80 FilePath full_path_; 84 FilePath full_path_;
81 85
86 // List of permissions and paths that have to be granted for the selected
87 // files.
88 std::vector<std::pair<FilePath, int> > permissions_to_grant_;
89
82 // |file_selector_for_test_| and |disable_geture_check_for_test_| are used 90 // |file_selector_for_test_| and |disable_geture_check_for_test_| are used
83 // primary in testing to override file selector to be used in the function 91 // primary in testing to override file selector to be used in the function
84 // implementation and disable user gesture check. 92 // implementation and disable user gesture check.
85 // Once set they will be used for every extension function call. 93 // Once set they will be used for every extension function call.
86 static file_handler::FileSelector* file_selector_for_test_; 94 static file_handler::FileSelector* file_selector_for_test_;
87 static bool gesture_check_disabled_for_test_; 95 static bool gesture_check_disabled_for_test_;
88 }; 96 };
89 97
90 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_HANDLER_API_H_ 98 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_HANDLER_API_H_
91 99
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/extensions/file_browser_handler_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698