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

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
59 // Creates file on provided file path.
60 bool DoCreateFile();
61 57
62 // Called on UI thread after the file gets created. 58 // Called on UI thread after the file gets created.
63 void OnFileCreated(bool success, 59 void OnFileSystemOpened(bool success,
64 const std::string& file_system_name, 60 const std::string& file_system_name,
65 const GURL& file_system_root); 61 const GURL& file_system_root);
66 62
67 // 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
68 // cros mount point provider and child process security policy. 64 // cros mount point provider and child process security policy.
69 // Returns virtual path for which has been given permission. 65 void GrantPermissions(const GrantPermissionsCallback& callback);
70 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);
71 72
72 // Sends response to the extension. 73 // Sends response to the extension.
73 void Respond(bool success, 74 void Respond(bool success,
74 const std::string& file_system_name, 75 const std::string& file_system_name,
75 const GURL& file_system_root, 76 const GURL& file_system_root,
76 const FilePath& virtual_path); 77 const FilePath& virtual_path);
77 78
78 // Gets file selector that should be used to select the file. 79 // Gets file selector that should be used to select the file.
79 // We should not take the ownership of the selector. 80 // We should not take the ownership of the selector.
80 file_handler::FileSelector* GetFileSelector(); 81 file_handler::FileSelector* GetFileSelector();
81 82
82 // Full file system path of the selected file. 83 // Full file system path of the selected file.
83 FilePath full_path_; 84 FilePath full_path_;
84 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
85 // |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
86 // 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
87 // implementation and disable user gesture check. 92 // implementation and disable user gesture check.
88 // Once set they will be used for every extension function call. 93 // Once set they will be used for every extension function call.
89 static file_handler::FileSelector* file_selector_for_test_; 94 static file_handler::FileSelector* file_selector_for_test_;
90 static bool gesture_check_disabled_for_test_; 95 static bool gesture_check_disabled_for_test_;
91 }; 96 };
92 97
93 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_HANDLER_API_H_ 98 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_HANDLER_API_H_
94 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