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

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

Issue 2495123003: Continue attempts to reinstall corrupt policy extensions across restarts (Closed)
Patch Set: merged latest from origin/master 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
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 "base/files/file_util.h"
8 #include "base/path_service.h"
7 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
8 #include "content/public/test/browser_test_utils.h" 10 #include "content/public/test/browser_test_utils.h"
9 #include "extensions/browser/extension_host.h" 11 #include "extensions/browser/extension_host.h"
10 #include "extensions/browser/process_manager.h" 12 #include "extensions/browser/process_manager.h"
11 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
12 14
15 #if defined(OS_CHROMEOS)
16 #include "chrome/browser/extensions/updater/local_extension_cache.h"
17 #include "chromeos/chromeos_paths.h"
18 #endif
19
13 namespace extensions { 20 namespace extensions {
14 namespace browsertest_util { 21 namespace browsertest_util {
15 22
16 std::string ExecuteScriptInBackgroundPage(Profile* profile, 23 std::string ExecuteScriptInBackgroundPage(Profile* profile,
17 const std::string& extension_id, 24 const std::string& extension_id,
18 const std::string& script) { 25 const std::string& script) {
19 extensions::ProcessManager* manager = 26 extensions::ProcessManager* manager =
20 extensions::ProcessManager::Get(profile); 27 extensions::ProcessManager::Get(profile);
21 extensions::ExtensionHost* host = 28 extensions::ExtensionHost* host =
22 manager->GetBackgroundHostForExtension(extension_id); 29 manager->GetBackgroundHostForExtension(extension_id);
(...skipping 17 matching lines...) Expand all
40 extensions::ProcessManager::Get(profile); 47 extensions::ProcessManager::Get(profile);
41 extensions::ExtensionHost* host = 48 extensions::ExtensionHost* host =
42 manager->GetBackgroundHostForExtension(extension_id); 49 manager->GetBackgroundHostForExtension(extension_id);
43 if (host == NULL) { 50 if (host == NULL) {
44 ADD_FAILURE() << "Extension " << extension_id << " has no background page."; 51 ADD_FAILURE() << "Extension " << extension_id << " has no background page.";
45 return false; 52 return false;
46 } 53 }
47 return content::ExecuteScript(host->host_contents(), script); 54 return content::ExecuteScript(host->host_contents(), script);
48 } 55 }
49 56
57 void CreateAndInitializeLocalCache() {
58 #if defined(OS_CHROMEOS)
59 base::FilePath extension_cache_dir;
60 CHECK(PathService::Get(chromeos::DIR_DEVICE_EXTENSION_LOCAL_CACHE,
61 &extension_cache_dir));
62 base::FilePath cache_init_file = extension_cache_dir.Append(
63 extensions::LocalExtensionCache::kCacheReadyFlagFileName);
64 EXPECT_EQ(base::WriteFile(cache_init_file, "", 0), 0);
65 #endif
66 }
67
50 } // namespace browsertest_util 68 } // namespace browsertest_util
51 } // namespace extensions 69 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/browsertest_util.h ('k') | chrome/browser/extensions/chrome_content_verifier_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698