| 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 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" | 5 #include "chrome/browser/extensions/api/developer_private/entry_picker.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "chrome/browser/extensions/api/developer_private/developer_private_api.
h" | 10 #include "chrome/browser/extensions/api/developer_private/developer_private_api.
h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 namespace api { | 25 namespace api { |
| 26 | 26 |
| 27 EntryPicker::EntryPicker(EntryPickerClient* client, | 27 EntryPicker::EntryPicker(EntryPickerClient* client, |
| 28 content::WebContents* web_contents, | 28 content::WebContents* web_contents, |
| 29 ui::SelectFileDialog::Type picker_type, | 29 ui::SelectFileDialog::Type picker_type, |
| 30 const base::FilePath& last_directory, | 30 const base::FilePath& last_directory, |
| 31 const base::string16& select_title, | 31 const base::string16& select_title, |
| 32 const ui::SelectFileDialog::FileTypeInfo& info, | 32 const ui::SelectFileDialog::FileTypeInfo& info, |
| 33 int file_type_index) | 33 int file_type_index) |
| 34 : client_(client) { | 34 : client_(client) { |
| 35 select_file_dialog_ = ui::SelectFileDialog::Create( | |
| 36 this, new ChromeSelectFilePolicy(web_contents)); | |
| 37 | |
| 38 gfx::NativeWindow owning_window = web_contents ? | |
| 39 platform_util::GetTopLevel(web_contents->GetNativeView()) : | |
| 40 NULL; | |
| 41 | |
| 42 if (g_skip_picker_for_test) { | 35 if (g_skip_picker_for_test) { |
| 43 if (g_path_to_be_picked_for_test) { | 36 if (g_path_to_be_picked_for_test) { |
| 44 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 37 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| 45 base::Bind( | 38 base::Bind( |
| 46 &EntryPicker::FileSelected, | 39 &EntryPicker::FileSelected, |
| 47 base::Unretained(this), *g_path_to_be_picked_for_test, 1, | 40 base::Unretained(this), *g_path_to_be_picked_for_test, 1, |
| 48 static_cast<void*>(NULL))); | 41 static_cast<void*>(nullptr))); |
| 49 } else { | 42 } else { |
| 50 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 43 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| 51 base::Bind( | 44 base::Bind( |
| 52 &EntryPicker::FileSelectionCanceled, | 45 &EntryPicker::FileSelectionCanceled, |
| 53 base::Unretained(this), static_cast<void*>(NULL))); | 46 base::Unretained(this), static_cast<void*>(nullptr))); |
| 54 } | 47 } |
| 55 return; | 48 return; |
| 56 } | 49 } |
| 57 | 50 |
| 51 select_file_dialog_ = ui::SelectFileDialog::Create( |
| 52 this, new ChromeSelectFilePolicy(web_contents)); |
| 53 |
| 54 gfx::NativeWindow owning_window = web_contents ? |
| 55 platform_util::GetTopLevel(web_contents->GetNativeView()) : |
| 56 nullptr; |
| 57 |
| 58 select_file_dialog_->SelectFile(picker_type, | 58 select_file_dialog_->SelectFile(picker_type, |
| 59 select_title, | 59 select_title, |
| 60 last_directory, | 60 last_directory, |
| 61 &info, | 61 &info, |
| 62 file_type_index, | 62 file_type_index, |
| 63 base::FilePath::StringType(), | 63 base::FilePath::StringType(), |
| 64 owning_window, | 64 owning_window, |
| 65 NULL); | 65 nullptr); |
| 66 } | 66 } |
| 67 | 67 |
| 68 EntryPicker::~EntryPicker() {} | 68 EntryPicker::~EntryPicker() {} |
| 69 | 69 |
| 70 void EntryPicker::FileSelected(const base::FilePath& path, | 70 void EntryPicker::FileSelected(const base::FilePath& path, |
| 71 int index, | 71 int index, |
| 72 void* params) { | 72 void* params) { |
| 73 client_->FileSelected(path); | 73 client_->FileSelected(path); |
| 74 delete this; | 74 delete this; |
| 75 } | 75 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 100 } | 100 } |
| 101 | 101 |
| 102 // static | 102 // static |
| 103 void EntryPicker::StopSkippingPickerForTest() { | 103 void EntryPicker::StopSkippingPickerForTest() { |
| 104 g_skip_picker_for_test = false; | 104 g_skip_picker_for_test = false; |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace api | 107 } // namespace api |
| 108 | 108 |
| 109 } // namespace extensions | 109 } // namespace extensions |
| OLD | NEW |