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

Side by Side Diff: chrome/browser/ui/pdf/pdf_unsupported_feature.cc

Issue 10910168: Separate plugin_metadata from plugin_installer, thread-safe plugin_finder (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: .. Created 8 years, 3 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
OLDNEW
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/ui/pdf/pdf_unsupported_feature.h" 5 #include "chrome/browser/ui/pdf/pdf_unsupported_feature.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "base/version.h" 10 #include "base/version.h"
11 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" 11 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
12 #include "chrome/browser/chrome_plugin_service_filter.h" 12 #include "chrome/browser/chrome_plugin_service_filter.h"
13 #include "chrome/browser/infobars/infobar_tab_helper.h" 13 #include "chrome/browser/infobars/infobar_tab_helper.h"
14 #include "chrome/browser/plugin_finder.h" 14 #include "chrome/browser/plugin_finder.h"
15 #include "chrome/browser/plugin_installer.h" 15 #include "chrome/browser/plugin_metadata.h"
16 #include "chrome/browser/plugin_prefs.h" 16 #include "chrome/browser/plugin_prefs.h"
17 #include "chrome/browser/prefs/pref_service.h" 17 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/renderer_preferences_util.h" 19 #include "chrome/browser/renderer_preferences_util.h"
20 #include "chrome/browser/tab_contents/tab_util.h" 20 #include "chrome/browser/tab_contents/tab_util.h"
21 #include "chrome/browser/ui/tab_contents/tab_contents.h" 21 #include "chrome/browser/ui/tab_contents/tab_contents.h"
22 #include "chrome/common/chrome_content_client.h" 22 #include "chrome/common/chrome_content_client.h"
23 #include "chrome/common/jstemplate_builder.h" 23 #include "chrome/common/jstemplate_builder.h"
24 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
25 #include "content/public/browser/interstitial_page.h" 25 #include "content/public/browser/interstitial_page.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 if (!reader_installed_) { 289 if (!reader_installed_) {
290 content::RecordAction( 290 content::RecordAction(
291 UserMetricsAction("PDF_InstallReaderInfoBarShown")); 291 UserMetricsAction("PDF_InstallReaderInfoBarShown"));
292 return; 292 return;
293 } 293 }
294 294
295 content::RecordAction(UserMetricsAction("PDF_UseReaderInfoBarShown")); 295 content::RecordAction(UserMetricsAction("PDF_UseReaderInfoBarShown"));
296 reader_webplugininfo_ = *reader; 296 reader_webplugininfo_ = *reader;
297 297
298 #if defined(ENABLE_PLUGIN_INSTALLATION) 298 #if defined(ENABLE_PLUGIN_INSTALLATION)
299 PluginInstaller* installer = 299 PluginMetadata* plugin_metadata =
300 plugin_finder->FindPluginWithIdentifier("adobe-reader"); 300 plugin_finder->FindPluginMetadataWithIdentifier("adobe-reader");
301 301
302 reader_vulnerable_ = 302 reader_vulnerable_ = plugin_metadata->GetSecurityStatus(*reader) !=
303 installer->GetSecurityStatus(*reader) != 303 PluginMetadata::SECURITY_STATUS_UP_TO_DATE;
304 PluginInstaller::SECURITY_STATUS_UP_TO_DATE;
305 #else 304 #else
306 NOTREACHED(); 305 NOTREACHED();
307 #endif 306 #endif
308 } 307 }
309 308
310 PDFUnsupportedFeatureInfoBarDelegate::~PDFUnsupportedFeatureInfoBarDelegate() { 309 PDFUnsupportedFeatureInfoBarDelegate::~PDFUnsupportedFeatureInfoBarDelegate() {
311 } 310 }
312 311
313 void PDFUnsupportedFeatureInfoBarDelegate::InfoBarDismissed() { 312 void PDFUnsupportedFeatureInfoBarDelegate::InfoBarDismissed() {
314 OnNo(); 313 OnNo();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 372 }
374 373
375 void PDFUnsupportedFeatureInfoBarDelegate::OnNo() { 374 void PDFUnsupportedFeatureInfoBarDelegate::OnNo() {
376 content::RecordAction(reader_installed_ ? 375 content::RecordAction(reader_installed_ ?
377 UserMetricsAction("PDF_UseReaderInfoBarCancel") : 376 UserMetricsAction("PDF_UseReaderInfoBarCancel") :
378 UserMetricsAction("PDF_InstallReaderInfoBarCancel")); 377 UserMetricsAction("PDF_InstallReaderInfoBarCancel"));
379 } 378 }
380 379
381 void GotPluginsCallback(int process_id, 380 void GotPluginsCallback(int process_id,
382 int routing_id, 381 int routing_id,
383 PluginFinder* plugin_finder,
384 const std::vector<webkit::WebPluginInfo>& plugins) { 382 const std::vector<webkit::WebPluginInfo>& plugins) {
385 WebContents* web_contents = 383 WebContents* web_contents =
386 tab_util::GetWebContentsByID(process_id, routing_id); 384 tab_util::GetWebContentsByID(process_id, routing_id);
387 if (!web_contents) 385 if (!web_contents)
388 return; 386 return;
389 387
390 TabContents* tab = TabContents::FromWebContents(web_contents); 388 TabContents* tab = TabContents::FromWebContents(web_contents);
391 if (!tab) 389 if (!tab)
392 return; 390 return;
393 391
394 string16 reader_group_name(ASCIIToUTF16(PluginGroup::kAdobeReaderGroupName)); 392 string16 reader_group_name(ASCIIToUTF16(PluginGroup::kAdobeReaderGroupName));
395 // If the Reader plugin is disabled by policy, don't prompt them. 393 // If the Reader plugin is disabled by policy, don't prompt them.
396 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(tab->profile()); 394 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(tab->profile());
397 if (plugin_prefs->PolicyStatusForPlugin(reader_group_name) == 395 if (plugin_prefs->PolicyStatusForPlugin(reader_group_name) ==
398 PluginPrefs::POLICY_DISABLED) { 396 PluginPrefs::POLICY_DISABLED) {
399 return; 397 return;
400 } 398 }
401 399
402 const webkit::WebPluginInfo* reader = NULL; 400 const webkit::WebPluginInfo* reader = NULL;
401 PluginFinder* plugin_finder = PluginFinder::GetInstance();
403 for (size_t i = 0; i < plugins.size(); ++i) { 402 for (size_t i = 0; i < plugins.size(); ++i) {
404 PluginInstaller* installer = plugin_finder->GetPluginInstaller(plugins[i]); 403 PluginMetadata* plugin_metadata =
405 if (reader_group_name == installer->name()) { 404 plugin_finder->GetPluginMetadata(plugins[i]);
405 if (reader_group_name == plugin_metadata->name()) {
406 DCHECK(!reader); 406 DCHECK(!reader);
407 reader = &plugins[i]; 407 reader = &plugins[i];
408 } 408 }
409 } 409 }
410 410
411 tab->infobar_tab_helper()->AddInfoBar( 411 tab->infobar_tab_helper()->AddInfoBar(
412 new PDFUnsupportedFeatureInfoBarDelegate(tab, reader, plugin_finder)); 412 new PDFUnsupportedFeatureInfoBarDelegate(tab, reader, plugin_finder));
413 } 413 }
414 414
415 void GotPluginFinderCallback(int process_id,
416 int routing_id,
417 PluginFinder* plugin_finder) {
418 PluginService::GetInstance()->GetPlugins(
419 base::Bind(&GotPluginsCallback, process_id, routing_id,
420 base::Unretained(plugin_finder)));
421 }
422
423 } // namespace 415 } // namespace
424 416
425 void PDFHasUnsupportedFeature(TabContents* tab) { 417 void PDFHasUnsupportedFeature(TabContents* tab) {
426 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) 418 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION)
427 // Only works for Windows for now. For Mac, we'll have to launch the file 419 // Only works for Windows for now. For Mac, we'll have to launch the file
428 // externally since Adobe Reader doesn't work inside Chrome. 420 // externally since Adobe Reader doesn't work inside Chrome.
429 PluginFinder::Get(base::Bind(&GotPluginFinderCallback, 421 PluginFinder::Get(base::Bind(&GotPluginsCallback,
430 tab->web_contents()->GetRenderProcessHost()->GetID(), 422 tab->web_contents()->GetRenderProcessHost()->GetID(),
431 tab->web_contents()->GetRenderViewHost()->GetRoutingID())); 423 tab->web_contents()->GetRenderViewHost()->GetRoutingID()));
432 #endif 424 #endif
433 } 425 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698