OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/chrome_plugin_service_filter.h" | 10 #include "chrome/browser/chrome_plugin_service_filter.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 GViewRequestInterceptorTest() | 91 GViewRequestInterceptorTest() |
92 : ui_thread_(BrowserThread::UI, &message_loop_), | 92 : ui_thread_(BrowserThread::UI, &message_loop_), |
93 file_thread_(BrowserThread::FILE, &message_loop_), | 93 file_thread_(BrowserThread::FILE, &message_loop_), |
94 io_thread_(BrowserThread::IO, &message_loop_), | 94 io_thread_(BrowserThread::IO, &message_loop_), |
95 plugin_list_(NULL, 0) {} | 95 plugin_list_(NULL, 0) {} |
96 | 96 |
97 virtual void SetUp() { | 97 virtual void SetUp() { |
98 content::ResourceContext* resource_context = | 98 content::ResourceContext* resource_context = |
99 content::MockResourceContext::GetInstance(); | 99 content::MockResourceContext::GetInstance(); |
100 net::URLRequestContext* request_context = | 100 net::URLRequestContext* request_context = |
101 resource_context->request_context(); | 101 resource_context->GetRequestContext(); |
102 old_factory_ = request_context->job_factory(); | 102 old_factory_ = request_context->job_factory(); |
103 job_factory_.SetProtocolHandler("http", new GViewRequestProtocolFactory); | 103 job_factory_.SetProtocolHandler("http", new GViewRequestProtocolFactory); |
104 job_factory_.AddInterceptor(new GViewRequestInterceptor); | 104 job_factory_.AddInterceptor(new GViewRequestInterceptor); |
105 request_context->set_job_factory(&job_factory_); | 105 request_context->set_job_factory(&job_factory_); |
106 PluginPrefsFactory::GetInstance()->ForceRegisterPrefsForTest(&prefs_); | 106 PluginPrefsFactory::GetInstance()->ForceRegisterPrefsForTest(&prefs_); |
107 plugin_prefs_ = new PluginPrefs(); | 107 plugin_prefs_ = new PluginPrefs(); |
108 plugin_prefs_->SetPrefs(&prefs_); | 108 plugin_prefs_->SetPrefs(&prefs_); |
109 ChromePluginServiceFilter* filter = | 109 ChromePluginServiceFilter* filter = |
110 ChromePluginServiceFilter::GetInstance(); | 110 ChromePluginServiceFilter::GetInstance(); |
111 filter->RegisterResourceContext(plugin_prefs_, resource_context); | 111 filter->RegisterResourceContext(plugin_prefs_, resource_context); |
112 PluginService::GetInstance()->SetFilter(filter); | 112 PluginService::GetInstance()->SetFilter(filter); |
113 | 113 |
114 ASSERT_TRUE(PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path_)); | 114 ASSERT_TRUE(PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path_)); |
115 | 115 |
116 handler_ = new content::DummyResourceHandler(); | 116 handler_ = new content::DummyResourceHandler(); |
117 | 117 |
118 PluginService::GetInstance()->SetPluginListForTesting(&plugin_list_); | 118 PluginService::GetInstance()->SetPluginListForTesting(&plugin_list_); |
119 PluginService::GetInstance()->Init(); | 119 PluginService::GetInstance()->Init(); |
120 } | 120 } |
121 | 121 |
122 virtual void TearDown() { | 122 virtual void TearDown() { |
123 plugin_prefs_->ShutdownOnUIThread(); | 123 plugin_prefs_->ShutdownOnUIThread(); |
124 content::ResourceContext* resource_context = | 124 content::ResourceContext* resource_context = |
125 content::MockResourceContext::GetInstance(); | 125 content::MockResourceContext::GetInstance(); |
126 net::URLRequestContext* request_context = | 126 net::URLRequestContext* request_context = |
127 resource_context->request_context(); | 127 resource_context->GetRequestContext(); |
128 request_context->set_job_factory(old_factory_); | 128 request_context->set_job_factory(old_factory_); |
129 ChromePluginServiceFilter* filter = | 129 ChromePluginServiceFilter* filter = |
130 ChromePluginServiceFilter::GetInstance(); | 130 ChromePluginServiceFilter::GetInstance(); |
131 filter->UnregisterResourceContext(resource_context); | 131 filter->UnregisterResourceContext(resource_context); |
132 PluginService::GetInstance()->SetFilter(NULL); | 132 PluginService::GetInstance()->SetFilter(NULL); |
133 } | 133 } |
134 | 134 |
135 void RegisterPDFPlugin() { | 135 void RegisterPDFPlugin() { |
136 webkit::WebPluginInfo info; | 136 webkit::WebPluginInfo info; |
137 info.path = pdf_path_; | 137 info.path = pdf_path_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 -1, // parent_frame_id | 178 -1, // parent_frame_id |
179 ResourceType::MAIN_FRAME, | 179 ResourceType::MAIN_FRAME, |
180 content::PAGE_TRANSITION_LINK, | 180 content::PAGE_TRANSITION_LINK, |
181 0, // upload_size | 181 0, // upload_size |
182 false, // is_download | 182 false, // is_download |
183 true, // allow_download | 183 true, // allow_download |
184 false, // has_user_gesture | 184 false, // has_user_gesture |
185 WebKit::WebReferrerPolicyDefault, | 185 WebKit::WebReferrerPolicyDefault, |
186 context); | 186 context); |
187 request->SetUserData(NULL, info); | 187 request->SetUserData(NULL, info); |
188 request->set_context(context->request_context()); | 188 request->set_context(context->GetRequestContext()); |
189 } | 189 } |
190 | 190 |
191 protected: | 191 protected: |
192 base::ShadowingAtExitManager at_exit_manager_; // Deletes PluginService. | 192 base::ShadowingAtExitManager at_exit_manager_; // Deletes PluginService. |
193 MessageLoopForIO message_loop_; | 193 MessageLoopForIO message_loop_; |
194 content::TestBrowserThread ui_thread_; | 194 content::TestBrowserThread ui_thread_; |
195 content::TestBrowserThread file_thread_; | 195 content::TestBrowserThread file_thread_; |
196 content::TestBrowserThread io_thread_; | 196 content::TestBrowserThread io_thread_; |
197 webkit::npapi::MockPluginList plugin_list_; | 197 webkit::npapi::MockPluginList plugin_list_; |
198 TestingPrefService prefs_; | 198 TestingPrefService prefs_; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 SetupRequest(&request); | 291 SetupRequest(&request); |
292 request.Start(); | 292 request.Start(); |
293 MessageLoop::current()->Run(); | 293 MessageLoop::current()->Run(); |
294 EXPECT_EQ(0, test_delegate_.received_redirect_count()); | 294 EXPECT_EQ(0, test_delegate_.received_redirect_count()); |
295 EXPECT_EQ(GURL(kPdfBlob), request.url()); | 295 EXPECT_EQ(GURL(kPdfBlob), request.url()); |
296 } | 296 } |
297 | 297 |
298 } // namespace | 298 } // namespace |
299 | 299 |
300 } // namespace chromeos | 300 } // namespace chromeos |
OLD | NEW |