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