OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/ui/webui/extensions/extension_loader_handler.h" | 5 #include "chrome/browser/ui/webui/extensions/extension_loader_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 base::ReadFileToString(path, &data); | 44 base::ReadFileToString(path, &data); |
45 return data; | 45 return data; |
46 } | 46 } |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 class ExtensionLoaderHandler::FileHelper | 50 class ExtensionLoaderHandler::FileHelper |
51 : public ui::SelectFileDialog::Listener { | 51 : public ui::SelectFileDialog::Listener { |
52 public: | 52 public: |
53 explicit FileHelper(ExtensionLoaderHandler* loader_handler); | 53 explicit FileHelper(ExtensionLoaderHandler* loader_handler); |
54 virtual ~FileHelper(); | 54 ~FileHelper() override; |
55 | 55 |
56 // Create a FileDialog for the user to select the unpacked extension | 56 // Create a FileDialog for the user to select the unpacked extension |
57 // directory. | 57 // directory. |
58 void ChooseFile(); | 58 void ChooseFile(); |
59 | 59 |
60 private: | 60 private: |
61 // ui::SelectFileDialog::Listener implementation. | 61 // ui::SelectFileDialog::Listener implementation. |
62 virtual void FileSelected(const base::FilePath& path, | 62 void FileSelected(const base::FilePath& path, |
63 int index, | 63 int index, |
64 void* params) override; | 64 void* params) override; |
65 virtual void MultiFilesSelected( | 65 void MultiFilesSelected(const std::vector<base::FilePath>& files, |
66 const std::vector<base::FilePath>& files, void* params) override; | 66 void* params) override; |
67 | 67 |
68 // The associated ExtensionLoaderHandler. Weak, but guaranteed to be alive, | 68 // The associated ExtensionLoaderHandler. Weak, but guaranteed to be alive, |
69 // as it owns this object. | 69 // as it owns this object. |
70 ExtensionLoaderHandler* loader_handler_; | 70 ExtensionLoaderHandler* loader_handler_; |
71 | 71 |
72 // The dialog used to pick a directory when loading an unpacked extension. | 72 // The dialog used to pick a directory when loading an unpacked extension. |
73 scoped_refptr<ui::SelectFileDialog> load_extension_dialog_; | 73 scoped_refptr<ui::SelectFileDialog> load_extension_dialog_; |
74 | 74 |
75 // The last selected directory, so we can start in the same spot. | 75 // The last selected directory, so we can start in the same spot. |
76 base::FilePath last_unpacked_directory_; | 76 base::FilePath last_unpacked_directory_; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 314 } |
315 | 315 |
316 void ExtensionLoaderHandler::NotifyFrontendOfFailure() { | 316 void ExtensionLoaderHandler::NotifyFrontendOfFailure() { |
317 web_ui()->CallJavascriptFunction( | 317 web_ui()->CallJavascriptFunction( |
318 "extensions.ExtensionLoader.notifyLoadFailed", | 318 "extensions.ExtensionLoader.notifyLoadFailed", |
319 failures_); | 319 failures_); |
320 failures_.Clear(); | 320 failures_.Clear(); |
321 } | 321 } |
322 | 322 |
323 } // namespace extensions | 323 } // namespace extensions |
OLD | NEW |