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