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 // The file contains the implementation of | 5 // The file contains the implementation of |
6 // fileBrowserHandlerInternal.selectFile extension function. | 6 // fileBrowserHandlerInternal.selectFile extension function. |
7 // When invoked, the function does the following: | 7 // When invoked, the function does the following: |
8 // - Verifies that the extension function was invoked as a result of user | 8 // - Verifies that the extension function was invoked as a result of user |
9 // gesture. | 9 // gesture. |
10 // - Display 'save as' dialog using FileSelectorImpl which waits for the user | 10 // - Display 'save as' dialog using FileSelectorImpl which waits for the user |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // ownership of itself after the first call. It will delete itself after the | 93 // ownership of itself after the first call. It will delete itself after the |
94 // extension function is notified of file selection result. | 94 // extension function is notified of file selection result. |
95 // Since the extension function object is ref counted, FileSelectorImpl holds | 95 // Since the extension function object is ref counted, FileSelectorImpl holds |
96 // a reference to it to ensure that the extension function doesn't go away while | 96 // a reference to it to ensure that the extension function doesn't go away while |
97 // waiting for user action. The reference is released after the function is | 97 // waiting for user action. The reference is released after the function is |
98 // notified of the selection result. | 98 // notified of the selection result. |
99 class FileSelectorImpl : public FileSelector, | 99 class FileSelectorImpl : public FileSelector, |
100 public ui::SelectFileDialog::Listener { | 100 public ui::SelectFileDialog::Listener { |
101 public: | 101 public: |
102 FileSelectorImpl(); | 102 FileSelectorImpl(); |
103 virtual ~FileSelectorImpl() OVERRIDE; | 103 virtual ~FileSelectorImpl() override; |
104 | 104 |
105 protected: | 105 protected: |
106 // file_manager::FileSelectr overrides. | 106 // file_manager::FileSelectr overrides. |
107 // Shows save as dialog with suggested name in window bound to |browser|. | 107 // Shows save as dialog with suggested name in window bound to |browser|. |
108 // |allowed_extensions| specifies the file extensions allowed to be shown, | 108 // |allowed_extensions| specifies the file extensions allowed to be shown, |
109 // and selected. Extensions should not include '.'. | 109 // and selected. Extensions should not include '.'. |
110 // | 110 // |
111 // After this method is called, the selector implementation should not be | 111 // After this method is called, the selector implementation should not be |
112 // deleted by the caller. It will delete itself after it receives response | 112 // deleted by the caller. It will delete itself after it receives response |
113 // from SelectFielDialog. | 113 // from SelectFielDialog. |
114 virtual void SelectFile( | 114 virtual void SelectFile( |
115 const base::FilePath& suggested_name, | 115 const base::FilePath& suggested_name, |
116 const std::vector<std::string>& allowed_extensions, | 116 const std::vector<std::string>& allowed_extensions, |
117 Browser* browser, | 117 Browser* browser, |
118 FileBrowserHandlerInternalSelectFileFunction* function) OVERRIDE; | 118 FileBrowserHandlerInternalSelectFileFunction* function) override; |
119 | 119 |
120 // ui::SelectFileDialog::Listener overrides. | 120 // ui::SelectFileDialog::Listener overrides. |
121 virtual void FileSelected(const base::FilePath& path, | 121 virtual void FileSelected(const base::FilePath& path, |
122 int index, | 122 int index, |
123 void* params) OVERRIDE; | 123 void* params) override; |
124 virtual void MultiFilesSelected(const std::vector<base::FilePath>& files, | 124 virtual void MultiFilesSelected(const std::vector<base::FilePath>& files, |
125 void* params) OVERRIDE; | 125 void* params) override; |
126 virtual void FileSelectionCanceled(void* params) OVERRIDE; | 126 virtual void FileSelectionCanceled(void* params) override; |
127 | 127 |
128 private: | 128 private: |
129 // Initiates and shows 'save as' dialog which will be used to prompt user to | 129 // Initiates and shows 'save as' dialog which will be used to prompt user to |
130 // select a file path. The initial selected file name in the dialog will be | 130 // select a file path. The initial selected file name in the dialog will be |
131 // set to |suggested_name|. The dialog will be bound to the tab active in | 131 // set to |suggested_name|. The dialog will be bound to the tab active in |
132 // |browser|. | 132 // |browser|. |
133 // |allowed_extensions| specifies the file extensions allowed to be shown, | 133 // |allowed_extensions| specifies the file extensions allowed to be shown, |
134 // and selected. Extensions should not include '.'. | 134 // and selected. Extensions should not include '.'. |
135 // | 135 // |
136 // Returns boolean indicating whether the dialog has been successfully shown | 136 // Returns boolean indicating whether the dialog has been successfully shown |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 249 } |
250 | 250 |
251 // FileSelectorFactory implementation. | 251 // FileSelectorFactory implementation. |
252 class FileSelectorFactoryImpl : public FileSelectorFactory { | 252 class FileSelectorFactoryImpl : public FileSelectorFactory { |
253 public: | 253 public: |
254 FileSelectorFactoryImpl() {} | 254 FileSelectorFactoryImpl() {} |
255 virtual ~FileSelectorFactoryImpl() {} | 255 virtual ~FileSelectorFactoryImpl() {} |
256 | 256 |
257 // FileSelectorFactory implementation. | 257 // FileSelectorFactory implementation. |
258 // Creates new FileSelectorImplementation for the function. | 258 // Creates new FileSelectorImplementation for the function. |
259 virtual FileSelector* CreateFileSelector() const OVERRIDE { | 259 virtual FileSelector* CreateFileSelector() const override { |
260 return new FileSelectorImpl(); | 260 return new FileSelectorImpl(); |
261 } | 261 } |
262 | 262 |
263 private: | 263 private: |
264 DISALLOW_COPY_AND_ASSIGN(FileSelectorFactoryImpl); | 264 DISALLOW_COPY_AND_ASSIGN(FileSelectorFactoryImpl); |
265 }; | 265 }; |
266 | 266 |
267 } // namespace | 267 } // namespace |
268 | 268 |
269 FileBrowserHandlerInternalSelectFileFunction:: | 269 FileBrowserHandlerInternalSelectFileFunction:: |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 result->entry->file_system_name = entry_definition.file_system_name; | 365 result->entry->file_system_name = entry_definition.file_system_name; |
366 result->entry->file_system_root = entry_definition.file_system_root_url; | 366 result->entry->file_system_root = entry_definition.file_system_root_url; |
367 result->entry->file_full_path = | 367 result->entry->file_full_path = |
368 "/" + entry_definition.full_path.AsUTF8Unsafe(); | 368 "/" + entry_definition.full_path.AsUTF8Unsafe(); |
369 result->entry->file_is_directory = entry_definition.is_directory; | 369 result->entry->file_is_directory = entry_definition.is_directory; |
370 } | 370 } |
371 | 371 |
372 results_ = SelectFile::Results::Create(*result); | 372 results_ = SelectFile::Results::Create(*result); |
373 SendResponse(true); | 373 SendResponse(true); |
374 } | 374 } |
OLD | NEW |