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

Unified Diff: chrome/browser/ui/pdf/pdf_unsupported_feature.cc

Issue 11414286: Remove unneeded TabContents::FromWebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 8 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/pdf/pdf_unsupported_feature.cc
diff --git a/chrome/browser/ui/pdf/pdf_unsupported_feature.cc b/chrome/browser/ui/pdf/pdf_unsupported_feature.cc
index f7af1a957855a3dab6a3b1eec1337a869bb8f82d..c5517bc7292f0f381c9cf45a94df593526d59ce1 100644
--- a/chrome/browser/ui/pdf/pdf_unsupported_feature.cc
+++ b/chrome/browser/ui/pdf/pdf_unsupported_feature.cc
@@ -20,7 +20,6 @@
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/ui/pdf/open_pdf_in_reader_prompt_delegate.h"
#include "chrome/browser/ui/pdf/pdf_tab_helper.h"
-#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/chrome_content_client.h"
#include "chrome/common/jstemplate_builder.h"
#include "chrome/common/pref_names.h"
@@ -129,11 +128,11 @@ string16 PDFEnableAdobeReaderPromptDelegate::GetMessageText() const {
}
// Launch the url to get the latest Adbobe Reader installer.
-void OpenReaderUpdateURL(WebContents* tab) {
+void OpenReaderUpdateURL(WebContents* web_contents) {
OpenURLParams params(
GURL(kAdobeReaderUpdateUrl), Referrer(), NEW_FOREGROUND_TAB,
content::PAGE_TRANSITION_LINK, false);
- tab->OpenURL(params);
+ web_contents->OpenURL(params);
}
// Opens the PDF using Adobe Reader.
@@ -158,13 +157,13 @@ class PDFUnsupportedFeatureInterstitial
: public content::InterstitialPageDelegate {
public:
PDFUnsupportedFeatureInterstitial(
- TabContents* tab,
+ WebContents* web_contents,
const WebPluginInfo& reader_webplugininfo)
- : tab_contents_(tab),
+ : web_contents_(web_contents),
reader_webplugininfo_(reader_webplugininfo) {
content::RecordAction(UserMetricsAction("PDF_ReaderInterstitialShown"));
interstitial_page_ = InterstitialPage::Create(
- tab->web_contents(), false, tab->web_contents()->GetURL(), this);
+ web_contents, false, web_contents->GetURL(), this);
interstitial_page_->Show();
}
@@ -209,14 +208,13 @@ class PDFUnsupportedFeatureInterstitial
if (command == "1") {
content::RecordAction(
UserMetricsAction("PDF_ReaderInterstitialUpdate"));
- OpenReaderUpdateURL(tab_contents_->web_contents());
+ OpenReaderUpdateURL(web_contents_);
} else if (command == "2") {
content::RecordAction(
UserMetricsAction("PDF_ReaderInterstitialIgnore"));
// Pretend that the plug-in is up-to-date so that we don't block it.
reader_webplugininfo_.version = ASCIIToUTF16("11.0.0.0");
- OpenUsingReader(tab_contents_->web_contents(), reader_webplugininfo_,
- NULL);
+ OpenUsingReader(web_contents_, reader_webplugininfo_, NULL);
} else {
NOTREACHED();
}
@@ -225,12 +223,13 @@ class PDFUnsupportedFeatureInterstitial
virtual void OverrideRendererPrefs(
content::RendererPreferences* prefs) OVERRIDE {
- renderer_preferences_util::UpdateFromSystemSettings(
- prefs, tab_contents_->profile());
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents_->GetBrowserContext());
+ renderer_preferences_util::UpdateFromSystemSettings(prefs, profile);
}
private:
- TabContents* tab_contents_;
+ WebContents* web_contents_;
WebPluginInfo reader_webplugininfo_;
InterstitialPage* interstitial_page_; // Owns us.
@@ -243,7 +242,7 @@ class PDFUnsupportedFeaturePromptDelegate
: public OpenPDFInReaderPromptDelegate {
public:
// |reader| is NULL if Adobe Reader isn't installed.
- PDFUnsupportedFeaturePromptDelegate(TabContents* tab_contents,
+ PDFUnsupportedFeaturePromptDelegate(WebContents* web_contents,
const webkit::WebPluginInfo* reader,
PluginFinder* plugin_finder);
virtual ~PDFUnsupportedFeaturePromptDelegate();
@@ -258,7 +257,7 @@ class PDFUnsupportedFeaturePromptDelegate
virtual void Cancel() OVERRIDE;
private:
- TabContents* tab_contents_;
+ WebContents* web_contents_;
bool reader_installed_;
bool reader_vulnerable_;
WebPluginInfo reader_webplugininfo_;
@@ -267,10 +266,10 @@ class PDFUnsupportedFeaturePromptDelegate
};
PDFUnsupportedFeaturePromptDelegate::PDFUnsupportedFeaturePromptDelegate(
- TabContents* tab_contents,
+ WebContents* web_contents,
const webkit::WebPluginInfo* reader,
PluginFinder* plugin_finder)
- : tab_contents_(tab_contents),
+ : web_contents_(web_contents),
reader_installed_(!!reader),
reader_vulnerable_(false) {
if (!reader_installed_) {
@@ -331,22 +330,23 @@ void PDFUnsupportedFeaturePromptDelegate::Accept() {
if (!reader_installed_) {
content::RecordAction(UserMetricsAction("PDF_InstallReaderInfoBarOK"));
- OpenReaderUpdateURL(tab_contents_->web_contents());
+ OpenReaderUpdateURL(web_contents_);
return;
}
content::RecordAction(UserMetricsAction("PDF_UseReaderInfoBarOK"));
if (reader_vulnerable_) {
- new PDFUnsupportedFeatureInterstitial(tab_contents_, reader_webplugininfo_);
+ new PDFUnsupportedFeatureInterstitial(web_contents_, reader_webplugininfo_);
return;
}
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents_->GetBrowserContext());
OpenPDFInReaderPromptDelegate* delegate =
- new PDFEnableAdobeReaderPromptDelegate(tab_contents_->profile());
+ new PDFEnableAdobeReaderPromptDelegate(profile);
- OpenUsingReader(tab_contents_->web_contents(), reader_webplugininfo_,
- delegate);
+ OpenUsingReader(web_contents_, reader_webplugininfo_, delegate);
}
void PDFUnsupportedFeaturePromptDelegate::Cancel() {
@@ -364,10 +364,6 @@ void GotPluginsCallback(int process_id,
if (!web_contents)
return;
- TabContents* tab = TabContents::FromWebContents(web_contents);
- if (!tab)
- return;
-
const webkit::WebPluginInfo* reader = NULL;
PluginFinder* plugin_finder = PluginFinder::GetInstance();
for (size_t i = 0; i < plugins.size(); ++i) {
@@ -379,7 +375,9 @@ void GotPluginsCallback(int process_id,
DCHECK(!reader);
reader = &plugins[i];
// If the Reader plugin is disabled by policy, don't prompt them.
- PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(tab->profile());
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents->GetBrowserContext());
+ PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile);
if (plugin_prefs->PolicyStatusForPlugin(plugin_metadata->name()) ==
PluginPrefs::POLICY_DISABLED) {
return;
@@ -388,7 +386,8 @@ void GotPluginsCallback(int process_id,
}
scoped_ptr<OpenPDFInReaderPromptDelegate> prompt(
- new PDFUnsupportedFeaturePromptDelegate(tab, reader, plugin_finder));
+ new PDFUnsupportedFeaturePromptDelegate(
+ web_contents, reader, plugin_finder));
PDFTabHelper* pdf_tab_helper = PDFTabHelper::FromWebContents(web_contents);
pdf_tab_helper->ShowOpenInReaderPrompt(prompt.Pass());
}
« no previous file with comments | « chrome/browser/ui/intents/web_intent_picker_controller.cc ('k') | chrome/browser/ui/sync/one_click_signin_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698