| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_PACK_EXTENSION_HANDLER_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_PACK_EXTENSION_HANDLER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/files/file_path.h" | |
| 11 #include "chrome/browser/browsing_data/browsing_data_remover.h" | |
| 12 #include "chrome/browser/extensions/pack_extension_job.h" | |
| 13 #include "chrome/browser/plugins/plugin_data_remover_helper.h" | |
| 14 #include "content/public/browser/web_ui_message_handler.h" | |
| 15 #include "ui/shell_dialogs/select_file_dialog.h" | |
| 16 | |
| 17 namespace content { | |
| 18 class WebUIDataSource; | |
| 19 } | |
| 20 | |
| 21 namespace extensions { | |
| 22 | |
| 23 // Clear browser data handler page UI handler. | |
| 24 class PackExtensionHandler : public content::WebUIMessageHandler, | |
| 25 public ui::SelectFileDialog::Listener, | |
| 26 public PackExtensionJob::Client { | |
| 27 public: | |
| 28 PackExtensionHandler(); | |
| 29 ~PackExtensionHandler() override; | |
| 30 | |
| 31 void GetLocalizedValues(content::WebUIDataSource* source); | |
| 32 | |
| 33 // WebUIMessageHandler implementation. | |
| 34 void RegisterMessages() override; | |
| 35 | |
| 36 // ExtensionPackJob::Client implementation. | |
| 37 void OnPackSuccess(const base::FilePath& crx_file, | |
| 38 const base::FilePath& key_file) override; | |
| 39 | |
| 40 void OnPackFailure(const std::string& error, | |
| 41 ExtensionCreator::ErrorType) override; | |
| 42 | |
| 43 private: | |
| 44 // SelectFileDialog::Listener implementation. | |
| 45 void FileSelected(const base::FilePath& path, | |
| 46 int index, | |
| 47 void* params) override; | |
| 48 void MultiFilesSelected(const std::vector<base::FilePath>& files, | |
| 49 void* params) override; | |
| 50 void FileSelectionCanceled(void* params) override {} | |
| 51 | |
| 52 // JavaScript callback to start packing an extension. | |
| 53 void HandlePackMessage(const base::ListValue* args); | |
| 54 | |
| 55 // JavaScript callback to show a file browse dialog. | |
| 56 // |args[0]| must be a string that specifies the file dialog type: file or | |
| 57 // folder. | |
| 58 // |args[1]| must be a string that specifies the operation to perform: load | |
| 59 // or pem. | |
| 60 void HandleSelectFilePathMessage(const base::ListValue* args); | |
| 61 | |
| 62 // A function to ask the page to show an alert. | |
| 63 void ShowAlert(const std::string& message); | |
| 64 | |
| 65 // Used to package the extension. | |
| 66 scoped_refptr<PackExtensionJob> pack_job_; | |
| 67 | |
| 68 // Returned by the SelectFileDialog machinery. Used to initiate the selection | |
| 69 // dialog. | |
| 70 scoped_refptr<ui::SelectFileDialog> load_extension_dialog_; | |
| 71 | |
| 72 // Path to root directory of extension. | |
| 73 base::FilePath extension_path_; | |
| 74 | |
| 75 // Path to private key file, or null if none specified. | |
| 76 base::FilePath private_key_path_; | |
| 77 | |
| 78 // Path to the last used folder to load an extension. | |
| 79 base::FilePath last_used_path_; | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(PackExtensionHandler); | |
| 82 }; | |
| 83 | |
| 84 } // namespace extensions | |
| 85 | |
| 86 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_PACK_EXTENSION_HANDLER_H_ | |
| OLD | NEW |