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

Side by Side Diff: chrome/browser/extensions/browsertest_util.cc

Issue 147923005: Split ExtensionSystem interface from ExtensionSystemImpl implementation, part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re^3base Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browsertest_util.h" 5 #include "chrome/browser/extensions/browsertest_util.h"
6 6
7 #include "chrome/browser/extensions/extension_host.h" 7 #include "chrome/browser/extensions/extension_host.h"
8 #include "chrome/browser/extensions/extension_system.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "content/public/test/browser_test_utils.h" 9 #include "content/public/test/browser_test_utils.h"
10 #include "extensions/browser/extension_system.h"
10 #include "extensions/browser/process_manager.h" 11 #include "extensions/browser/process_manager.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace extensions { 14 namespace extensions {
14 namespace browsertest_util { 15 namespace browsertest_util {
15 16
16 std::string ExecuteScriptInBackgroundPage(Profile* profile, 17 std::string ExecuteScriptInBackgroundPage(Profile* profile,
17 const std::string& extension_id, 18 const std::string& extension_id,
18 const std::string& script) { 19 const std::string& script) {
19 extensions::ProcessManager* manager = 20 extensions::ProcessManager* manager =
20 extensions::ExtensionSystem::Get(profile)->process_manager(); 21 extensions::ExtensionSystem::Get(profile)->process_manager();
21 extensions::ExtensionHost* host = 22 extensions::ExtensionHost* host =
22 manager->GetBackgroundHostForExtension(extension_id); 23 manager->GetBackgroundHostForExtension(extension_id);
23 if (host == NULL) { 24 if (host == NULL) {
24 ADD_FAILURE() << "Extension " << extension_id << " has no background page."; 25 ADD_FAILURE() << "Extension " << extension_id << " has no background page.";
25 return ""; 26 return "";
26 } 27 }
27 std::string result; 28 std::string result;
28 if (!content::ExecuteScriptAndExtractString( 29 if (!content::ExecuteScriptAndExtractString(
29 host->host_contents(), script, &result)) { 30 host->host_contents(), script, &result)) {
30 ADD_FAILURE() << "Executing script failed: " << script; 31 ADD_FAILURE() << "Executing script failed: " << script;
31 result.clear(); 32 result.clear();
32 } 33 }
33 return result; 34 return result;
34 } 35 }
35 36
36 } // namespace browsertest_util 37 } // namespace browsertest_util
37 } // namespace extensions 38 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/browser_action_apitest.cc ('k') | chrome/browser/extensions/chrome_extensions_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698