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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 // it doesn't try and call back. | 92 // it doesn't try and call back. |
93 if (load_extension_dialog_.get()) | 93 if (load_extension_dialog_.get()) |
94 load_extension_dialog_->ListenerDestroyed(); | 94 load_extension_dialog_->ListenerDestroyed(); |
95 } | 95 } |
96 | 96 |
97 void ExtensionLoaderHandler::FileHelper::ChooseFile() { | 97 void ExtensionLoaderHandler::FileHelper::ChooseFile() { |
98 static const int kFileTypeIndex = 0; // No file type information to index. | 98 static const int kFileTypeIndex = 0; // No file type information to index. |
99 static const ui::SelectFileDialog::Type kSelectType = | 99 static const ui::SelectFileDialog::Type kSelectType = |
100 ui::SelectFileDialog::SELECT_FOLDER; | 100 ui::SelectFileDialog::SELECT_FOLDER; |
101 | 101 |
102 gfx::NativeWindow parent_window = | |
103 loader_handler_->web_ui()->GetWebContents()->GetTopLevelNativeWindow(); | |
102 if (!load_extension_dialog_.get()) { | 104 if (!load_extension_dialog_.get()) { |
103 load_extension_dialog_ = ui::SelectFileDialog::Create( | 105 load_extension_dialog_ = ui::SelectFileDialog::Create( |
104 this, | 106 this, |
105 new ChromeSelectFilePolicy( | 107 new ChromeSelectFilePolicy( |
106 loader_handler_->web_ui()->GetWebContents())); | 108 loader_handler_->web_ui()->GetWebContents())); |
109 } else if (load_extension_dialog_->IsRunning(parent_window)) { | |
110 LOG(ERROR) << "Select file dialog already in use!"; | |
Devlin
2014/12/04 21:39:10
Generally, we don't like to log errors for things
| |
111 return; | |
107 } | 112 } |
108 | 113 |
109 load_extension_dialog_->SelectFile( | 114 load_extension_dialog_->SelectFile( |
110 kSelectType, | 115 kSelectType, |
111 title_, | 116 title_, |
112 last_unpacked_directory_, | 117 last_unpacked_directory_, |
113 NULL, | 118 NULL, |
114 kFileTypeIndex, | 119 kFileTypeIndex, |
115 base::FilePath::StringType(), | 120 base::FilePath::StringType(), |
116 loader_handler_->web_ui()->GetWebContents()->GetTopLevelNativeWindow(), | 121 parent_window, |
117 NULL); | 122 NULL); |
118 | 123 |
119 content::RecordComputedAction("Options_LoadUnpackedExtension"); | 124 content::RecordComputedAction("Options_LoadUnpackedExtension"); |
120 } | 125 } |
121 | 126 |
122 void ExtensionLoaderHandler::FileHelper::FileSelected( | 127 void ExtensionLoaderHandler::FileHelper::FileSelected( |
123 const base::FilePath& path, int index, void* params) { | 128 const base::FilePath& path, int index, void* params) { |
124 loader_handler_->LoadUnpackedExtensionImpl(path); | 129 loader_handler_->LoadUnpackedExtensionImpl(path); |
125 } | 130 } |
126 | 131 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 } | 306 } |
302 | 307 |
303 void ExtensionLoaderHandler::NotifyFrontendOfFailure() { | 308 void ExtensionLoaderHandler::NotifyFrontendOfFailure() { |
304 web_ui()->CallJavascriptFunction( | 309 web_ui()->CallJavascriptFunction( |
305 "extensions.ExtensionLoader.notifyLoadFailed", | 310 "extensions.ExtensionLoader.notifyLoadFailed", |
306 failures_); | 311 failures_); |
307 failures_.Clear(); | 312 failures_.Clear(); |
308 } | 313 } |
309 | 314 |
310 } // namespace extensions | 315 } // namespace extensions |
OLD | NEW |