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 #import "chrome/browser/ui/cocoa/extensions/extension_install_prompt_test_utils.
h" | 5 #import "chrome/browser/ui/cocoa/extensions/extension_install_prompt_test_utils.
h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/threading/thread_restrictions.h" |
11 #include "chrome/common/chrome_paths.h" | 12 #include "chrome/common/chrome_paths.h" |
12 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
13 | 14 |
14 using extensions::Extension; | 15 using extensions::Extension; |
15 | 16 |
16 namespace chrome { | 17 namespace chrome { |
17 | 18 |
18 scoped_refptr<extensions::Extension> LoadInstallPromptExtension( | 19 scoped_refptr<extensions::Extension> LoadInstallPromptExtension( |
19 const char* extension_dir_name, | 20 const char* extension_dir_name, |
20 const char* manifest_file) { | 21 const char* manifest_file) { |
| 22 base::ThreadRestrictions::ScopedAllowIO allow_io; |
21 scoped_refptr<Extension> extension; | 23 scoped_refptr<Extension> extension; |
22 | 24 |
23 base::FilePath path; | 25 base::FilePath path; |
24 PathService::Get(chrome::DIR_TEST_DATA, &path); | 26 PathService::Get(chrome::DIR_TEST_DATA, &path); |
25 path = path.AppendASCII("extensions") | 27 path = path.AppendASCII("extensions") |
26 .AppendASCII(extension_dir_name) | 28 .AppendASCII(extension_dir_name) |
27 .AppendASCII(manifest_file); | 29 .AppendASCII(manifest_file); |
28 | 30 |
29 std::string error; | 31 std::string error; |
30 JSONFileValueDeserializer deserializer(path); | 32 JSONFileValueDeserializer deserializer(path); |
(...skipping 11 matching lines...) Expand all Loading... |
42 LOG(ERROR) << error; | 44 LOG(ERROR) << error; |
43 | 45 |
44 return extension; | 46 return extension; |
45 } | 47 } |
46 | 48 |
47 scoped_refptr<Extension> LoadInstallPromptExtension() { | 49 scoped_refptr<Extension> LoadInstallPromptExtension() { |
48 return LoadInstallPromptExtension("install_prompt", "extension.json"); | 50 return LoadInstallPromptExtension("install_prompt", "extension.json"); |
49 } | 51 } |
50 | 52 |
51 gfx::Image LoadInstallPromptIcon() { | 53 gfx::Image LoadInstallPromptIcon() { |
| 54 base::ThreadRestrictions::ScopedAllowIO allow_io; |
52 base::FilePath path; | 55 base::FilePath path; |
53 PathService::Get(chrome::DIR_TEST_DATA, &path); | 56 PathService::Get(chrome::DIR_TEST_DATA, &path); |
54 path = path.AppendASCII("extensions") | 57 path = path.AppendASCII("extensions") |
55 .AppendASCII("install_prompt") | 58 .AppendASCII("install_prompt") |
56 .AppendASCII("icon.png"); | 59 .AppendASCII("icon.png"); |
57 | 60 |
58 std::string file_contents; | 61 std::string file_contents; |
59 base::ReadFileToString(path, &file_contents); | 62 base::ReadFileToString(path, &file_contents); |
60 | 63 |
61 return gfx::Image::CreateFrom1xPNGBytes( | 64 return gfx::Image::CreateFrom1xPNGBytes( |
(...skipping 15 matching lines...) Expand all Loading... |
77 BuildExtensionPostInstallPermissionsPrompt(Extension* extension) { | 80 BuildExtensionPostInstallPermissionsPrompt(Extension* extension) { |
78 std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt( | 81 std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt( |
79 new ExtensionInstallPrompt::Prompt( | 82 new ExtensionInstallPrompt::Prompt( |
80 ExtensionInstallPrompt::POST_INSTALL_PERMISSIONS_PROMPT)); | 83 ExtensionInstallPrompt::POST_INSTALL_PERMISSIONS_PROMPT)); |
81 prompt->set_extension(extension); | 84 prompt->set_extension(extension); |
82 prompt->set_icon(LoadInstallPromptIcon()); | 85 prompt->set_icon(LoadInstallPromptIcon()); |
83 return prompt; | 86 return prompt; |
84 } | 87 } |
85 | 88 |
86 } // namespace chrome | 89 } // namespace chrome |
OLD | NEW |