| 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/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
| 14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 15 #include "chrome/browser/chromeos/file_manager/path_util.h" | 16 #include "chrome/browser/chromeos/file_manager/path_util.h" |
| 16 #include "chrome/browser/extensions/component_loader.h" | 17 #include "chrome/browser/extensions/component_loader.h" |
| 17 #include "chrome/browser/extensions/extension_browsertest.h" | 18 #include "chrome/browser/extensions/extension_browsertest.h" |
| 18 #include "chrome/browser/extensions/extension_test_message_listener.h" | 19 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/browser_navigator.h" | 22 #include "chrome/browser/ui/browser_navigator.h" |
| 22 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
| 23 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
| 25 #include "chrome/common/pref_names.h" |
| 24 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/notification_types.h" | 27 #include "content/public/browser/notification_types.h" |
| 26 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
| 27 #include "content/public/test/test_utils.h" | 29 #include "content/public/test/test_utils.h" |
| 28 #include "ui/shell_dialogs/select_file_dialog.h" | 30 #include "ui/shell_dialogs/select_file_dialog.h" |
| 29 #include "ui/shell_dialogs/selected_file_info.h" | 31 #include "ui/shell_dialogs/selected_file_info.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. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 listener_.reset(); | 110 listener_.reset(); |
| 109 | 111 |
| 110 second_dialog_ = NULL; | 112 second_dialog_ = NULL; |
| 111 second_listener_.reset(); | 113 second_listener_.reset(); |
| 112 } | 114 } |
| 113 | 115 |
| 114 // Creates a file system mount point for a directory. | 116 // Creates a file system mount point for a directory. |
| 115 void AddMountPoint(const base::FilePath& path) { | 117 void AddMountPoint(const base::FilePath& path) { |
| 116 EXPECT_TRUE(file_manager::util::RegisterDownloadsMountPoint( | 118 EXPECT_TRUE(file_manager::util::RegisterDownloadsMountPoint( |
| 117 browser()->profile(), path)); | 119 browser()->profile(), path)); |
| 120 browser()->profile()->GetPrefs()->SetFilePath( |
| 121 prefs::kDownloadDefaultDirectory, downloads_dir_); |
| 118 } | 122 } |
| 119 | 123 |
| 120 void CheckJavascriptErrors() { | 124 void CheckJavascriptErrors() { |
| 121 content::RenderViewHost* host = dialog_->GetRenderViewHost(); | 125 content::RenderViewHost* host = dialog_->GetRenderViewHost(); |
| 122 scoped_ptr<base::Value> value = | 126 scoped_ptr<base::Value> value = |
| 123 content::ExecuteScriptAndGetValue(host, "window.JSErrorCount"); | 127 content::ExecuteScriptAndGetValue(host, "window.JSErrorCount"); |
| 124 int js_error_count = 0; | 128 int js_error_count = 0; |
| 125 ASSERT_TRUE(value->GetAsInteger(&js_error_count)); | 129 ASSERT_TRUE(value->GetAsInteger(&js_error_count)); |
| 126 ASSERT_EQ(0, js_error_count); | 130 ASSERT_EQ(0, js_error_count); |
| 127 } | 131 } |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); | 361 ASSERT_FALSE(second_dialog_->IsRunning(owning_window)); |
| 358 | 362 |
| 359 // Click cancel button. | 363 // Click cancel button. |
| 360 CloseDialog(DIALOG_BTN_CANCEL, owning_window); | 364 CloseDialog(DIALOG_BTN_CANCEL, owning_window); |
| 361 | 365 |
| 362 // Listener should have been informed of the cancellation. | 366 // Listener should have been informed of the cancellation. |
| 363 ASSERT_FALSE(listener_->file_selected()); | 367 ASSERT_FALSE(listener_->file_selected()); |
| 364 ASSERT_TRUE(listener_->canceled()); | 368 ASSERT_TRUE(listener_->canceled()); |
| 365 ASSERT_EQ(this, listener_->params()); | 369 ASSERT_EQ(this, listener_->params()); |
| 366 } | 370 } |
| OLD | NEW |