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

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

Issue 10918174: Remove PluginGroup (Closed) Base URL: http://git.chromium.org/chromium/src.git@remove_async_plugin_finder
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"
(...skipping 18 matching lines...) Expand all
29 #include "content/public/browser/render_view_host.h" 29 #include "content/public/browser/render_view_host.h"
30 #include "content/public/browser/user_metrics.h" 30 #include "content/public/browser/user_metrics.h"
31 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
32 #include "grit/browser_resources.h" 32 #include "grit/browser_resources.h"
33 #include "grit/generated_resources.h" 33 #include "grit/generated_resources.h"
34 #include "grit/theme_resources.h" 34 #include "grit/theme_resources.h"
35 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
36 #include "ui/base/layout.h" 36 #include "ui/base/layout.h"
37 #include "ui/base/resource/resource_bundle.h" 37 #include "ui/base/resource/resource_bundle.h"
38 #include "ui/gfx/image/image.h" 38 #include "ui/gfx/image/image.h"
39 #include "webkit/plugins/npapi/plugin_group.h"
40 39
41 using content::InterstitialPage; 40 using content::InterstitialPage;
42 using content::OpenURLParams; 41 using content::OpenURLParams;
43 using content::PluginService; 42 using content::PluginService;
44 using content::Referrer; 43 using content::Referrer;
45 using content::UserMetricsAction; 44 using content::UserMetricsAction;
46 using content::WebContents; 45 using content::WebContents;
47 using webkit::npapi::PluginGroup;
48 using webkit::WebPluginInfo; 46 using webkit::WebPluginInfo;
49 47
50 namespace { 48 namespace {
51 49
52 static const char kReaderUpdateUrl[] = 50 static const char kReaderUpdateUrl[] =
53 "http://www.adobe.com/go/getreader_chrome"; 51 "http://www.adobe.com/go/getreader_chrome";
54 52
55 // The info bar delegate used to ask the user if they want to use Adobe Reader 53 // The info bar delegate used to ask the user if they want to use Adobe Reader
56 // by default. We want the infobar to have [No][Yes], so we swap the text on 54 // by default. We want the infobar to have [No][Yes], so we swap the text on
57 // the buttons, and the meaning of the delegate callbacks. 55 // the buttons, and the meaning of the delegate callbacks.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 116 }
119 117
120 string16 PDFEnableAdobeReaderInfoBarDelegate::GetMessageText() const { 118 string16 PDFEnableAdobeReaderInfoBarDelegate::GetMessageText() const {
121 return l10n_util::GetStringUTF16(IDS_PDF_INFOBAR_QUESTION_ALWAYS_USE_READER); 119 return l10n_util::GetStringUTF16(IDS_PDF_INFOBAR_QUESTION_ALWAYS_USE_READER);
122 } 120 }
123 121
124 void PDFEnableAdobeReaderInfoBarDelegate::OnYes() { 122 void PDFEnableAdobeReaderInfoBarDelegate::OnYes() {
125 content::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarOK")); 123 content::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarOK"));
126 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile_); 124 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile_);
127 plugin_prefs->EnablePluginGroup( 125 plugin_prefs->EnablePluginGroup(
128 true, ASCIIToUTF16(webkit::npapi::PluginGroup::kAdobeReaderGroupName)); 126 true, ASCIIToUTF16(PluginMetadata::kAdobeReaderGroupName));
129 plugin_prefs->EnablePluginGroup( 127 plugin_prefs->EnablePluginGroup(
130 false, ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName)); 128 false, ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName));
131 } 129 }
132 130
133 void PDFEnableAdobeReaderInfoBarDelegate::OnNo() { 131 void PDFEnableAdobeReaderInfoBarDelegate::OnNo() {
134 content::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarCancel")); 132 content::RecordAction(UserMetricsAction("PDF_EnableReaderInfoBarCancel"));
135 } 133 }
136 134
137 // Launch the url to get the latest Adbobe Reader installer. 135 // Launch the url to get the latest Adbobe Reader installer.
138 void OpenReaderUpdateURL(WebContents* tab) { 136 void OpenReaderUpdateURL(WebContents* tab) {
139 OpenURLParams params( 137 OpenURLParams params(
140 GURL(kReaderUpdateUrl), Referrer(), NEW_FOREGROUND_TAB, 138 GURL(kReaderUpdateUrl), Referrer(), NEW_FOREGROUND_TAB,
141 content::PAGE_TRANSITION_LINK, false); 139 content::PAGE_TRANSITION_LINK, false);
142 tab->OpenURL(params); 140 tab->OpenURL(params);
143 } 141 }
144 142
145 // Opens the PDF using Adobe Reader. 143 // Opens the PDF using Adobe Reader.
146 void OpenUsingReader(TabContents* tab, 144 void OpenUsingReader(TabContents* tab,
147 const WebPluginInfo& reader_plugin, 145 const WebPluginInfo& reader_plugin,
148 InfoBarDelegate* old_delegate, 146 InfoBarDelegate* old_delegate,
149 InfoBarDelegate* new_delegate) { 147 InfoBarDelegate* new_delegate) {
150 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( 148 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab(
151 tab->web_contents()->GetRenderProcessHost()->GetID(), 149 tab->web_contents()->GetRenderProcessHost()->GetID(),
152 tab->web_contents()->GetRenderViewHost()->GetRoutingID(), 150 tab->web_contents()->GetRenderViewHost()->GetRoutingID(),
153 tab->web_contents()->GetURL(), 151 tab->web_contents()->GetURL(),
154 ASCIIToUTF16(PluginGroup::kAdobeReaderGroupName)); 152 ASCIIToUTF16(PluginMetadata::kAdobeReaderGroupName));
155 tab->web_contents()->GetRenderViewHost()->ReloadFrame(); 153 tab->web_contents()->GetRenderViewHost()->ReloadFrame();
156 154
157 if (new_delegate) { 155 if (new_delegate) {
158 if (old_delegate) { 156 if (old_delegate) {
159 tab->infobar_tab_helper()->ReplaceInfoBar(old_delegate, new_delegate); 157 tab->infobar_tab_helper()->ReplaceInfoBar(old_delegate, new_delegate);
160 } else { 158 } else {
161 tab->infobar_tab_helper()->AddInfoBar(new_delegate); 159 tab->infobar_tab_helper()->AddInfoBar(new_delegate);
162 } 160 }
163 } 161 }
164 } 162 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 const std::vector<webkit::WebPluginInfo>& plugins) { 380 const std::vector<webkit::WebPluginInfo>& plugins) {
383 WebContents* web_contents = 381 WebContents* web_contents =
384 tab_util::GetWebContentsByID(process_id, routing_id); 382 tab_util::GetWebContentsByID(process_id, routing_id);
385 if (!web_contents) 383 if (!web_contents)
386 return; 384 return;
387 385
388 TabContents* tab = TabContents::FromWebContents(web_contents); 386 TabContents* tab = TabContents::FromWebContents(web_contents);
389 if (!tab) 387 if (!tab)
390 return; 388 return;
391 389
392 string16 reader_group_name(ASCIIToUTF16(PluginGroup::kAdobeReaderGroupName)); 390 string16 reader_group_name(
391 ASCIIToUTF16(PluginMetadata::kAdobeReaderGroupName));
393 // If the Reader plugin is disabled by policy, don't prompt them. 392 // If the Reader plugin is disabled by policy, don't prompt them.
394 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(tab->profile()); 393 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(tab->profile());
395 if (plugin_prefs->PolicyStatusForPlugin(reader_group_name) == 394 if (plugin_prefs->PolicyStatusForPlugin(reader_group_name) ==
396 PluginPrefs::POLICY_DISABLED) { 395 PluginPrefs::POLICY_DISABLED) {
397 return; 396 return;
398 } 397 }
399 398
400 const webkit::WebPluginInfo* reader = NULL; 399 const webkit::WebPluginInfo* reader = NULL;
401 PluginFinder* plugin_finder = PluginFinder::GetInstance(); 400 PluginFinder* plugin_finder = PluginFinder::GetInstance();
402 for (size_t i = 0; i < plugins.size(); ++i) { 401 for (size_t i = 0; i < plugins.size(); ++i) {
(...skipping 13 matching lines...) Expand all
416 415
417 void PDFHasUnsupportedFeature(TabContents* tab) { 416 void PDFHasUnsupportedFeature(TabContents* tab) {
418 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) 417 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION)
419 // Only works for Windows for now. For Mac, we'll have to launch the file 418 // Only works for Windows for now. For Mac, we'll have to launch the file
420 // externally since Adobe Reader doesn't work inside Chrome. 419 // externally since Adobe Reader doesn't work inside Chrome.
421 PluginFinder::Get(base::Bind(&GotPluginsCallback, 420 PluginFinder::Get(base::Bind(&GotPluginsCallback,
422 tab->web_contents()->GetRenderProcessHost()->GetID(), 421 tab->web_contents()->GetRenderProcessHost()->GetID(),
423 tab->web_contents()->GetRenderViewHost()->GetRoutingID())); 422 tab->web_contents()->GetRenderViewHost()->GetRoutingID()));
424 #endif 423 #endif
425 } 424 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698