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