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

Side by Side Diff: chrome/browser/component_updater/pepper_flash_component_installer.cc

Issue 8806034: Enable pepper flash by default in windows canary (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 string16 channel;
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
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) {
185 PluginPrefs::EnablePluginGlobally(IsPepperFlashEnabledByDefault(),
186 plugin_info.path);
187 }
171 PluginService::GetInstance()->RegisterInternalPlugin( 188 PluginService::GetInstance()->RegisterInternalPlugin(
172 plugin_info.ToWebPluginInfo()); 189 plugin_info.ToWebPluginInfo());
173 PluginService::GetInstance()->RefreshPlugins(); 190 PluginService::GetInstance()->RefreshPlugins();
174 } 191 }
175 192
176 } // namespace 193 } // namespace
177 194
178 class PepperFlashComponentInstaller : public ComponentInstaller { 195 class PepperFlashComponentInstaller : public ComponentInstaller {
179 public: 196 public:
180 explicit PepperFlashComponentInstaller(const Version& version); 197 explicit PepperFlashComponentInstaller(const Version& version);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 return false; 232 return false;
216 if (!file_util::Move(unpack_path, path)) 233 if (!file_util::Move(unpack_path, path))
217 return false; 234 return false;
218 // Installation is done. Now tell the rest of chrome. Both the path service 235 // Installation is done. Now tell the rest of chrome. Both the path service
219 // and to the plugin service. 236 // and to the plugin service.
220 current_version_ = version; 237 current_version_ = version;
221 path = path.Append(kPepperFlashPluginFileName); 238 path = path.Append(kPepperFlashPluginFileName);
222 PathService::Override(chrome::FILE_PEPPER_FLASH_PLUGIN, path); 239 PathService::Override(chrome::FILE_PEPPER_FLASH_PLUGIN, path);
223 BrowserThread::PostTask( 240 BrowserThread::PostTask(
224 BrowserThread::UI, FROM_HERE, 241 BrowserThread::UI, FROM_HERE,
225 base::Bind(&RegisterPepperFlashWithChrome, path, version)); 242 base::Bind(&RegisterPepperFlashWithChrome, path, version, true));
226 return true; 243 return true;
227 } 244 }
228 245
229 bool VetoPepperFlashIntefaces(base::DictionaryValue* manifest) { 246 bool VetoPepperFlashIntefaces(base::DictionaryValue* manifest) {
230 // Check that we implement the required interfaces. 247 // Check that we implement the required interfaces.
231 base::ListValue* interfaces = NULL; 248 base::ListValue* interfaces = NULL;
232 if (manifest->GetList("x-ppapi-required-interfaces", &interfaces)) { 249 if (manifest->GetList("x-ppapi-required-interfaces", &interfaces)) {
233 for (size_t ix = 0; ix != interfaces->GetSize(); ++ix) { 250 for (size_t ix = 0; ix != interfaces->GetSize(); ++ix) {
234 std::string interface_name; 251 std::string interface_name;
235 if (!interfaces->GetString(ix, &interface_name)) 252 if (!interfaces->GetString(ix, &interface_name))
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 return; 321 return;
305 } 322 }
306 } 323 }
307 324
308 Version version(kNullVersion); 325 Version version(kNullVersion);
309 if (GetLatestPepperFlashDirectory(&path, &version)) { 326 if (GetLatestPepperFlashDirectory(&path, &version)) {
310 path = path.Append(kPepperFlashPluginFileName); 327 path = path.Append(kPepperFlashPluginFileName);
311 if (file_util::PathExists(path)) { 328 if (file_util::PathExists(path)) {
312 BrowserThread::PostTask( 329 BrowserThread::PostTask(
313 BrowserThread::UI, FROM_HERE, 330 BrowserThread::UI, FROM_HERE,
314 base::Bind(&RegisterPepperFlashWithChrome, path, version)); 331 base::Bind(&RegisterPepperFlashWithChrome, path, version, false));
315 } else { 332 } else {
316 version = Version(kNullVersion); 333 version = Version(kNullVersion);
317 } 334 }
318 } 335 }
319 336
320 BrowserThread::PostTask( 337 BrowserThread::PostTask(
321 BrowserThread::UI, FROM_HERE, 338 BrowserThread::UI, FROM_HERE,
322 base::Bind(&FinishPepperFlashUpdateRegistration, cus, version)); 339 base::Bind(&FinishPepperFlashUpdateRegistration, cus, version));
323 } 340 }
324 341
325 } // namespace 342 } // namespace
326 343
327 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { 344 void RegisterPepperFlashComponent(ComponentUpdateService* cus) {
328 // #if defined(GOOGLE_CHROME_BUILD) 345 #if defined(GOOGLE_CHROME_BUILD)
329 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 346 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
330 base::Bind(&StartPepperFlashUpdateRegistration, cus)); 347 base::Bind(&StartPepperFlashUpdateRegistration, cus));
331 // #endif 348 #endif
332 } 349 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698