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

Unified Diff: chrome/browser/tab_contents/tab_contents.cc

Issue 6350010: Put some plug-ins behind an infobar, where they have:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/tab_contents/tab_contents.cc
===================================================================
--- chrome/browser/tab_contents/tab_contents.cc (revision 72249)
+++ chrome/browser/tab_contents/tab_contents.cc (working copy)
@@ -248,97 +248,185 @@
params->request_time = base::Time::Now();
}
+// PluginInfoBar --------------------------------------------------------------
-// OutdatedPluginInfoBar ------------------------------------------------------
-
-class OutdatedPluginInfoBar : public ConfirmInfoBarDelegate {
+class PluginInfoBar : public ConfirmInfoBarDelegate {
public:
- OutdatedPluginInfoBar(TabContents* tab_contents,
- const string16& name,
- const GURL& update_url);
+ PluginInfoBar(TabContents* tab_contents,
+ const string16& name,
+ const GURL& update_url);
- private:
- virtual ~OutdatedPluginInfoBar();
-
// ConfirmInfoBarDelegate:
virtual void InfoBarClosed();
virtual SkBitmap* GetIcon() const;
- virtual string16 GetMessageText() const;
- virtual int GetButtons() const;
+ virtual string16 GetMessageText() const = 0;
+ virtual int GetButtons() const = 0;
virtual string16 GetButtonLabel(InfoBarButton button) const;
virtual bool Accept();
virtual bool Cancel();
virtual string16 GetLinkText();
virtual bool LinkClicked(WindowOpenDisposition disposition);
+ protected:
+ virtual ~PluginInfoBar();
+
+ string16 name_;
+
+ private:
+ virtual void RecordMetric(const std::string& action) const = 0;
+
TabContents* tab_contents_;
- string16 name_;
GURL update_url_;
+
+ DISALLOW_COPY_AND_ASSIGN(PluginInfoBar);
};
-OutdatedPluginInfoBar::OutdatedPluginInfoBar(TabContents* tab_contents,
- const string16& name,
- const GURL& update_url)
+PluginInfoBar::PluginInfoBar(TabContents* tab_contents,
+ const string16& name,
+ const GURL& update_url)
: ConfirmInfoBarDelegate(tab_contents),
+ name_(name),
tab_contents_(tab_contents),
- name_(name),
update_url_(update_url) {
- UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown"));
- tab_contents->AddInfoBar(this);
}
-OutdatedPluginInfoBar::~OutdatedPluginInfoBar() {
+PluginInfoBar::~PluginInfoBar() {
}
-void OutdatedPluginInfoBar::InfoBarClosed() {
- UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Closed"));
+void PluginInfoBar::InfoBarClosed() {
+ RecordMetric("Closed");
delete this;
}
-SkBitmap* OutdatedPluginInfoBar::GetIcon() const {
+SkBitmap* PluginInfoBar::GetIcon() const {
return ResourceBundle::GetSharedInstance().GetBitmapNamed(
IDR_INFOBAR_PLUGIN_INSTALL);
}
-string16 OutdatedPluginInfoBar::GetMessageText() const {
- return l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT, name_);
-}
-
-int OutdatedPluginInfoBar::GetButtons() const {
- return BUTTON_OK | BUTTON_CANCEL;
-}
-
-string16 OutdatedPluginInfoBar::GetButtonLabel(InfoBarButton button) const {
+string16 PluginInfoBar::GetButtonLabel(InfoBarButton button) const {
return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
IDS_PLUGIN_UPDATE : IDS_PLUGIN_ENABLE_TEMPORARILY);
}
-bool OutdatedPluginInfoBar::Accept() {
- UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Update"));
+bool PluginInfoBar::Accept() {
+ RecordMetric("Update");
tab_contents_->OpenURL(update_url_, GURL(), NEW_FOREGROUND_TAB,
PageTransition::LINK);
return false;
}
-bool OutdatedPluginInfoBar::Cancel() {
- UserMetrics::RecordAction(
- UserMetricsAction("OutdatedPluginInfobar.AllowThisTime"));
+bool PluginInfoBar::Cancel() {
+ RecordMetric("AllowThisTime");
tab_contents_->render_view_host()->LoadBlockedPlugins();
return false;
}
-string16 OutdatedPluginInfoBar::GetLinkText() {
+string16 PluginInfoBar::GetLinkText() {
return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
}
-bool OutdatedPluginInfoBar::LinkClicked(WindowOpenDisposition disposition) {
- UserMetrics::RecordAction(
- UserMetricsAction("OutdatedPluginInfobar.LearnMore"));
+bool PluginInfoBar::LinkClicked(WindowOpenDisposition disposition) {
+ RecordMetric("LearnMore");
// TODO(bauerb): Navigate to a help page explaining why we disabled
- // the plugin, once we have one.
+ // or blocked the plugin, once we have one.
return false;
}
+
+// BlockedPluginInfoBar -------------------------------------------------------
+
+class BlockedPluginInfoBar : public PluginInfoBar {
+ public:
+ BlockedPluginInfoBar(TabContents* tab_contents,
+ const string16& name);
+
+ // ConfirmInfoBarDelegate:
+ virtual string16 GetMessageText() const;
+ virtual int GetButtons() const;
+
+ protected:
+ virtual ~BlockedPluginInfoBar();
+
+ private:
+ // PluginInfoBar:
+ virtual void RecordMetric(const std::string& action) const;
+
+ DISALLOW_COPY_AND_ASSIGN(BlockedPluginInfoBar);
+};
+
+BlockedPluginInfoBar::BlockedPluginInfoBar(TabContents* tab_contents,
+ const string16& name)
+ : PluginInfoBar(tab_contents, name, GURL()) {
+ tab_contents->AddInfoBar(this);
+ RecordMetric("Shown");
+}
+
+BlockedPluginInfoBar::~BlockedPluginInfoBar() {
+}
+
+string16 BlockedPluginInfoBar::GetMessageText() const {
+ return l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, name_);
+}
+
+int BlockedPluginInfoBar::GetButtons() const {
+ return BUTTON_CANCEL;
+}
+
+void BlockedPluginInfoBar::RecordMetric(const std::string& action) const {
+ std::string uma("BlockedPluginInfobar");
+ uma += UTF16ToASCII(name_);
+ uma += ".";
+ uma += action;
+ UserMetrics::RecordAction(UserMetricsAction(uma.c_str()));
Bernhard Bauer 2011/01/24 12:56:33 The problem with this is if you don't use a string
+}
+
+// OutdatedPluginInfoBar ------------------------------------------------------
+
+class OutdatedPluginInfoBar : public PluginInfoBar {
+ public:
+ OutdatedPluginInfoBar(TabContents* tab_contents,
+ const string16& name,
+ const GURL& update_url);
+
+ // ConfirmInfoBarDelegate:
+ virtual string16 GetMessageText() const;
+ virtual int GetButtons() const;
+
+ protected:
+ virtual ~OutdatedPluginInfoBar();
+
+ private:
+ // PluginInfoBar:
+ virtual void RecordMetric(const std::string& action) const;
+
+ DISALLOW_COPY_AND_ASSIGN(OutdatedPluginInfoBar);
+};
+
+OutdatedPluginInfoBar::OutdatedPluginInfoBar(TabContents* tab_contents,
+ const string16& name,
+ const GURL& update_url)
+ : PluginInfoBar(tab_contents, name, update_url) {
+ tab_contents->AddInfoBar(this);
+ RecordMetric("Shown");
+}
+
+OutdatedPluginInfoBar::~OutdatedPluginInfoBar() {
+}
+
+string16 OutdatedPluginInfoBar::GetMessageText() const {
+ return l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT, name_);
+}
+
+int OutdatedPluginInfoBar::GetButtons() const {
+ return BUTTON_OK | BUTTON_CANCEL;
+}
+
+void OutdatedPluginInfoBar::RecordMetric(const std::string& action) const {
+ std::string uma("OutdatedPluginInfobar.");
+ uma += action;
+ UserMetrics::RecordAction(UserMetricsAction(uma.c_str()));
+}
+
} // namespace
@@ -2350,7 +2438,10 @@
void TabContents::OnBlockedOutdatedPlugin(const string16& name,
const GURL& update_url) {
- new OutdatedPluginInfoBar(this, name, update_url);
+ if (!update_url.is_empty())
+ new OutdatedPluginInfoBar(this, name, update_url);
+ else
+ new BlockedPluginInfoBar(this, name);
}
void TabContents::OnPageContents(const GURL& url,

Powered by Google App Engine
This is Rietveld 408576698