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 #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 <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/base_paths.h" | 11 #include "base/base_paths.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/string_split.h" | 18 #include "base/string_split.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "base/stringprintf.h" | 20 #include "base/stringprintf.h" |
21 #include "base/values.h" | 21 #include "base/values.h" |
22 #include "base/version.h" | 22 #include "base/version.h" |
23 #include "build/build_config.h" | 23 #include "build/build_config.h" |
24 #include "chrome/browser/component_updater/component_updater_service.h" | 24 #include "chrome/browser/component_updater/component_updater_service.h" |
25 #include "chrome/common/pepper_flash.h" | 25 #include "chrome/browser/component_updater/pepper_flash_field_trial.h" |
26 #include "chrome/browser/plugin_prefs.h" | 26 #include "chrome/browser/plugin_prefs.h" |
27 #include "chrome/common/chrome_constants.h" | 27 #include "chrome/common/chrome_constants.h" |
28 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
| 29 #include "chrome/installer/util/browser_distribution.h" |
29 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
30 #include "content/public/browser/plugin_service.h" | 31 #include "content/public/browser/plugin_service.h" |
31 #include "content/public/common/pepper_plugin_info.h" | 32 #include "content/public/common/pepper_plugin_info.h" |
32 #include "ppapi/c/private/ppb_pdf.h" | 33 #include "ppapi/c/private/ppb_pdf.h" |
33 #include "webkit/plugins/plugin_constants.h" | 34 #include "webkit/plugins/plugin_constants.h" |
34 #include "webkit/plugins/ppapi/plugin_module.h" | 35 #include "webkit/plugins/ppapi/plugin_module.h" |
35 | 36 |
36 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR. | 37 #if defined(OS_WIN) |
| 38 #include "base/win/metro.h" |
| 39 #endif |
37 | 40 |
38 using content::BrowserThread; | 41 using content::BrowserThread; |
39 using content::PluginService; | 42 using content::PluginService; |
40 | 43 |
41 namespace { | 44 namespace { |
42 | 45 |
43 // CRX hash. The extension id is: mimojjlkmoijpicakmndhoigimigcmbb. | 46 // CRX hash. The extension id is: mimojjlkmoijpicakmndhoigimigcmbb. |
44 const uint8 sha2_hash[] = {0xc8, 0xce, 0x99, 0xba, 0xce, 0x89, 0xf8, 0x20, | 47 const uint8 sha2_hash[] = {0xc8, 0xce, 0x99, 0xba, 0xce, 0x89, 0xf8, 0x20, |
45 0xac, 0xd3, 0x7e, 0x86, 0x8c, 0x86, 0x2c, 0x11, | 48 0xac, 0xd3, 0x7e, 0x86, 0x8c, 0x86, 0x2c, 0x11, |
46 0xb9, 0x40, 0xc5, 0x55, 0xaf, 0x08, 0x63, 0x70, | 49 0xb9, 0x40, 0xc5, 0x55, 0xaf, 0x08, 0x63, 0x70, |
(...skipping 22 matching lines...) Expand all Loading... |
69 "???"; | 72 "???"; |
70 #endif | 73 #endif |
71 | 74 |
72 // The Pepper Flash plugins are in a directory with this name. | 75 // The Pepper Flash plugins are in a directory with this name. |
73 const FilePath::CharType kPepperFlashBaseDirectory[] = | 76 const FilePath::CharType kPepperFlashBaseDirectory[] = |
74 FILE_PATH_LITERAL("PepperFlash"); | 77 FILE_PATH_LITERAL("PepperFlash"); |
75 | 78 |
76 // 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. |
77 const char kNullVersion[] = "0.0.0.0"; | 80 const char kNullVersion[] = "0.0.0.0"; |
78 | 81 |
| 82 // True if Pepper Flash should be enabled by default. Aura builds for any OS |
| 83 // Windows 8 metro mode and part of Windows canary have it enabled by default. |
| 84 bool IsPepperFlashEnabledByDefault() { |
| 85 #if defined(USE_AURA) |
| 86 return true; |
| 87 #elif !defined(OS_WIN) |
| 88 return false; |
| 89 #else |
| 90 if (base::win::GetMetroModule()) |
| 91 return true; |
| 92 if (!PepperFlashFieldTrial::InEnableByDefaultGroup()) |
| 93 return false; |
| 94 |
| 95 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 96 if (!dist) |
| 97 return false; |
| 98 string16 channel; |
| 99 if (!dist->GetChromeChannel(&channel)) |
| 100 return false; |
| 101 return (channel == L"canary"); |
| 102 #endif |
| 103 } |
| 104 |
79 // The base directory on Windows looks like: | 105 // The base directory on Windows looks like: |
80 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\. | 106 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\. |
81 FilePath GetPepperFlashBaseDirectory() { | 107 FilePath GetPepperFlashBaseDirectory() { |
82 FilePath result; | 108 FilePath result; |
83 PathService::Get(chrome::DIR_USER_DATA, &result); | 109 PathService::Get(chrome::DIR_USER_DATA, &result); |
84 return result.Append(kPepperFlashBaseDirectory); | 110 return result.Append(kPepperFlashBaseDirectory); |
85 } | 111 } |
86 | 112 |
87 // Pepper Flash plugins have the version encoded in the path itself | 113 // Pepper Flash plugins have the version encoded in the path itself |
88 // so we need to enumerate the directories to find the full path. | 114 // so we need to enumerate the directories to find the full path. |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // Remove older versions of Pepper Flash. | 379 // Remove older versions of Pepper Flash. |
354 for (std::vector<FilePath>::iterator iter = older_dirs.begin(); | 380 for (std::vector<FilePath>::iterator iter = older_dirs.begin(); |
355 iter != older_dirs.end(); ++iter) { | 381 iter != older_dirs.end(); ++iter) { |
356 file_util::Delete(*iter, true); | 382 file_util::Delete(*iter, true); |
357 } | 383 } |
358 } | 384 } |
359 | 385 |
360 } // namespace | 386 } // namespace |
361 | 387 |
362 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { | 388 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { |
363 #if defined(GOOGLE_CHROME_BUILD) && !defined(FLAPPER_AVAILABLE) | 389 #if defined(GOOGLE_CHROME_BUILD) |
364 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 390 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
365 base::Bind(&StartPepperFlashUpdateRegistration, cus)); | 391 base::Bind(&StartPepperFlashUpdateRegistration, cus)); |
366 #endif | 392 #endif |
367 } | 393 } |
OLD | NEW |