OLD | NEW |
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 // File contains the fileBrowserHandlerInternal.selectFile extension function. | 5 // File contains the fileBrowserHandlerInternal.selectFile extension function. |
6 // The function prompts user to select a file path to be used by the caller. It | 6 // The function prompts user to select a file path to be used by the caller. It |
7 // will fail if it isn't invoked by a user gesture (e.g. a mouse click or a | 7 // will fail if it isn't invoked by a user gesture (e.g. a mouse click or a |
8 // keyboard key press). | 8 // keyboard key press). |
9 // Note that the target file is never actually created by this function, even | 9 // Note that the target file is never actually created by this function, even |
10 // if the selected path doesn't exist. | 10 // if the selected path doesn't exist. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 protected: | 107 protected: |
108 // The class is ref counted, so destructor should not be public. | 108 // The class is ref counted, so destructor should not be public. |
109 virtual ~FileBrowserHandlerInternalSelectFileFunction(); | 109 virtual ~FileBrowserHandlerInternalSelectFileFunction(); |
110 | 110 |
111 // AsyncExtensionFunction implementation. | 111 // AsyncExtensionFunction implementation. |
112 // Runs the extension function implementation. | 112 // Runs the extension function implementation. |
113 virtual bool RunImpl() OVERRIDE; | 113 virtual bool RunImpl() OVERRIDE; |
114 | 114 |
115 private: | 115 private: |
116 // Grants file access permissions for the created file to the caller. | 116 // Respond to the API with selected entry definition. |
117 // Inside this method, | 117 void RespondEntryDefinition( |
118 void GrantPermissions( | |
119 const base::FilePath& full_path, | |
120 const file_manager::util::FileDefinition& file_definition, | |
121 const file_manager::util::EntryDefinition& entry_definition); | 118 const file_manager::util::EntryDefinition& entry_definition); |
122 | 119 |
123 // Creates dictionary value that will be used to as the extension function's | 120 // Creates dictionary value that will be used to as the extension function's |
124 // callback argument and ends extension function execution by calling | 121 // callback argument and ends extension function execution by calling |
125 // |SendResponse(true)|. | 122 // |SendResponse(true)|. |
126 // The |results_| value will be set to dictionary containing two properties: | 123 // The |results_| value will be set to dictionary containing two properties: |
127 // * boolean 'success', which will be equal to |success|. | 124 // * boolean 'success', which will be equal to |success|. |
128 // * object 'entry', which will be set only when |success| is true, and the | 125 // * object 'entry', which will be set only when |success| is true, and the |
129 // conversion to |entry_definition| was successful. In such case, it will | 126 // conversion to |entry_definition| was successful. In such case, it will |
130 // contain information needed to create a FileEntry object for the selected | 127 // contain information needed to create a FileEntry object for the selected |
131 // file. | 128 // file. |
132 void Respond(const file_manager::util::EntryDefinition& entry_definition, | 129 void Respond(const file_manager::util::EntryDefinition& entry_definition, |
133 bool success); | 130 bool success); |
134 | 131 |
135 // Factory used to create FileSelector to be used for prompting user to select | 132 // Factory used to create FileSelector to be used for prompting user to select |
136 // file. | 133 // file. |
137 scoped_ptr<file_manager::FileSelectorFactory> file_selector_factory_; | 134 scoped_ptr<file_manager::FileSelectorFactory> file_selector_factory_; |
138 // Whether user gesture check is disabled. This should be true only in tests. | 135 // Whether user gesture check is disabled. This should be true only in tests. |
139 bool user_gesture_check_enabled_; | 136 bool user_gesture_check_enabled_; |
140 | 137 |
141 // List of permissions and paths that have to be granted for the selected | 138 // List of permissions and paths that have to be granted for the selected |
142 // files. | 139 // files. |
143 std::vector<std::pair<base::FilePath, int> > permissions_to_grant_; | 140 std::vector<std::pair<base::FilePath, int> > permissions_to_grant_; |
144 | 141 |
145 DECLARE_EXTENSION_FUNCTION("fileBrowserHandlerInternal.selectFile", | 142 DECLARE_EXTENSION_FUNCTION("fileBrowserHandlerInternal.selectFile", |
146 FILEBROWSERHANDLERINTERNAL_SELECTFILE) | 143 FILEBROWSERHANDLERINTERNAL_SELECTFILE) |
147 }; | 144 }; |
148 | 145 |
149 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_BROWSER_HANDLER_
API_H_ | 146 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_FILE_BROWSER_HANDLER_
API_H_ |
OLD | NEW |