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/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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
44 #include "base/win/metro.h" | 44 #include "base/win/metro.h" |
45 #endif | 45 #endif |
46 | 46 |
47 using content::InterstitialPage; | 47 using content::InterstitialPage; |
48 using content::OpenURLParams; | 48 using content::OpenURLParams; |
49 using content::PluginService; | 49 using content::PluginService; |
50 using content::Referrer; | 50 using content::Referrer; |
51 using content::UserMetricsAction; | 51 using content::UserMetricsAction; |
52 using content::WebContents; | 52 using content::WebContents; |
53 using webkit::WebPluginInfo; | 53 using content::WebPluginInfo; |
54 | 54 |
55 namespace { | 55 namespace { |
56 | 56 |
57 static const char kAdobeReaderIdentifier[] = "adobe-reader"; | 57 static const char kAdobeReaderIdentifier[] = "adobe-reader"; |
58 static const char kAdobeReaderUpdateUrl[] = | 58 static const char kAdobeReaderUpdateUrl[] = |
59 "http://www.adobe.com/go/getreader_chrome"; | 59 "http://www.adobe.com/go/getreader_chrome"; |
60 | 60 |
61 // The prompt delegate used to ask the user if they want to use Adobe Reader | 61 // The prompt delegate used to ask the user if they want to use Adobe Reader |
62 // by default. | 62 // by default. |
63 class PDFEnableAdobeReaderPromptDelegate | 63 class PDFEnableAdobeReaderPromptDelegate |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 DISALLOW_COPY_AND_ASSIGN(PDFUnsupportedFeatureInterstitial); | 236 DISALLOW_COPY_AND_ASSIGN(PDFUnsupportedFeatureInterstitial); |
237 }; | 237 }; |
238 | 238 |
239 // The delegate for the bubble used to inform the user that we don't support a | 239 // The delegate for the bubble used to inform the user that we don't support a |
240 // feature in the PDF. | 240 // feature in the PDF. |
241 class PDFUnsupportedFeaturePromptDelegate | 241 class PDFUnsupportedFeaturePromptDelegate |
242 : public OpenPDFInReaderPromptDelegate { | 242 : public OpenPDFInReaderPromptDelegate { |
243 public: | 243 public: |
244 // |reader| is NULL if Adobe Reader isn't installed. | 244 // |reader| is NULL if Adobe Reader isn't installed. |
245 PDFUnsupportedFeaturePromptDelegate(WebContents* web_contents, | 245 PDFUnsupportedFeaturePromptDelegate(WebContents* web_contents, |
246 const webkit::WebPluginInfo* reader, | 246 const content::WebPluginInfo* reader, |
247 PluginFinder* plugin_finder); | 247 PluginFinder* plugin_finder); |
248 virtual ~PDFUnsupportedFeaturePromptDelegate(); | 248 virtual ~PDFUnsupportedFeaturePromptDelegate(); |
249 | 249 |
250 // OpenPDFInReaderPromptDelegate: | 250 // OpenPDFInReaderPromptDelegate: |
251 virtual string16 GetMessageText() const OVERRIDE; | 251 virtual string16 GetMessageText() const OVERRIDE; |
252 virtual string16 GetAcceptButtonText() const OVERRIDE; | 252 virtual string16 GetAcceptButtonText() const OVERRIDE; |
253 virtual string16 GetCancelButtonText() const OVERRIDE; | 253 virtual string16 GetCancelButtonText() const OVERRIDE; |
254 virtual bool ShouldExpire( | 254 virtual bool ShouldExpire( |
255 const content::LoadCommittedDetails& details) const OVERRIDE; | 255 const content::LoadCommittedDetails& details) const OVERRIDE; |
256 virtual void Accept() OVERRIDE; | 256 virtual void Accept() OVERRIDE; |
257 virtual void Cancel() OVERRIDE; | 257 virtual void Cancel() OVERRIDE; |
258 | 258 |
259 private: | 259 private: |
260 WebContents* web_contents_; | 260 WebContents* web_contents_; |
261 bool reader_installed_; | 261 bool reader_installed_; |
262 bool reader_vulnerable_; | 262 bool reader_vulnerable_; |
263 WebPluginInfo reader_webplugininfo_; | 263 WebPluginInfo reader_webplugininfo_; |
264 | 264 |
265 DISALLOW_IMPLICIT_CONSTRUCTORS(PDFUnsupportedFeaturePromptDelegate); | 265 DISALLOW_IMPLICIT_CONSTRUCTORS(PDFUnsupportedFeaturePromptDelegate); |
266 }; | 266 }; |
267 | 267 |
268 PDFUnsupportedFeaturePromptDelegate::PDFUnsupportedFeaturePromptDelegate( | 268 PDFUnsupportedFeaturePromptDelegate::PDFUnsupportedFeaturePromptDelegate( |
269 WebContents* web_contents, | 269 WebContents* web_contents, |
270 const webkit::WebPluginInfo* reader, | 270 const content::WebPluginInfo* reader, |
271 PluginFinder* plugin_finder) | 271 PluginFinder* plugin_finder) |
272 : web_contents_(web_contents), | 272 : web_contents_(web_contents), |
273 reader_installed_(!!reader), | 273 reader_installed_(!!reader), |
274 reader_vulnerable_(false) { | 274 reader_vulnerable_(false) { |
275 if (!reader_installed_) { | 275 if (!reader_installed_) { |
276 content::RecordAction( | 276 content::RecordAction( |
277 UserMetricsAction("PDF_InstallReaderInfoBarShown")); | 277 UserMetricsAction("PDF_InstallReaderInfoBarShown")); |
278 return; | 278 return; |
279 } | 279 } |
280 | 280 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 351 |
352 void PDFUnsupportedFeaturePromptDelegate::Cancel() { | 352 void PDFUnsupportedFeaturePromptDelegate::Cancel() { |
353 content::RecordAction(reader_installed_ ? | 353 content::RecordAction(reader_installed_ ? |
354 UserMetricsAction("PDF_UseReaderInfoBarCancel") : | 354 UserMetricsAction("PDF_UseReaderInfoBarCancel") : |
355 UserMetricsAction("PDF_InstallReaderInfoBarCancel")); | 355 UserMetricsAction("PDF_InstallReaderInfoBarCancel")); |
356 } | 356 } |
357 | 357 |
358 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) | 358 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) |
359 void GotPluginsCallback(int process_id, | 359 void GotPluginsCallback(int process_id, |
360 int routing_id, | 360 int routing_id, |
361 const std::vector<webkit::WebPluginInfo>& plugins) { | 361 const std::vector<content::WebPluginInfo>& plugins) { |
362 WebContents* web_contents = | 362 WebContents* web_contents = |
363 tab_util::GetWebContentsByID(process_id, routing_id); | 363 tab_util::GetWebContentsByID(process_id, routing_id); |
364 if (!web_contents) | 364 if (!web_contents) |
365 return; | 365 return; |
366 | 366 |
367 const webkit::WebPluginInfo* reader = NULL; | 367 const content::WebPluginInfo* reader = NULL; |
368 PluginFinder* plugin_finder = PluginFinder::GetInstance(); | 368 PluginFinder* plugin_finder = PluginFinder::GetInstance(); |
369 for (size_t i = 0; i < plugins.size(); ++i) { | 369 for (size_t i = 0; i < plugins.size(); ++i) { |
370 scoped_ptr<PluginMetadata> plugin_metadata( | 370 scoped_ptr<PluginMetadata> plugin_metadata( |
371 plugin_finder->GetPluginMetadata(plugins[i])); | 371 plugin_finder->GetPluginMetadata(plugins[i])); |
372 if (plugin_metadata->identifier() != kAdobeReaderIdentifier) | 372 if (plugin_metadata->identifier() != kAdobeReaderIdentifier) |
373 continue; | 373 continue; |
374 | 374 |
375 DCHECK(!reader); | 375 DCHECK(!reader); |
376 reader = &plugins[i]; | 376 reader = &plugins[i]; |
377 // If the Reader plugin is disabled by policy, don't prompt them. | 377 // If the Reader plugin is disabled by policy, don't prompt them. |
(...skipping 19 matching lines...) Expand all Loading... |
397 | 397 |
398 void PDFHasUnsupportedFeature(content::WebContents* web_contents) { | 398 void PDFHasUnsupportedFeature(content::WebContents* web_contents) { |
399 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) | 399 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) |
400 // Only works for Windows for now. For Mac, we'll have to launch the file | 400 // Only works for Windows for now. For Mac, we'll have to launch the file |
401 // externally since Adobe Reader doesn't work inside Chrome. | 401 // externally since Adobe Reader doesn't work inside Chrome. |
402 PluginService::GetInstance()->GetPlugins(base::Bind(&GotPluginsCallback, | 402 PluginService::GetInstance()->GetPlugins(base::Bind(&GotPluginsCallback, |
403 web_contents->GetRenderProcessHost()->GetID(), | 403 web_contents->GetRenderProcessHost()->GetID(), |
404 web_contents->GetRenderViewHost()->GetRoutingID())); | 404 web_contents->GetRenderViewHost()->GetRoutingID())); |
405 #endif | 405 #endif |
406 } | 406 } |
OLD | NEW |