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

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

Issue 2130803003: Rearrange Flash component registration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Keep using chrome_content_client to load bundled Flash Created 4 years, 5 months 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
« no previous file with comments | « no previous file | chrome/common/chrome_content_client.cc » ('j') | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/pepper_flash_component_installer.h" 5 #include "chrome/browser/component_updater/pepper_flash_component_installer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 99
100 bool IsPepperFlash(const content::WebPluginInfo& plugin) { 100 bool IsPepperFlash(const content::WebPluginInfo& plugin) {
101 // We try to recognize Pepper Flash by the following criteria: 101 // We try to recognize Pepper Flash by the following criteria:
102 // * It is a Pepper plugin. 102 // * It is a Pepper plugin.
103 // * It has the special Flash permissions. 103 // * It has the special Flash permissions.
104 return plugin.is_pepper_plugin() && 104 return plugin.is_pepper_plugin() &&
105 (plugin.pepper_permissions & ppapi::PERMISSION_FLASH); 105 (plugin.pepper_permissions & ppapi::PERMISSION_FLASH);
106 } 106 }
107 107
108 // |path| is the path to the latest Chrome-managed Flash installation (bundled
109 // or component updated).
110 // |version| is the version of that Flash implementation.
108 void RegisterPepperFlashWithChrome(const base::FilePath& path, 111 void RegisterPepperFlashWithChrome(const base::FilePath& path,
109 const Version& version) { 112 const Version& version) {
110 DCHECK_CURRENTLY_ON(BrowserThread::UI); 113 DCHECK_CURRENTLY_ON(BrowserThread::UI);
111 content::PepperPluginInfo plugin_info; 114 content::PepperPluginInfo plugin_info;
112 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info)) 115 if (!MakePepperFlashPluginInfo(path, version, true, &plugin_info))
113 return; 116 return;
114 117
115 base::FilePath bundled_flash_dir;
116 PathService::Get(chrome::DIR_PEPPER_FLASH_PLUGIN, &bundled_flash_dir);
117 base::FilePath system_flash_path; 118 base::FilePath system_flash_path;
118 PathService::Get(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN, &system_flash_path); 119 PathService::Get(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN, &system_flash_path);
119 120
120 std::vector<content::WebPluginInfo> plugins; 121 std::vector<content::WebPluginInfo> plugins;
121 PluginService::GetInstance()->GetInternalPlugins(&plugins); 122 PluginService::GetInstance()->GetInternalPlugins(&plugins);
122 for (const auto& plugin : plugins) { 123 for (const auto& plugin : plugins) {
123 if (!IsPepperFlash(plugin)) 124 if (!IsPepperFlash(plugin))
124 continue; 125 continue;
125 126
126 Version registered_version(base::UTF16ToUTF8(plugin.version)); 127 Version registered_version(base::UTF16ToUTF8(plugin.version));
127 128
128 // If lower version, never register. 129 // If lower version, never register.
129 if (registered_version.IsValid() && 130 if (registered_version.IsValid() &&
130 version.CompareTo(registered_version) < 0) { 131 version.CompareTo(registered_version) < 0) {
131 return; 132 return;
132 } 133 }
133 134
134 bool registered_is_bundled =
135 !bundled_flash_dir.empty() && bundled_flash_dir.IsParent(plugin.path);
136 bool registered_is_debug_system = 135 bool registered_is_debug_system =
137 !system_flash_path.empty() && 136 !system_flash_path.empty() &&
138 base::FilePath::CompareEqualIgnoreCase(plugin.path.value(), 137 base::FilePath::CompareEqualIgnoreCase(plugin.path.value(),
139 system_flash_path.value()) && 138 system_flash_path.value()) &&
140 chrome::IsSystemFlashScriptDebuggerPresent(); 139 chrome::IsSystemFlashScriptDebuggerPresent();
141 bool is_on_network = false; 140 bool is_on_network = false;
142 #if defined(OS_WIN) 141 #if defined(OS_WIN)
143 // On Windows, component updated DLLs can't load off network drives. 142 // On Windows, component updated DLLs can't load off network drives.
144 // See crbug.com/572131 for details. 143 // See crbug.com/572131 for details.
145 is_on_network = base::IsOnNetworkDrive(path); 144 is_on_network = base::IsOnNetworkDrive(path);
146 #endif 145 #endif
147 // If equal version, register iff component is not on a network drive, 146 // If equal version, register iff component is not on a network drive,
148 // and the version of flash is not bundled, and not debug system. 147 // and the version of flash is not debug system.
149 if (registered_version.IsValid() && 148 if (registered_version.IsValid() &&
150 version.CompareTo(registered_version) == 0 && 149 version.CompareTo(registered_version) == 0 &&
151 (is_on_network || registered_is_bundled || 150 (is_on_network || registered_is_debug_system)) {
152 registered_is_debug_system)) {
153 return; 151 return;
154 } 152 }
155 153
156 // If the version is newer, remove the old one first. 154 // If the version is newer, remove the old one first.
157 PluginService::GetInstance()->UnregisterInternalPlugin(plugin.path); 155 PluginService::GetInstance()->UnregisterInternalPlugin(plugin.path);
158 break; 156 break;
159 } 157 }
160 158
161 PluginService::GetInstance()->RegisterInternalPlugin( 159 PluginService::GetInstance()->RegisterInternalPlugin(
162 plugin_info.ToWebPluginInfo(), true); 160 plugin_info.ToWebPluginInfo(), true);
163 PluginService::GetInstance()->RefreshPlugins(); 161 PluginService::GetInstance()->RefreshPlugins();
164 } 162 }
165 163
166 void NotifyPathServiceAndChrome(const base::FilePath& path, 164 void UpdatePathService(const base::FilePath& path) {
167 const Version& version) {
168 PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path); 165 PathService::Override(chrome::DIR_PEPPER_FLASH_PLUGIN, path);
169 BrowserThread::PostTask(
170 BrowserThread::UI, FROM_HERE,
171 base::Bind(&RegisterPepperFlashWithChrome,
172 path.Append(chrome::kPepperFlashPluginFilename),
173 version));
174 } 166 }
175 #endif // !defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD) 167 #endif // !defined(OS_LINUX) && defined(GOOGLE_CHROME_BUILD)
176 168
177 #if defined(GOOGLE_CHROME_BUILD) 169 #if defined(GOOGLE_CHROME_BUILD)
178 class FlashComponentInstallerTraits : public ComponentInstallerTraits { 170 class FlashComponentInstallerTraits : public ComponentInstallerTraits {
179 public: 171 public:
180 FlashComponentInstallerTraits(); 172 FlashComponentInstallerTraits();
181 ~FlashComponentInstallerTraits() override {} 173 ~FlashComponentInstallerTraits() override {}
182 174
183 private: 175 private:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 221 }
230 222
231 void FlashComponentInstallerTraits::ComponentReady( 223 void FlashComponentInstallerTraits::ComponentReady(
232 const base::Version& version, 224 const base::Version& version,
233 const base::FilePath& path, 225 const base::FilePath& path,
234 std::unique_ptr<base::DictionaryValue> manifest) { 226 std::unique_ptr<base::DictionaryValue> manifest) {
235 #if !defined(OS_LINUX) 227 #if !defined(OS_LINUX)
236 // Installation is done. Now tell the rest of chrome. Both the path service 228 // Installation is done. Now tell the rest of chrome. Both the path service
237 // and to the plugin service. On Linux, a restart is required to use the new 229 // and to the plugin service. On Linux, a restart is required to use the new
238 // Flash version, so we do not do this. 230 // Flash version, so we do not do this.
231 RegisterPepperFlashWithChrome(path.Append(chrome::kPepperFlashPluginFilename),
232 version);
239 BrowserThread::GetBlockingPool()->PostTask( 233 BrowserThread::GetBlockingPool()->PostTask(
240 FROM_HERE, base::Bind(&NotifyPathServiceAndChrome, path, version)); 234 FROM_HERE, base::Bind(&UpdatePathService, path));
241 #endif // !defined(OS_LINUX) 235 #endif // !defined(OS_LINUX)
242 } 236 }
243 237
244 bool FlashComponentInstallerTraits::VerifyInstallation( 238 bool FlashComponentInstallerTraits::VerifyInstallation(
245 const base::DictionaryValue& manifest, 239 const base::DictionaryValue& manifest,
246 const base::FilePath& install_dir) const { 240 const base::FilePath& install_dir) const {
247 Version unused; 241 Version unused;
248 return chrome::CheckPepperFlashManifest(manifest, &unused); 242 return chrome::CheckPepperFlashManifest(manifest, &unused);
249 } 243 }
250 244
(...skipping 29 matching lines...) Expand all
280 std::unique_ptr<ComponentInstallerTraits> traits( 274 std::unique_ptr<ComponentInstallerTraits> traits(
281 new FlashComponentInstallerTraits); 275 new FlashComponentInstallerTraits);
282 // |cus| will take ownership of |installer| during installer->Register(cus). 276 // |cus| will take ownership of |installer| during installer->Register(cus).
283 DefaultComponentInstaller* installer = 277 DefaultComponentInstaller* installer =
284 new DefaultComponentInstaller(std::move(traits)); 278 new DefaultComponentInstaller(std::move(traits));
285 installer->Register(cus, base::Closure()); 279 installer->Register(cus, base::Closure());
286 #endif // defined(GOOGLE_CHROME_BUILD) 280 #endif // defined(GOOGLE_CHROME_BUILD)
287 } 281 }
288 282
289 } // namespace component_updater 283 } // namespace component_updater
OLDNEW
« no previous file with comments | « no previous file | chrome/common/chrome_content_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698