cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / extensions / shell / common / shell_content_client.cc
blob946fe838192cfc3795c5138079f4c6ffbc5266a7
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "extensions/shell/common/shell_content_client.h"
7 #include "base/strings/string_piece.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "content/public/common/user_agent.h"
10 #include "extensions/common/constants.h"
11 #include "extensions/shell/common/version.h" // Generated file.
12 #include "ui/base/l10n/l10n_util.h"
13 #include "ui/base/resource/resource_bundle.h"
15 #if !defined(DISABLE_NACL)
16 #include "base/base_paths.h"
17 #include "base/files/file_path.h"
18 #include "base/path_service.h"
19 #include "components/nacl/common/nacl_constants.h"
20 #include "components/nacl/renderer/plugin/ppapi_entrypoints.h"
21 #include "content/public/common/pepper_plugin_info.h"
22 #include "ppapi/shared_impl/ppapi_permissions.h"
23 #endif
25 namespace extensions {
26 namespace {
28 #if !defined(DISABLE_NACL)
29 bool GetNaClPluginPath(base::FilePath* path) {
30 // On Posix, plugins live in the module directory.
31 base::FilePath module;
32 if (!PathService::Get(base::DIR_MODULE, &module))
33 return false;
34 *path = module.Append(nacl::kInternalNaClPluginFileName);
35 return true;
37 #endif // !defined(DISABLE_NACL)
39 } // namespace
41 ShellContentClient::ShellContentClient() {
44 ShellContentClient::~ShellContentClient() {
47 void ShellContentClient::AddPepperPlugins(
48 std::vector<content::PepperPluginInfo>* plugins) {
49 #if !defined(DISABLE_NACL)
50 base::FilePath path;
51 if (!GetNaClPluginPath(&path))
52 return;
54 content::PepperPluginInfo nacl;
55 // The nacl plugin is now built into the binary.
56 nacl.is_internal = true;
57 nacl.path = path;
58 nacl.name = nacl::kNaClPluginName;
59 content::WebPluginMimeType nacl_mime_type(nacl::kNaClPluginMimeType,
60 nacl::kNaClPluginExtension,
61 nacl::kNaClPluginDescription);
62 nacl.mime_types.push_back(nacl_mime_type);
63 content::WebPluginMimeType pnacl_mime_type(nacl::kPnaclPluginMimeType,
64 nacl::kPnaclPluginExtension,
65 nacl::kPnaclPluginDescription);
66 nacl.mime_types.push_back(pnacl_mime_type);
67 nacl.internal_entry_points.get_interface = nacl_plugin::PPP_GetInterface;
68 nacl.internal_entry_points.initialize_module =
69 nacl_plugin::PPP_InitializeModule;
70 nacl.internal_entry_points.shutdown_module =
71 nacl_plugin::PPP_ShutdownModule;
72 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
73 plugins->push_back(nacl);
74 #endif // !defined(DISABLE_NACL)
77 static const int kNumShellStandardURLSchemes = 2;
78 static const url::SchemeWithType kShellStandardURLSchemes[
79 kNumShellStandardURLSchemes] = {
80 {extensions::kExtensionScheme, url::SCHEME_WITHOUT_PORT},
81 {extensions::kExtensionResourceScheme, url::SCHEME_WITHOUT_PORT},
84 void ShellContentClient::AddAdditionalSchemes(
85 std::vector<url::SchemeWithType>* standard_schemes,
86 std::vector<std::string>* savable_schemes) {
87 for (int i = 0; i < kNumShellStandardURLSchemes; i++)
88 standard_schemes->push_back(kShellStandardURLSchemes[i]);
90 savable_schemes->push_back(kExtensionScheme);
91 savable_schemes->push_back(kExtensionResourceScheme);
94 std::string ShellContentClient::GetUserAgent() const {
95 // Must contain a user agent string for version sniffing. For example,
96 // pluginless WebRTC Hangouts checks the Chrome version number.
97 return content::BuildUserAgentFromProduct("Chrome/" PRODUCT_VERSION);
100 base::string16 ShellContentClient::GetLocalizedString(int message_id) const {
101 return l10n_util::GetStringUTF16(message_id);
104 base::StringPiece ShellContentClient::GetDataResource(
105 int resource_id,
106 ui::ScaleFactor scale_factor) const {
107 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
108 resource_id, scale_factor);
111 base::RefCountedStaticMemory* ShellContentClient::GetDataResourceBytes(
112 int resource_id) const {
113 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id);
116 gfx::Image& ShellContentClient::GetNativeImageNamed(int resource_id) const {
117 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
120 } // namespace extensions