Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc

Issue 562603002: Move PageTransition from //content/public/common to //ui/base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 21 matching lines...) Expand all
32 #include "chrome/test/base/in_process_browser_test.h" 32 #include "chrome/test/base/in_process_browser_test.h"
33 #include "chrome/test/base/ui_test_utils.h" 33 #include "chrome/test/base/ui_test_utils.h"
34 #include "content/public/browser/browser_context.h" 34 #include "content/public/browser/browser_context.h"
35 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/download_item.h" 36 #include "content/public/browser/download_item.h"
37 #include "content/public/browser/download_manager.h" 37 #include "content/public/browser/download_manager.h"
38 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
39 #include "content/public/browser/storage_partition.h" 39 #include "content/public/browser/storage_partition.h"
40 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
41 #include "content/public/common/content_switches.h" 41 #include "content/public/common/content_switches.h"
42 #include "content/public/common/page_transition_types.h"
43 #include "content/public/test/download_test_observer.h" 42 #include "content/public/test/download_test_observer.h"
44 #include "content/test/net/url_request_slow_download_job.h" 43 #include "content/test/net/url_request_slow_download_job.h"
45 #include "extensions/browser/event_router.h" 44 #include "extensions/browser/event_router.h"
46 #include "extensions/browser/notification_types.h" 45 #include "extensions/browser/notification_types.h"
47 #include "net/base/data_url.h" 46 #include "net/base/data_url.h"
48 #include "net/base/net_util.h" 47 #include "net/base/net_util.h"
49 #include "net/url_request/url_request.h" 48 #include "net/url_request/url_request.h"
50 #include "net/url_request/url_request_context.h" 49 #include "net/url_request/url_request_context.h"
51 #include "net/url_request/url_request_job.h" 50 #include "net/url_request/url_request_job.h"
52 #include "net/url_request/url_request_job_factory.h" 51 #include "net/url_request/url_request_job_factory.h"
53 #include "net/url_request/url_request_job_factory_impl.h" 52 #include "net/url_request/url_request_job_factory_impl.h"
54 #include "storage/browser/fileapi/file_system_context.h" 53 #include "storage/browser/fileapi/file_system_context.h"
55 #include "storage/browser/fileapi/file_system_operation_runner.h" 54 #include "storage/browser/fileapi/file_system_operation_runner.h"
56 #include "storage/browser/fileapi/file_system_url.h" 55 #include "storage/browser/fileapi/file_system_url.h"
56 #include "ui/base/page_transition_types.h"
57 57
58 using content::BrowserContext; 58 using content::BrowserContext;
59 using content::BrowserThread; 59 using content::BrowserThread;
60 using content::DownloadItem; 60 using content::DownloadItem;
61 using content::DownloadManager; 61 using content::DownloadManager;
62 using content::URLRequestSlowDownloadJob; 62 using content::URLRequestSlowDownloadJob;
63 63
64 namespace errors = download_extension_errors; 64 namespace errors = download_extension_errors;
65 65
66 namespace extensions { 66 namespace extensions {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 268
269 void LoadExtension(const char* name) { 269 void LoadExtension(const char* name) {
270 // Store the created Extension object so that we can attach it to 270 // Store the created Extension object so that we can attach it to
271 // ExtensionFunctions. Also load the extension in incognito profiles for 271 // ExtensionFunctions. Also load the extension in incognito profiles for
272 // testing incognito. 272 // testing incognito.
273 extension_ = LoadExtensionIncognito(test_data_dir_.AppendASCII(name)); 273 extension_ = LoadExtensionIncognito(test_data_dir_.AppendASCII(name));
274 CHECK(extension_); 274 CHECK(extension_);
275 content::WebContents* tab = chrome::AddSelectedTabWithURL( 275 content::WebContents* tab = chrome::AddSelectedTabWithURL(
276 current_browser(), 276 current_browser(),
277 extension_->GetResourceURL("empty.html"), 277 extension_->GetResourceURL("empty.html"),
278 content::PAGE_TRANSITION_LINK); 278 ui::PAGE_TRANSITION_LINK);
279 EventRouter::Get(current_browser()->profile()) 279 EventRouter::Get(current_browser()->profile())
280 ->AddEventListener(downloads::OnCreated::kEventName, 280 ->AddEventListener(downloads::OnCreated::kEventName,
281 tab->GetRenderProcessHost(), 281 tab->GetRenderProcessHost(),
282 GetExtensionId()); 282 GetExtensionId());
283 EventRouter::Get(current_browser()->profile()) 283 EventRouter::Get(current_browser()->profile())
284 ->AddEventListener(downloads::OnChanged::kEventName, 284 ->AddEventListener(downloads::OnChanged::kEventName,
285 tab->GetRenderProcessHost(), 285 tab->GetRenderProcessHost(),
286 GetExtensionId()); 286 GetExtensionId());
287 EventRouter::Get(current_browser()->profile()) 287 EventRouter::Get(current_browser()->profile())
288 ->AddEventListener(downloads::OnErased::kEventName, 288 ->AddEventListener(downloads::OnErased::kEventName,
289 tab->GetRenderProcessHost(), 289 tab->GetRenderProcessHost(),
290 GetExtensionId()); 290 GetExtensionId());
291 } 291 }
292 292
293 content::RenderProcessHost* AddFilenameDeterminer() { 293 content::RenderProcessHost* AddFilenameDeterminer() {
294 ExtensionDownloadsEventRouter::SetDetermineFilenameTimeoutSecondsForTesting( 294 ExtensionDownloadsEventRouter::SetDetermineFilenameTimeoutSecondsForTesting(
295 2); 295 2);
296 content::WebContents* tab = chrome::AddSelectedTabWithURL( 296 content::WebContents* tab = chrome::AddSelectedTabWithURL(
297 current_browser(), 297 current_browser(),
298 extension_->GetResourceURL("empty.html"), 298 extension_->GetResourceURL("empty.html"),
299 content::PAGE_TRANSITION_LINK); 299 ui::PAGE_TRANSITION_LINK);
300 EventRouter::Get(current_browser()->profile()) 300 EventRouter::Get(current_browser()->profile())
301 ->AddEventListener(downloads::OnDeterminingFilename::kEventName, 301 ->AddEventListener(downloads::OnDeterminingFilename::kEventName,
302 tab->GetRenderProcessHost(), 302 tab->GetRenderProcessHost(),
303 GetExtensionId()); 303 GetExtensionId());
304 return tab->GetRenderProcessHost(); 304 return tab->GetRenderProcessHost();
305 } 305 }
306 306
307 void RemoveFilenameDeterminer(content::RenderProcessHost* host) { 307 void RemoveFilenameDeterminer(content::RenderProcessHost* host) {
308 EventRouter::Get(current_browser()->profile())->RemoveEventListener( 308 EventRouter::Get(current_browser()->profile())->RemoveEventListener(
309 downloads::OnDeterminingFilename::kEventName, host, GetExtensionId()); 309 downloads::OnDeterminingFilename::kEventName, host, GetExtensionId());
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 579
580 DownloadsEventsListener* events_listener() { return events_listener_.get(); } 580 DownloadsEventsListener* events_listener() { return events_listener_.get(); }
581 581
582 private: 582 private:
583 void SetUpExtensionFunction(UIThreadExtensionFunction* function) { 583 void SetUpExtensionFunction(UIThreadExtensionFunction* function) {
584 if (extension_) { 584 if (extension_) {
585 // Recreate the tab each time for insulation. 585 // Recreate the tab each time for insulation.
586 content::WebContents* tab = chrome::AddSelectedTabWithURL( 586 content::WebContents* tab = chrome::AddSelectedTabWithURL(
587 current_browser(), 587 current_browser(),
588 extension_->GetResourceURL("empty.html"), 588 extension_->GetResourceURL("empty.html"),
589 content::PAGE_TRANSITION_LINK); 589 ui::PAGE_TRANSITION_LINK);
590 function->set_extension(extension_); 590 function->set_extension(extension_);
591 function->SetRenderViewHost(tab->GetRenderViewHost()); 591 function->SetRenderViewHost(tab->GetRenderViewHost());
592 } 592 }
593 } 593 }
594 594
595 void CreateAndSetDownloadsDirectory() { 595 void CreateAndSetDownloadsDirectory() {
596 ASSERT_TRUE(downloads_directory_.CreateUniqueTempDir()); 596 ASSERT_TRUE(downloads_directory_.CreateUniqueTempDir());
597 current_browser()->profile()->GetPrefs()->SetFilePath( 597 current_browser()->profile()->GetPrefs()->SetFilePath(
598 prefs::kDownloadDefaultDirectory, 598 prefs::kDownloadDefaultDirectory,
599 downloads_directory_.path()); 599 downloads_directory_.path());
(...skipping 3555 matching lines...) Expand 10 before | Expand all | Expand 10 after
4155 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); 4155 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action);
4156 EXPECT_FALSE(warnings.empty()); 4156 EXPECT_FALSE(warnings.empty());
4157 EXPECT_EQ(Warning::kDownloadFilenameConflict, 4157 EXPECT_EQ(Warning::kDownloadFilenameConflict,
4158 warnings.begin()->warning_type()); 4158 warnings.begin()->warning_type());
4159 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); 4159 EXPECT_EQ("incumbent", warnings.begin()->extension_id());
4160 } 4160 }
4161 4161
4162 } // namespace extensions 4162 } // namespace extensions
4163 4163
4164 #endif // http://crbug.com/3061144 4164 #endif // http://crbug.com/3061144
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698