| 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/browser/component_updater/pepper_flash_field_trial.h" | 25 #include "chrome/common/pepper_flash.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" | |
| 30 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
| 31 #include "content/public/browser/plugin_service.h" | 30 #include "content/public/browser/plugin_service.h" |
| 32 #include "content/public/common/pepper_plugin_info.h" | 31 #include "content/public/common/pepper_plugin_info.h" |
| 33 #include "ppapi/c/private/ppb_pdf.h" | 32 #include "ppapi/c/private/ppb_pdf.h" |
| 34 #include "webkit/plugins/plugin_constants.h" | 33 #include "webkit/plugins/plugin_constants.h" |
| 35 #include "webkit/plugins/ppapi/plugin_module.h" | 34 #include "webkit/plugins/ppapi/plugin_module.h" |
| 36 | 35 |
| 37 #if defined(OS_WIN) | 36 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 38 #include "base/win/metro.h" | |
| 39 #endif | |
| 40 | 37 |
| 41 using content::BrowserThread; | 38 using content::BrowserThread; |
| 42 using content::PluginService; | 39 using content::PluginService; |
| 43 | 40 |
| 44 namespace { | 41 namespace { |
| 45 | 42 |
| 46 // CRX hash. The extension id is: mimojjlkmoijpicakmndhoigimigcmbb. | 43 // CRX hash. The extension id is: mimojjlkmoijpicakmndhoigimigcmbb. |
| 47 const uint8 sha2_hash[] = {0xc8, 0xce, 0x99, 0xba, 0xce, 0x89, 0xf8, 0x20, | 44 const uint8 sha2_hash[] = {0xc8, 0xce, 0x99, 0xba, 0xce, 0x89, 0xf8, 0x20, |
| 48 0xac, 0xd3, 0x7e, 0x86, 0x8c, 0x86, 0x2c, 0x11, | 45 0xac, 0xd3, 0x7e, 0x86, 0x8c, 0x86, 0x2c, 0x11, |
| 49 0xb9, 0x40, 0xc5, 0x55, 0xaf, 0x08, 0x63, 0x70, | 46 0xb9, 0x40, 0xc5, 0x55, 0xaf, 0x08, 0x63, 0x70, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 72 "???"; | 69 "???"; |
| 73 #endif | 70 #endif |
| 74 | 71 |
| 75 // The Pepper Flash plugins are in a directory with this name. | 72 // The Pepper Flash plugins are in a directory with this name. |
| 76 const FilePath::CharType kPepperFlashBaseDirectory[] = | 73 const FilePath::CharType kPepperFlashBaseDirectory[] = |
| 77 FILE_PATH_LITERAL("PepperFlash"); | 74 FILE_PATH_LITERAL("PepperFlash"); |
| 78 | 75 |
| 79 // If we don't have a Pepper Flash component, this is the version we claim. | 76 // If we don't have a Pepper Flash component, this is the version we claim. |
| 80 const char kNullVersion[] = "0.0.0.0"; | 77 const char kNullVersion[] = "0.0.0.0"; |
| 81 | 78 |
| 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 | |
| 105 // The base directory on Windows looks like: | 79 // The base directory on Windows looks like: |
| 106 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\. | 80 // <profile>\AppData\Local\Google\Chrome\User Data\PepperFlash\. |
| 107 FilePath GetPepperFlashBaseDirectory() { | 81 FilePath GetPepperFlashBaseDirectory() { |
| 108 FilePath result; | 82 FilePath result; |
| 109 PathService::Get(chrome::DIR_USER_DATA, &result); | 83 PathService::Get(chrome::DIR_USER_DATA, &result); |
| 110 return result.Append(kPepperFlashBaseDirectory); | 84 return result.Append(kPepperFlashBaseDirectory); |
| 111 } | 85 } |
| 112 | 86 |
| 113 // Pepper Flash plugins have the version encoded in the path itself | 87 // Pepper Flash plugins have the version encoded in the path itself |
| 114 // so we need to enumerate the directories to find the full path. | 88 // 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... |
| 379 // Remove older versions of Pepper Flash. | 353 // Remove older versions of Pepper Flash. |
| 380 for (std::vector<FilePath>::iterator iter = older_dirs.begin(); | 354 for (std::vector<FilePath>::iterator iter = older_dirs.begin(); |
| 381 iter != older_dirs.end(); ++iter) { | 355 iter != older_dirs.end(); ++iter) { |
| 382 file_util::Delete(*iter, true); | 356 file_util::Delete(*iter, true); |
| 383 } | 357 } |
| 384 } | 358 } |
| 385 | 359 |
| 386 } // namespace | 360 } // namespace |
| 387 | 361 |
| 388 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { | 362 void RegisterPepperFlashComponent(ComponentUpdateService* cus) { |
| 389 #if defined(GOOGLE_CHROME_BUILD) | 363 #if defined(GOOGLE_CHROME_BUILD) && !defined(FLAPPER_AVAILABLE) |
| 390 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 364 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 391 base::Bind(&StartPepperFlashUpdateRegistration, cus)); | 365 base::Bind(&StartPepperFlashUpdateRegistration, cus)); |
| 392 #endif | 366 #endif |
| 393 } | 367 } |
| OLD | NEW |