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 #include "chrome/browser/extensions/extension_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/extensions/browsertest_util.h" |
18 #include "chrome/browser/extensions/component_loader.h" | 19 #include "chrome/browser/extensions/component_loader.h" |
19 #include "chrome/browser/extensions/crx_installer.h" | 20 #include "chrome/browser/extensions/crx_installer.h" |
20 #include "chrome/browser/extensions/extension_creator.h" | 21 #include "chrome/browser/extensions/extension_creator.h" |
21 #include "chrome/browser/extensions/extension_error_reporter.h" | 22 #include "chrome/browser/extensions/extension_error_reporter.h" |
22 #include "chrome/browser/extensions/extension_host.h" | 23 #include "chrome/browser/extensions/extension_host.h" |
23 #include "chrome/browser/extensions/extension_install_prompt.h" | 24 #include "chrome/browser/extensions/extension_install_prompt.h" |
24 #include "chrome/browser/extensions/extension_service.h" | 25 #include "chrome/browser/extensions/extension_service.h" |
25 #include "chrome/browser/extensions/extension_system.h" | 26 #include "chrome/browser/extensions/extension_system.h" |
26 #include "chrome/browser/extensions/unpacked_installer.h" | 27 #include "chrome/browser/extensions/unpacked_installer.h" |
27 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 if ((*iter)->GetURL().path() == path) { | 670 if ((*iter)->GetURL().path() == path) { |
670 EXPECT_FALSE(host); | 671 EXPECT_FALSE(host); |
671 host = *iter; | 672 host = *iter; |
672 } | 673 } |
673 num_hosts++; | 674 num_hosts++; |
674 } | 675 } |
675 EXPECT_EQ(expected_hosts, num_hosts); | 676 EXPECT_EQ(expected_hosts, num_hosts); |
676 return host; | 677 return host; |
677 } | 678 } |
678 | 679 |
| 680 std::string ExtensionBrowserTest::ExecuteScriptInBackgroundPage( |
| 681 const std::string& extension_id, |
| 682 const std::string& script) { |
| 683 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( |
| 684 profile(), extension_id, script); |
| 685 } |
| 686 |
679 void ExtensionBrowserTest::Observe( | 687 void ExtensionBrowserTest::Observe( |
680 int type, | 688 int type, |
681 const content::NotificationSource& source, | 689 const content::NotificationSource& source, |
682 const content::NotificationDetails& details) { | 690 const content::NotificationDetails& details) { |
683 switch (type) { | 691 switch (type) { |
684 case chrome::NOTIFICATION_EXTENSION_LOADED: | 692 case chrome::NOTIFICATION_EXTENSION_LOADED: |
685 last_loaded_extension_id_ = | 693 last_loaded_extension_id_ = |
686 content::Details<const Extension>(details).ptr()->id(); | 694 content::Details<const Extension>(details).ptr()->id(); |
687 VLOG(1) << "Got EXTENSION_LOADED notification."; | 695 VLOG(1) << "Got EXTENSION_LOADED notification."; |
688 base::MessageLoopForUI::current()->Quit(); | 696 base::MessageLoopForUI::current()->Quit(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: | 763 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: |
756 VLOG(1) << "Got LOAD_STOP or WEB_CONTENTS_DESTROYED notification."; | 764 VLOG(1) << "Got LOAD_STOP or WEB_CONTENTS_DESTROYED notification."; |
757 base::MessageLoopForUI::current()->Quit(); | 765 base::MessageLoopForUI::current()->Quit(); |
758 break; | 766 break; |
759 | 767 |
760 default: | 768 default: |
761 NOTREACHED(); | 769 NOTREACHED(); |
762 break; | 770 break; |
763 } | 771 } |
764 } | 772 } |
OLD | NEW |