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/ui/views/select_file_dialog_extension.h" | 5 #include "chrome/browser/ui/views/select_file_dialog_extension.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/scoped_temp_dir.h" | 11 #include "base/scoped_temp_dir.h" |
12 #include "base/threading/platform_thread.h" | 12 #include "base/threading/platform_thread.h" |
13 #include "base/utf_string_conversions.h" // ASCIIToUTF16 | 13 #include "base/utf_string_conversions.h" // ASCIIToUTF16 |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "chrome/browser/extensions/extension_browsertest.h" | 15 #include "chrome/browser/extensions/extension_browsertest.h" |
16 #include "chrome/browser/extensions/extension_test_message_listener.h" | 16 #include "chrome/browser/extensions/extension_test_message_listener.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_navigator.h" | 19 #include "chrome/browser/ui/browser_navigator.h" |
20 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 22 #include "content/public/browser/browser_context.h" |
22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
23 #include "content/public/browser/notification_types.h" | 24 #include "content/public/browser/notification_types.h" |
24 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
| 26 #include "content/public/browser/storage_partition.h" |
25 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
26 #include "ui/base/dialogs/select_file_dialog.h" | 28 #include "ui/base/dialogs/select_file_dialog.h" |
27 #include "ui/base/dialogs/selected_file_info.h" | 29 #include "ui/base/dialogs/selected_file_info.h" |
28 #include "webkit/fileapi/file_system_context.h" | 30 #include "webkit/fileapi/file_system_context.h" |
29 #include "webkit/fileapi/file_system_mount_point_provider.h" | 31 #include "webkit/fileapi/file_system_mount_point_provider.h" |
30 | 32 |
31 using content::BrowserContext; | 33 using content::BrowserContext; |
32 | 34 |
33 // Mock listener used by test below. | 35 // Mock listener used by test below. |
34 class MockSelectFileDialogListener : public ui::SelectFileDialog::Listener { | 36 class MockSelectFileDialogListener : public ui::SelectFileDialog::Listener { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 dialog_ = NULL; | 107 dialog_ = NULL; |
106 listener_.reset(); | 108 listener_.reset(); |
107 | 109 |
108 second_dialog_ = NULL; | 110 second_dialog_ = NULL; |
109 second_listener_.reset(); | 111 second_listener_.reset(); |
110 } | 112 } |
111 | 113 |
112 // Creates a file system mount point for a directory. | 114 // Creates a file system mount point for a directory. |
113 void AddMountPoint(const FilePath& path) { | 115 void AddMountPoint(const FilePath& path) { |
114 fileapi::ExternalFileSystemMountPointProvider* provider = | 116 fileapi::ExternalFileSystemMountPointProvider* provider = |
115 BrowserContext::GetFileSystemContext(browser()->profile())-> | 117 BrowserContext::GetDefaultStoragePartition(browser()->profile())-> |
116 external_provider(); | 118 GetFileSystemContext()->external_provider(); |
117 provider->AddLocalMountPoint(path); | 119 provider->AddLocalMountPoint(path); |
118 } | 120 } |
119 | 121 |
120 void OpenDialog(ui::SelectFileDialog::Type dialog_type, | 122 void OpenDialog(ui::SelectFileDialog::Type dialog_type, |
121 const FilePath& file_path, | 123 const FilePath& file_path, |
122 const gfx::NativeWindow& owning_window, | 124 const gfx::NativeWindow& owning_window, |
123 const std::string& additional_message) { | 125 const std::string& additional_message) { |
124 // Spawn a dialog to open a file. The dialog will signal that it is ready | 126 // Spawn a dialog to open a file. The dialog will signal that it is ready |
125 // via chrome.test.sendMessage() in the extension JavaScript. | 127 // via chrome.test.sendMessage() in the extension JavaScript. |
126 ExtensionTestMessageListener init_listener("worker-initialized", | 128 ExtensionTestMessageListener init_listener("worker-initialized", |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); | 343 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); |
342 | 344 |
343 // Click cancel button. | 345 // Click cancel button. |
344 CloseDialog(DIALOG_BTN_CANCEL, owning_window); | 346 CloseDialog(DIALOG_BTN_CANCEL, owning_window); |
345 | 347 |
346 // Listener should have been informed of the cancellation. | 348 // Listener should have been informed of the cancellation. |
347 ASSERT_FALSE(listener_->file_selected()); | 349 ASSERT_FALSE(listener_->file_selected()); |
348 ASSERT_TRUE(listener_->canceled()); | 350 ASSERT_TRUE(listener_->canceled()); |
349 ASSERT_EQ(this, listener_->params()); | 351 ASSERT_EQ(this, listener_->params()); |
350 } | 352 } |
OLD | NEW |