OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/component_updater/flash_component_installer.h" | 5 #include "chrome/browser/component_updater/flash_component_installer.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "base/version.h" | 19 #include "base/version.h" |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
21 #include "chrome/browser/component_updater/component_updater_service.h" | 21 #include "chrome/browser/component_updater/component_updater_service.h" |
22 #include "chrome/browser/plugin_prefs.h" | 22 #include "chrome/browser/plugin_prefs.h" |
23 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
24 #include "chrome/installer/util/browser_distribution.h" | |
24 #include "content/browser/plugin_service.h" | 25 #include "content/browser/plugin_service.h" |
25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/common/pepper_plugin_info.h" | 27 #include "content/public/common/pepper_plugin_info.h" |
27 #include "ppapi/c/private/ppb_pdf.h" | 28 #include "ppapi/c/private/ppb_pdf.h" |
28 #include "webkit/plugins/plugin_constants.h" | 29 #include "webkit/plugins/plugin_constants.h" |
29 #include "webkit/plugins/ppapi/plugin_module.h" | 30 #include "webkit/plugins/ppapi/plugin_module.h" |
30 | 31 |
31 using content::BrowserThread; | 32 using content::BrowserThread; |
32 | 33 |
33 namespace { | 34 namespace { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 "???"; | 72 "???"; |
72 #endif | 73 #endif |
73 | 74 |
74 // The Pepper Flash plugins are in a directory with this name. | 75 // The Pepper Flash plugins are in a directory with this name. |
75 const FilePath::CharType kPepperFlashBaseDirectory[] = | 76 const FilePath::CharType kPepperFlashBaseDirectory[] = |
76 FILE_PATH_LITERAL("PepperFlash"); | 77 FILE_PATH_LITERAL("PepperFlash"); |
77 | 78 |
78 // If we don't have a Pepper Flash component, this is the version we claim. | 79 // If we don't have a Pepper Flash component, this is the version we claim. |
79 const char kNullVersion[] = "0.0.0.0"; | 80 const char kNullVersion[] = "0.0.0.0"; |
80 | 81 |
81 // True if Pepper Flash should be enabled by default. | 82 // True if Pepper Flash should be enabled by default. Aura builds for any OS |
83 // and Windows canary have it enabled by default. | |
84 bool IsPepperFlashEnabledByDefault() { | |
82 #if defined(USE_AURA) | 85 #if defined(USE_AURA) |
83 const bool kEnablePepperFlash = true; | 86 return true; |
87 #elif !defined(OS_WIN) | |
88 return false; | |
84 #else | 89 #else |
85 const bool kEnablePepperFlash = false; | 90 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
91 if (!dist) | |
92 return false; | |
93 std::wstring channel; | |
brettw
2011/12/06 01:34:48
Can you use string16 for new code?
| |
94 if (!dist->GetChromeChannel(&channel)) | |
95 return false; | |
96 return (channel == L"canary"); | |
86 #endif | 97 #endif |
98 } | |
87 | 99 |
88 // The base directory on Windows looks like: | 100 // The base directory on Windows looks like: |
89 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\. | 101 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\. |
90 FilePath GetPepperFlashBaseDirectory() { | 102 FilePath GetPepperFlashBaseDirectory() { |
91 FilePath result; | 103 FilePath result; |
92 PathService::Get(chrome::DIR_USER_DATA, &result); | 104 PathService::Get(chrome::DIR_USER_DATA, &result); |
93 return result.Append(kPepperFlashBaseDirectory); | 105 return result.Append(kPepperFlashBaseDirectory); |
94 } | 106 } |
95 | 107 |
96 // Pepper Flash plugins have the version encoded in the path itself | 108 // Pepper Flash plugins have the version encoded in the path itself |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 kFlashPluginSwfExtension, | 165 kFlashPluginSwfExtension, |
154 kFlashPluginName); | 166 kFlashPluginName); |
155 plugin_info->mime_types.push_back(swf_mime_type); | 167 plugin_info->mime_types.push_back(swf_mime_type); |
156 webkit::WebPluginMimeType spl_mime_type(kFlashPluginSplMimeType, | 168 webkit::WebPluginMimeType spl_mime_type(kFlashPluginSplMimeType, |
157 kFlashPluginSplExtension, | 169 kFlashPluginSplExtension, |
158 kFlashPluginName); | 170 kFlashPluginName); |
159 plugin_info->mime_types.push_back(spl_mime_type); | 171 plugin_info->mime_types.push_back(spl_mime_type); |
160 return true; | 172 return true; |
161 } | 173 } |
162 | 174 |
175 // If it is a |fresh_install| we enable or disable it by default in some | |
176 // configurations. See IsPepperFlashEnabledByDefault() for more information. | |
163 void RegisterPepperFlashWithChrome(const FilePath& path, | 177 void RegisterPepperFlashWithChrome(const FilePath& path, |
164 const Version& version) { | 178 const Version& version, |
179 bool fresh_install) { | |
165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
166 content::PepperPluginInfo plugin_info; | 181 content::PepperPluginInfo plugin_info; |
167 // Register it as out-of-process and disabled. | |
168 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) | 182 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) |
169 return; | 183 return; |
170 PluginPrefs::EnablePluginGlobally(kEnablePepperFlash, plugin_info.path); | 184 if (fresh_install) |
brettw
2011/12/06 01:34:48
Need {}
| |
185 PluginPrefs::EnablePluginGlobally(IsPepperFlashEnabledByDefault(), | |
186 plugin_info.path); | |
171 PluginService::GetInstance()->RegisterInternalPlugin( | 187 PluginService::GetInstance()->RegisterInternalPlugin( |
172 plugin_info.ToWebPluginInfo()); | 188 plugin_info.ToWebPluginInfo()); |
173 PluginService::GetInstance()->RefreshPlugins(); | 189 PluginService::GetInstance()->RefreshPlugins(); |
174 } | 190 } |
175 | 191 |
176 } // namespace | 192 } // namespace |
177 | 193 |
178 class PepperFlashComponentInstaller : public ComponentInstaller { | 194 class PepperFlashComponentInstaller : public ComponentInstaller { |
179 public: | 195 public: |
180 explicit PepperFlashComponentInstaller(const Version& version); | 196 explicit PepperFlashComponentInstaller(const Version& version); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 return false; | 231 return false; |
216 if (!file_util::Move(unpack_path, path)) | 232 if (!file_util::Move(unpack_path, path)) |
217 return false; | 233 return false; |
218 // Installation is done. Now tell the rest of chrome. Both the path service | 234 // Installation is done. Now tell the rest of chrome. Both the path service |
219 // and to the plugin service. | 235 // and to the plugin service. |
220 current_version_ = version; | 236 current_version_ = version; |
221 path = path.Append(kPepperFlashPluginFileName); | 237 path = path.Append(kPepperFlashPluginFileName); |
222 PathService::Override(chrome::FILE_PEPPER_FLASH_PLUGIN, path); | 238 PathService::Override(chrome::FILE_PEPPER_FLASH_PLUGIN, path); |
223 BrowserThread::PostTask( | 239 BrowserThread::PostTask( |
224 BrowserThread::UI, FROM_HERE, | 240 BrowserThread::UI, FROM_HERE, |
225 base::Bind(&RegisterPepperFlashWithChrome, path, version)); | 241 base::Bind(&RegisterPepperFlashWithChrome, path, version, true)); |
226 return true; | 242 return true; |
227 } | 243 } |
228 | 244 |
229 bool VetoPepperFlashIntefaces(base::DictionaryValue* manifest) { | 245 bool VetoPepperFlashIntefaces(base::DictionaryValue* manifest) { |
230 // Check that we implement the required interfaces. | 246 // Check that we implement the required interfaces. |
231 base::ListValue* interfaces = NULL; | 247 base::ListValue* interfaces = NULL; |
232 if (manifest->GetList("x-ppapi-required-interfaces", &interfaces)) { | 248 if (manifest->GetList("x-ppapi-required-interfaces", &interfaces)) { |
233 for (size_t ix = 0; ix != interfaces->GetSize(); ++ix) { | 249 for (size_t ix = 0; ix != interfaces->GetSize(); ++ix) { |
234 std::string interface_name; | 250 std::string interface_name; |
235 if (!interfaces->GetString(ix, &interface_name)) | 251 if (!interfaces->GetString(ix, &interface_name)) |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 return; | 320 return; |
305 } | 321 } |
306 } | 322 } |
307 | 323 |
308 Version version(kNullVersion); | 324 Version version(kNullVersion); |
309 if (GetLatestPepperFlashDirectory(&path, &version)) { | 325 if (GetLatestPepperFlashDirectory(&path, &version)) { |
310 path = path.Append(kPepperFlashPluginFileName); | 326 path = path.Append(kPepperFlashPluginFileName); |
311 if (file_util::PathExists(path)) { | 327 if (file_util::PathExists(path)) { |
312 BrowserThread::PostTask( | 328 BrowserThread::PostTask( |
313 BrowserThread::UI, FROM_HERE, | 329 BrowserThread::UI, FROM_HERE, |
314 base::Bind(&RegisterPepperFlashWithChrome, path, version)); | 330 base::Bind(&RegisterPepperFlashWithChrome, path, version, false)); |
315 } else { | 331 } else { |
316 version = Version(kNullVersion); | 332 version = Version(kNullVersion); |
317 } | 333 } |
318 } | 334 } |
319 | 335 |
320 BrowserThread::PostTask( | 336 BrowserThread::PostTask( |
321 BrowserThread::UI, FROM_HERE, | 337 BrowserThread::UI, FROM_HERE, |
322 base::Bind(&FinishPepperFlashUpdateRegistration, cus, version)); | 338 base::Bind(&FinishPepperFlashUpdateRegistration, cus, version)); |
323 } | 339 } |
324 | 340 |
325 } // namespace | 341 } // namespace |
326 | 342 |
327 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { | 343 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { |
328 // #if defined(GOOGLE_CHROME_BUILD) | 344 #if defined(GOOGLE_CHROME_BUILD) |
329 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 345 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
330 base::Bind(&StartPepperFlashUpdateRegistration, cus)); | 346 base::Bind(&StartPepperFlashUpdateRegistration, cus)); |
331 // #endif | 347 #endif |
332 } | 348 } |
OLD | NEW |