| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 scoped_refptr<Extension> extension; | 21 scoped_refptr<Extension> extension; |
| 22 | 22 |
| 23 base::FilePath path; | 23 base::FilePath path; |
| 24 PathService::Get(chrome::DIR_TEST_DATA, &path); | 24 PathService::Get(chrome::DIR_TEST_DATA, &path); |
| 25 path = path.AppendASCII("extensions") | 25 path = path.AppendASCII("extensions") |
| 26 .AppendASCII(extension_dir_name) | 26 .AppendASCII(extension_dir_name) |
| 27 .AppendASCII(manifest_file); | 27 .AppendASCII(manifest_file); |
| 28 | 28 |
| 29 std::string error; | 29 std::string error; |
| 30 JSONFileValueDeserializer deserializer(path); | 30 JSONFileValueDeserializer deserializer(path); |
| 31 scoped_ptr<base::DictionaryValue> value = | 31 std::unique_ptr<base::DictionaryValue> value = |
| 32 base::DictionaryValue::From(deserializer.Deserialize(NULL, &error)); | 32 base::DictionaryValue::From(deserializer.Deserialize(NULL, &error)); |
| 33 if (!value.get()) { | 33 if (!value.get()) { |
| 34 LOG(ERROR) << error; | 34 LOG(ERROR) << error; |
| 35 return extension; | 35 return extension; |
| 36 } | 36 } |
| 37 | 37 |
| 38 extension = Extension::Create( | 38 extension = Extension::Create( |
| 39 path.DirName(), extensions::Manifest::INVALID_LOCATION, *value, | 39 path.DirName(), extensions::Manifest::INVALID_LOCATION, *value, |
| 40 Extension::NO_FLAGS, &error); | 40 Extension::NO_FLAGS, &error); |
| 41 if (!extension.get()) | 41 if (!extension.get()) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 56 .AppendASCII("icon.png"); | 56 .AppendASCII("icon.png"); |
| 57 | 57 |
| 58 std::string file_contents; | 58 std::string file_contents; |
| 59 base::ReadFileToString(path, &file_contents); | 59 base::ReadFileToString(path, &file_contents); |
| 60 | 60 |
| 61 return gfx::Image::CreateFrom1xPNGBytes( | 61 return gfx::Image::CreateFrom1xPNGBytes( |
| 62 reinterpret_cast<const unsigned char*>(file_contents.c_str()), | 62 reinterpret_cast<const unsigned char*>(file_contents.c_str()), |
| 63 file_contents.length()); | 63 file_contents.length()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 scoped_ptr<ExtensionInstallPrompt::Prompt> BuildExtensionInstallPrompt( | 66 std::unique_ptr<ExtensionInstallPrompt::Prompt> BuildExtensionInstallPrompt( |
| 67 Extension* extension) { | 67 Extension* extension) { |
| 68 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt( | 68 std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt( |
| 69 new ExtensionInstallPrompt::Prompt( | 69 new ExtensionInstallPrompt::Prompt( |
| 70 ExtensionInstallPrompt::INSTALL_PROMPT)); | 70 ExtensionInstallPrompt::INSTALL_PROMPT)); |
| 71 prompt->set_extension(extension); | 71 prompt->set_extension(extension); |
| 72 prompt->set_icon(LoadInstallPromptIcon()); | 72 prompt->set_icon(LoadInstallPromptIcon()); |
| 73 return prompt; | 73 return prompt; |
| 74 } | 74 } |
| 75 | 75 |
| 76 scoped_ptr<ExtensionInstallPrompt::Prompt> | 76 std::unique_ptr<ExtensionInstallPrompt::Prompt> |
| 77 BuildExtensionPostInstallPermissionsPrompt(Extension* extension) { | 77 BuildExtensionPostInstallPermissionsPrompt(Extension* extension) { |
| 78 scoped_ptr<ExtensionInstallPrompt::Prompt> prompt( | 78 std::unique_ptr<ExtensionInstallPrompt::Prompt> prompt( |
| 79 new ExtensionInstallPrompt::Prompt( | 79 new ExtensionInstallPrompt::Prompt( |
| 80 ExtensionInstallPrompt::POST_INSTALL_PERMISSIONS_PROMPT)); | 80 ExtensionInstallPrompt::POST_INSTALL_PERMISSIONS_PROMPT)); |
| 81 prompt->set_extension(extension); | 81 prompt->set_extension(extension); |
| 82 prompt->set_icon(LoadInstallPromptIcon()); | 82 prompt->set_icon(LoadInstallPromptIcon()); |
| 83 return prompt; | 83 return prompt; |
| 84 } | 84 } |
| 85 | 85 |
| 86 } // namespace chrome | 86 } // namespace chrome |
| OLD | NEW |