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 // Disable everything on windows only. http://crbug.com/306144 | 5 // Disable everything on windows only. http://crbug.com/306144 |
6 #ifndef OS_WIN | 6 #ifndef OS_WIN |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
18 #include "chrome/browser/chrome_notification_types.h" | |
19 #include "chrome/browser/download/download_file_icon_extractor.h" | 18 #include "chrome/browser/download/download_file_icon_extractor.h" |
20 #include "chrome/browser/download/download_service.h" | 19 #include "chrome/browser/download/download_service.h" |
21 #include "chrome/browser/download/download_service_factory.h" | 20 #include "chrome/browser/download/download_service_factory.h" |
22 #include "chrome/browser/download/download_test_file_activity_observer.h" | 21 #include "chrome/browser/download/download_test_file_activity_observer.h" |
23 #include "chrome/browser/extensions/api/downloads/downloads_api.h" | 22 #include "chrome/browser/extensions/api/downloads/downloads_api.h" |
24 #include "chrome/browser/extensions/browser_action_test_util.h" | 23 #include "chrome/browser/extensions/browser_action_test_util.h" |
25 #include "chrome/browser/extensions/extension_apitest.h" | 24 #include "chrome/browser/extensions/extension_apitest.h" |
26 #include "chrome/browser/extensions/extension_function_test_utils.h" | 25 #include "chrome/browser/extensions/extension_function_test_utils.h" |
27 #include "chrome/browser/history/download_row.h" | 26 #include "chrome/browser/history/download_row.h" |
28 #include "chrome/browser/net/url_request_mock_util.h" | 27 #include "chrome/browser/net/url_request_mock_util.h" |
29 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
30 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
31 #include "chrome/browser/ui/browser_tabstrip.h" | 30 #include "chrome/browser/ui/browser_tabstrip.h" |
32 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
33 #include "chrome/test/base/in_process_browser_test.h" | 32 #include "chrome/test/base/in_process_browser_test.h" |
34 #include "chrome/test/base/ui_test_utils.h" | 33 #include "chrome/test/base/ui_test_utils.h" |
35 #include "content/public/browser/browser_context.h" | 34 #include "content/public/browser/browser_context.h" |
36 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
37 #include "content/public/browser/download_item.h" | 36 #include "content/public/browser/download_item.h" |
38 #include "content/public/browser/download_manager.h" | 37 #include "content/public/browser/download_manager.h" |
39 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
40 #include "content/public/browser/storage_partition.h" | 39 #include "content/public/browser/storage_partition.h" |
41 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
42 #include "content/public/common/content_switches.h" | 41 #include "content/public/common/content_switches.h" |
43 #include "content/public/common/page_transition_types.h" | 42 #include "content/public/common/page_transition_types.h" |
44 #include "content/public/test/download_test_observer.h" | 43 #include "content/public/test/download_test_observer.h" |
45 #include "content/test/net/url_request_slow_download_job.h" | 44 #include "content/test/net/url_request_slow_download_job.h" |
46 #include "extensions/browser/event_router.h" | 45 #include "extensions/browser/event_router.h" |
| 46 #include "extensions/browser/notification_types.h" |
47 #include "net/base/data_url.h" | 47 #include "net/base/data_url.h" |
48 #include "net/base/net_util.h" | 48 #include "net/base/net_util.h" |
49 #include "net/url_request/url_request.h" | 49 #include "net/url_request/url_request.h" |
50 #include "net/url_request/url_request_context.h" | 50 #include "net/url_request/url_request_context.h" |
51 #include "net/url_request/url_request_job.h" | 51 #include "net/url_request/url_request_job.h" |
52 #include "net/url_request/url_request_job_factory.h" | 52 #include "net/url_request/url_request_job_factory.h" |
53 #include "net/url_request/url_request_job_factory_impl.h" | 53 #include "net/url_request/url_request_job_factory_impl.h" |
54 #include "webkit/browser/fileapi/file_system_context.h" | 54 #include "webkit/browser/fileapi/file_system_context.h" |
55 #include "webkit/browser/fileapi/file_system_operation_runner.h" | 55 #include "webkit/browser/fileapi/file_system_operation_runner.h" |
56 #include "webkit/browser/fileapi/file_system_url.h" | 56 #include "webkit/browser/fileapi/file_system_url.h" |
(...skipping 16 matching lines...) Expand all Loading... |
73 struct DownloadIdComparator { | 73 struct DownloadIdComparator { |
74 bool operator() (DownloadItem* first, DownloadItem* second) { | 74 bool operator() (DownloadItem* first, DownloadItem* second) { |
75 return first->GetId() < second->GetId(); | 75 return first->GetId() < second->GetId(); |
76 } | 76 } |
77 }; | 77 }; |
78 | 78 |
79 class DownloadsEventsListener : public content::NotificationObserver { | 79 class DownloadsEventsListener : public content::NotificationObserver { |
80 public: | 80 public: |
81 DownloadsEventsListener() | 81 DownloadsEventsListener() |
82 : waiting_(false) { | 82 : waiting_(false) { |
83 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, | 83 registrar_.Add(this, |
| 84 extensions::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, |
84 content::NotificationService::AllSources()); | 85 content::NotificationService::AllSources()); |
85 } | 86 } |
86 | 87 |
87 virtual ~DownloadsEventsListener() { | 88 virtual ~DownloadsEventsListener() { |
88 registrar_.Remove(this, chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, | 89 registrar_.Remove(this, |
| 90 extensions::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, |
89 content::NotificationService::AllSources()); | 91 content::NotificationService::AllSources()); |
90 STLDeleteElements(&events_); | 92 STLDeleteElements(&events_); |
91 } | 93 } |
92 | 94 |
93 void ClearEvents() { | 95 void ClearEvents() { |
94 STLDeleteElements(&events_); | 96 STLDeleteElements(&events_); |
95 events_.clear(); | 97 events_.clear(); |
96 } | 98 } |
97 | 99 |
98 class Event { | 100 class Event { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 DISALLOW_COPY_AND_ASSIGN(Event); | 171 DISALLOW_COPY_AND_ASSIGN(Event); |
170 }; | 172 }; |
171 | 173 |
172 typedef ExtensionDownloadsEventRouter::DownloadsNotificationSource | 174 typedef ExtensionDownloadsEventRouter::DownloadsNotificationSource |
173 DownloadsNotificationSource; | 175 DownloadsNotificationSource; |
174 | 176 |
175 virtual void Observe(int type, | 177 virtual void Observe(int type, |
176 const content::NotificationSource& source, | 178 const content::NotificationSource& source, |
177 const content::NotificationDetails& details) OVERRIDE { | 179 const content::NotificationDetails& details) OVERRIDE { |
178 switch (type) { | 180 switch (type) { |
179 case chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT: | 181 case extensions::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT: { |
180 { | |
181 DownloadsNotificationSource* dns = | 182 DownloadsNotificationSource* dns = |
182 content::Source<DownloadsNotificationSource>(source).ptr(); | 183 content::Source<DownloadsNotificationSource>(source).ptr(); |
183 Event* new_event = new Event( | 184 Event* new_event = new Event( |
184 dns->profile, | 185 dns->profile, |
185 dns->event_name, | 186 dns->event_name, |
186 *content::Details<std::string>(details).ptr(), base::Time::Now()); | 187 *content::Details<std::string>(details).ptr(), base::Time::Now()); |
187 events_.push_back(new_event); | 188 events_.push_back(new_event); |
188 if (waiting_ && | 189 if (waiting_ && |
189 waiting_for_.get() && | 190 waiting_for_.get() && |
190 new_event->Satisfies(*waiting_for_)) { | 191 new_event->Satisfies(*waiting_for_)) { |
(...skipping 3933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4124 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); | 4125 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); |
4125 EXPECT_FALSE(warnings.empty()); | 4126 EXPECT_FALSE(warnings.empty()); |
4126 EXPECT_EQ(ExtensionWarning::kDownloadFilenameConflict, | 4127 EXPECT_EQ(ExtensionWarning::kDownloadFilenameConflict, |
4127 warnings.begin()->warning_type()); | 4128 warnings.begin()->warning_type()); |
4128 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); | 4129 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); |
4129 } | 4130 } |
4130 | 4131 |
4131 } // namespace extensions | 4132 } // namespace extensions |
4132 | 4133 |
4133 #endif // http://crbug.com/3061144 | 4134 #endif // http://crbug.com/3061144 |
OLD | NEW |