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

Side by Side Diff: chrome/browser/pdf/pdf_extension_test.cc

Issue 2518493002: Remove obsolete plugin state handling code. (Closed)
Patch Set: Removed unusued function. Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/chrome_plugin_browsertest.cc ('k') | chrome/browser/plugins/plugin_prefs.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/browser/pdf/pdf_extension_test_util.h" 23 #include "chrome/browser/pdf/pdf_extension_test_util.h"
24 #include "chrome/browser/pdf/pdf_extension_util.h" 24 #include "chrome/browser/pdf/pdf_extension_util.h"
25 #include "chrome/browser/plugins/plugin_prefs.h" 25 #include "chrome/browser/plugins/plugin_prefs.h"
26 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/ui/browser.h" 27 #include "chrome/browser/ui/browser.h"
28 #include "chrome/browser/ui/browser_finder.h" 28 #include "chrome/browser/ui/browser_finder.h"
29 #include "chrome/browser/ui/tabs/tab_strip_model.h" 29 #include "chrome/browser/ui/tabs/tab_strip_model.h"
30 #include "chrome/common/chrome_content_client.h" 30 #include "chrome/common/chrome_content_client.h"
31 #include "chrome/common/chrome_paths.h" 31 #include "chrome/common/chrome_paths.h"
32 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
33 #include "chrome/common/pref_names.h"
33 #include "chrome/test/base/ui_test_utils.h" 34 #include "chrome/test/base/ui_test_utils.h"
34 #include "components/zoom/page_zoom.h" 35 #include "components/zoom/page_zoom.h"
35 #include "components/zoom/test/zoom_test_utils.h" 36 #include "components/zoom/test/zoom_test_utils.h"
36 #include "components/zoom/zoom_controller.h" 37 #include "components/zoom/zoom_controller.h"
37 #include "content/public/browser/browser_accessibility_state.h" 38 #include "content/public/browser/browser_accessibility_state.h"
38 #include "content/public/browser/browser_plugin_guest_manager.h" 39 #include "content/public/browser/browser_plugin_guest_manager.h"
39 #include "content/public/browser/download_item.h" 40 #include "content/public/browser/download_item.h"
40 #include "content/public/browser/download_manager.h" 41 #include "content/public/browser/download_manager.h"
41 #include "content/public/browser/notification_observer.h" 42 #include "content/public/browser/notification_observer.h"
42 #include "content/public/browser/notification_registrar.h" 43 #include "content/public/browser/notification_registrar.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 &x)); 277 &x));
277 278
278 int y; 279 int y;
279 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( 280 ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
280 contents, 281 contents,
281 "window.domAutomationController.send(linkScreenPositionY);", 282 "window.domAutomationController.send(linkScreenPositionY);",
282 &y)); 283 &y));
283 284
284 point->SetPoint(x, y); 285 point->SetPoint(x, y);
285 } 286 }
286
287 }; 287 };
288 288
289 IN_PROC_BROWSER_TEST_P(PDFExtensionTest, Load) { 289 IN_PROC_BROWSER_TEST_P(PDFExtensionTest, Load) {
290 #if defined(GOOGLE_CHROME_BUILD) 290 #if defined(GOOGLE_CHROME_BUILD)
291 // Load private PDFs. 291 // Load private PDFs.
292 LoadAllPdfsTest("pdf_private", GetParam()); 292 LoadAllPdfsTest("pdf_private", GetParam());
293 #endif 293 #endif
294 // Load public PDFs. 294 // Load public PDFs.
295 LoadAllPdfsTest("pdf", GetParam()); 295 LoadAllPdfsTest("pdf", GetParam());
296 } 296 }
297 297
298 class DisablePluginHelper : public content::DownloadManager::Observer, 298 class DisablePluginHelper : public content::DownloadManager::Observer {
299 public content::NotificationObserver {
300 public: 299 public:
301 DisablePluginHelper() {} 300 DisablePluginHelper() {}
302 ~DisablePluginHelper() override {} 301 ~DisablePluginHelper() override {}
303 302
304 void DisablePlugin(Profile* profile) { 303 void DisablePlugin(Profile* profile) {
305 registrar_.Add(this, chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, 304 profile->GetPrefs()->SetBoolean(
306 content::Source<Profile>(profile)); 305 prefs::kPluginsAlwaysOpenPdfExternally, true);
307 scoped_refptr<PluginPrefs> prefs(PluginPrefs::GetForProfile(profile));
308 DCHECK(prefs.get());
309 prefs->EnablePluginGroup(
310 false, base::UTF8ToUTF16(ChromeContentClient::kPDFPluginName));
311 // Wait until the plugin has been disabled.
312 disable_run_loop_.Run();
313 } 306 }
314 307
315 const GURL& GetLastUrl() { 308 const GURL& GetLastUrl() {
316 // Wait until the download has been created. 309 // Wait until the download has been created.
317 download_run_loop_.Run(); 310 download_run_loop_.Run();
318 return last_url_; 311 return last_url_;
319 } 312 }
320 313
321 // content::DownloadManager::Observer implementation. 314 // content::DownloadManager::Observer implementation.
322 void OnDownloadCreated(content::DownloadManager* manager, 315 void OnDownloadCreated(content::DownloadManager* manager,
323 content::DownloadItem* item) override { 316 content::DownloadItem* item) override {
324 last_url_ = item->GetURL(); 317 last_url_ = item->GetURL();
325 download_run_loop_.Quit(); 318 download_run_loop_.Quit();
326 } 319 }
327 320
328 // content::NotificationObserver implementation.
329 void Observe(int type,
330 const content::NotificationSource& source,
331 const content::NotificationDetails& details) override {
332 DCHECK_EQ(chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, type);
333 disable_run_loop_.Quit();
334 }
335
336 private: 321 private:
337 content::NotificationRegistrar registrar_; 322 content::NotificationRegistrar registrar_;
338 base::RunLoop disable_run_loop_;
339 base::RunLoop download_run_loop_; 323 base::RunLoop download_run_loop_;
340 GURL last_url_; 324 GURL last_url_;
341 }; 325 };
342 326
343 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, DisablePlugin) { 327 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, DisablePlugin) {
344 // Disable the PDF plugin. 328 // Disable the PDF plugin.
345 content::WebContents* web_contents = 329 content::WebContents* web_contents =
346 browser()->tab_strip_model()->GetActiveWebContents(); 330 browser()->tab_strip_model()->GetActiveWebContents();
347 content::BrowserContext* browser_context = web_contents->GetBrowserContext(); 331 content::BrowserContext* browser_context = web_contents->GetBrowserContext();
348 Profile* profile = Profile::FromBrowserContext(browser_context); 332 Profile* profile = Profile::FromBrowserContext(browser_context);
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 const GURL& url = active_web_contents->GetURL(); 898 const GURL& url = active_web_contents->GetURL();
915 ASSERT_EQ(std::string("http://www.example.com/"), url.spec()); 899 ASSERT_EQ(std::string("http://www.example.com/"), url.spec());
916 } 900 }
917 901
918 // Test that if the plugin tries to load a URL that redirects then it will fail 902 // Test that if the plugin tries to load a URL that redirects then it will fail
919 // to load. This is to avoid the source origin of the document changing during 903 // to load. This is to avoid the source origin of the document changing during
920 // the redirect, which can have security implications. https://crbug.com/653749. 904 // the redirect, which can have security implications. https://crbug.com/653749.
921 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, RedirectsFailInPlugin) { 905 IN_PROC_BROWSER_TEST_F(PDFExtensionTest, RedirectsFailInPlugin) {
922 RunTestsInFile("redirects_fail_test.js", "test.pdf"); 906 RunTestsInFile("redirects_fail_test.js", "test.pdf");
923 } 907 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_plugin_browsertest.cc ('k') | chrome/browser/plugins/plugin_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698