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

Side by Side Diff: chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc

Issue 11365181: Remove GetExtensionService from Profile. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: replace missing extension_system include Created 8 years 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 #include <list> 5 #include <list>
6 #include <set> 6 #include <set>
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "chrome/app/chrome_command_ids.h" 12 #include "chrome/app/chrome_command_ids.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chrome_browser_main.h" 14 #include "chrome/browser/chrome_browser_main.h"
15 #include "chrome/browser/chrome_browser_main_extra_parts.h" 15 #include "chrome/browser/chrome_browser_main_extra_parts.h"
16 #include "chrome/browser/chrome_content_browser_client.h" 16 #include "chrome/browser/chrome_content_browser_client.h"
17 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" 17 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
18 #include "chrome/browser/extensions/extension_apitest.h" 18 #include "chrome/browser/extensions/extension_apitest.h"
19 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/extensions/extension_system.h"
20 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h" 22 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h"
22 #include "chrome/browser/tab_contents/render_view_context_menu.h" 23 #include "chrome/browser/tab_contents/render_view_context_menu.h"
23 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_tabstrip.h" 25 #include "chrome/browser/ui/browser_tabstrip.h"
25 #include "chrome/common/chrome_notification_types.h" 26 #include "chrome/common/chrome_notification_types.h"
26 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
27 #include "chrome/test/base/ui_test_utils.h" 28 #include "chrome/test/base/ui_test_utils.h"
28 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/render_process_host.h" 30 #include "content/public/browser/render_process_host.h"
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, UserAction) { 479 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, UserAction) {
479 // Wait for the extension to set itself up and return control to us. 480 // Wait for the extension to set itself up and return control to us.
480 ASSERT_TRUE( 481 ASSERT_TRUE(
481 RunExtensionSubtest("webnavigation", "test_userAction.html")) << message_; 482 RunExtensionSubtest("webnavigation", "test_userAction.html")) << message_;
482 483
483 WebContents* tab = chrome::GetActiveWebContents(browser()); 484 WebContents* tab = chrome::GetActiveWebContents(browser());
484 content::WaitForLoadStop(tab); 485 content::WaitForLoadStop(tab);
485 486
486 ResultCatcher catcher; 487 ResultCatcher catcher;
487 488
488 ExtensionService* service = browser()->profile()->GetExtensionService(); 489 ExtensionService* service = extensions::ExtensionSystem::Get(
490 browser()->profile())->extension_service();
489 const extensions::Extension* extension = 491 const extensions::Extension* extension =
490 service->GetExtensionById(last_loaded_extension_id_, false); 492 service->GetExtensionById(last_loaded_extension_id_, false);
491 GURL url = extension->GetResourceURL("userAction/a.html"); 493 GURL url = extension->GetResourceURL("userAction/a.html");
492 494
493 ui_test_utils::NavigateToURL(browser(), url); 495 ui_test_utils::NavigateToURL(browser(), url);
494 496
495 // This corresponds to "Open link in new tab". 497 // This corresponds to "Open link in new tab".
496 content::ContextMenuParams params; 498 content::ContextMenuParams params;
497 params.is_editable = false; 499 params.is_editable = false;
498 params.media_type = WebKit::WebContextMenuData::MediaTypeNone; 500 params.media_type = WebKit::WebContextMenuData::MediaTypeNone;
(...skipping 12 matching lines...) Expand all
511 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, RequestOpenTab) { 513 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, RequestOpenTab) {
512 // Wait for the extension to set itself up and return control to us. 514 // Wait for the extension to set itself up and return control to us.
513 ASSERT_TRUE(RunExtensionSubtest("webnavigation", "test_requestOpenTab.html")) 515 ASSERT_TRUE(RunExtensionSubtest("webnavigation", "test_requestOpenTab.html"))
514 << message_; 516 << message_;
515 517
516 WebContents* tab = chrome::GetActiveWebContents(browser()); 518 WebContents* tab = chrome::GetActiveWebContents(browser());
517 content::WaitForLoadStop(tab); 519 content::WaitForLoadStop(tab);
518 520
519 ResultCatcher catcher; 521 ResultCatcher catcher;
520 522
521 ExtensionService* service = browser()->profile()->GetExtensionService(); 523 ExtensionService* service = extensions::ExtensionSystem::Get(
524 browser()->profile())->extension_service();
522 const extensions::Extension* extension = 525 const extensions::Extension* extension =
523 service->GetExtensionById(last_loaded_extension_id_, false); 526 service->GetExtensionById(last_loaded_extension_id_, false);
524 GURL url = extension->GetResourceURL("requestOpenTab/a.html"); 527 GURL url = extension->GetResourceURL("requestOpenTab/a.html");
525 528
526 ui_test_utils::NavigateToURL(browser(), url); 529 ui_test_utils::NavigateToURL(browser(), url);
527 530
528 // There's a link on a.html. Middle-click on it to open it in a new tab. 531 // There's a link on a.html. Middle-click on it to open it in a new tab.
529 WebKit::WebMouseEvent mouse_event; 532 WebKit::WebMouseEvent mouse_event;
530 mouse_event.type = WebKit::WebInputEvent::MouseDown; 533 mouse_event.type = WebKit::WebInputEvent::MouseDown;
531 mouse_event.button = WebKit::WebMouseEvent::ButtonMiddle; 534 mouse_event.button = WebKit::WebMouseEvent::ButtonMiddle;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, History) { 606 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, History) {
604 ASSERT_TRUE( 607 ASSERT_TRUE(
605 RunExtensionSubtest("webnavigation", "test_history.html")) 608 RunExtensionSubtest("webnavigation", "test_history.html"))
606 << message_; 609 << message_;
607 } 610 }
608 611
609 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, CrossProcess) { 612 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, CrossProcess) {
610 LoadExtension(test_data_dir_.AppendASCII("webnavigation").AppendASCII("app")); 613 LoadExtension(test_data_dir_.AppendASCII("webnavigation").AppendASCII("app"));
611 LoadExtension(test_data_dir_.AppendASCII("webnavigation")); 614 LoadExtension(test_data_dir_.AppendASCII("webnavigation"));
612 615
613 ExtensionService* service = browser()->profile()->GetExtensionService(); 616 ExtensionService* service = extensions::ExtensionSystem::Get(
617 browser()->profile())->extension_service();
614 const extensions::Extension* extension = 618 const extensions::Extension* extension =
615 service->GetExtensionById(last_loaded_extension_id_, false); 619 service->GetExtensionById(last_loaded_extension_id_, false);
616 620
617 // See crossProcess/d.html. 621 // See crossProcess/d.html.
618 DelayLoadStartAndExecuteJavascript call_script( 622 DelayLoadStartAndExecuteJavascript call_script(
619 test_navigation_listener(), 623 test_navigation_listener(),
620 test_server()->GetURL("test1"), 624 test_server()->GetURL("test1"),
621 "navigate2()", 625 "navigate2()",
622 extension->GetResourceURL("crossProcess/empty.html")); 626 extension->GetResourceURL("crossProcess/empty.html"));
623 627
624 ASSERT_TRUE(RunPageTest( 628 ASSERT_TRUE(RunPageTest(
625 extension->GetResourceURL("test_crossProcess.html").spec())) 629 extension->GetResourceURL("test_crossProcess.html").spec()))
626 << message_; 630 << message_;
627 } 631 }
628 632
629 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, CrossProcessFragment) { 633 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, CrossProcessFragment) {
630 LoadExtension(test_data_dir_.AppendASCII("webnavigation")); 634 LoadExtension(test_data_dir_.AppendASCII("webnavigation"));
631 635
632 ExtensionService* service = browser()->profile()->GetExtensionService(); 636 ExtensionService* service = extensions::ExtensionSystem::Get(
637 browser()->profile())->extension_service();
633 const extensions::Extension* extension = 638 const extensions::Extension* extension =
634 service->GetExtensionById(last_loaded_extension_id_, false); 639 service->GetExtensionById(last_loaded_extension_id_, false);
635 640
636 // See crossProcess/f.html. 641 // See crossProcess/f.html.
637 DelayLoadStartAndExecuteJavascript call_script3( 642 DelayLoadStartAndExecuteJavascript call_script3(
638 test_navigation_listener(), 643 test_navigation_listener(),
639 test_server()->GetURL("test3"), 644 test_server()->GetURL("test3"),
640 "updateFragment()", 645 "updateFragment()",
641 extension->GetResourceURL(base::StringPrintf( 646 extension->GetResourceURL(base::StringPrintf(
642 "crossProcess/f.html?%d#foo", 647 "crossProcess/f.html?%d#foo",
643 test_server()->host_port_pair().port()))); 648 test_server()->host_port_pair().port())));
644 649
645 // See crossProcess/g.html. 650 // See crossProcess/g.html.
646 DelayLoadStartAndExecuteJavascript call_script4( 651 DelayLoadStartAndExecuteJavascript call_script4(
647 test_navigation_listener(), 652 test_navigation_listener(),
648 test_server()->GetURL("test4"), 653 test_server()->GetURL("test4"),
649 "updateFragment()", 654 "updateFragment()",
650 extension->GetResourceURL(base::StringPrintf( 655 extension->GetResourceURL(base::StringPrintf(
651 "crossProcess/g.html?%d#foo", 656 "crossProcess/g.html?%d#foo",
652 test_server()->host_port_pair().port()))); 657 test_server()->host_port_pair().port())));
653 658
654 ASSERT_TRUE(RunPageTest( 659 ASSERT_TRUE(RunPageTest(
655 extension->GetResourceURL("test_crossProcessFragment.html").spec())) 660 extension->GetResourceURL("test_crossProcessFragment.html").spec()))
656 << message_; 661 << message_;
657 } 662 }
658 663
659 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, CrossProcessHistory) { 664 IN_PROC_BROWSER_TEST_F(WebNavigationApiTest, CrossProcessHistory) {
660 LoadExtension(test_data_dir_.AppendASCII("webnavigation")); 665 LoadExtension(test_data_dir_.AppendASCII("webnavigation"));
661 666
662 ExtensionService* service = browser()->profile()->GetExtensionService(); 667 ExtensionService* service = extensions::ExtensionSystem::Get(
668 browser()->profile())->extension_service();
663 const extensions::Extension* extension = 669 const extensions::Extension* extension =
664 service->GetExtensionById(last_loaded_extension_id_, false); 670 service->GetExtensionById(last_loaded_extension_id_, false);
665 671
666 // See crossProcess/e.html. 672 // See crossProcess/e.html.
667 DelayLoadStartAndExecuteJavascript call_script2( 673 DelayLoadStartAndExecuteJavascript call_script2(
668 test_navigation_listener(), 674 test_navigation_listener(),
669 test_server()->GetURL("test2"), 675 test_server()->GetURL("test2"),
670 "updateHistory()", 676 "updateHistory()",
671 extension->GetResourceURL("crossProcess/empty.html")); 677 extension->GetResourceURL("crossProcess/empty.html"));
672 678
(...skipping 10 matching lines...) Expand all
683 test_server()->GetURL("test6"), 689 test_server()->GetURL("test6"),
684 "updateHistory()", 690 "updateHistory()",
685 extension->GetResourceURL("crossProcess/empty.html")); 691 extension->GetResourceURL("crossProcess/empty.html"));
686 692
687 ASSERT_TRUE(RunPageTest( 693 ASSERT_TRUE(RunPageTest(
688 extension->GetResourceURL("test_crossProcessHistory.html").spec())) 694 extension->GetResourceURL("test_crossProcessHistory.html").spec()))
689 << message_; 695 << message_;
690 } 696 }
691 697
692 } // namespace extensions 698 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698