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

Unified Diff: chrome/browser/nacl_host/nacl_infobar.cc

Issue 11593020: Add a help center link to NaCl infobar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase after infobar changes Created 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/nacl_host/nacl_infobar.cc
diff --git a/chrome/browser/nacl_host/nacl_infobar.cc b/chrome/browser/nacl_host/nacl_infobar.cc
index eb6fe358d67b4a5a9670391f0198074377ad2525..6b5dcea319a61957658a212fcfbced79591bc774 100644
--- a/chrome/browser/nacl_host/nacl_infobar.cc
+++ b/chrome/browser/nacl_host/nacl_infobar.cc
@@ -5,21 +5,66 @@
#include "chrome/browser/nacl_host/nacl_infobar.h"
#include "base/bind.h"
+#include "base/string16.h"
+#include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
#include "chrome/browser/api/infobars/infobar_service.h"
-#include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
+#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
#include "ppapi/c/private/ppb_nacl_private.h"
#include "ui/base/l10n/l10n_util.h"
-
using content::BrowserThread;
using content::RenderViewHost;
using content::WebContents;
namespace {
+// The URL for the "learn more" article.
+const char kNaClLearnMoreUrl[] =
+ "https://support.google.com/chrome/?p=ib_nacl";
+
+// A simple LinkInfoBarDelegate doesn't support making the link right-aligned
+// so use a ConfirmInfoBarDelegate without any buttons instead.
+class NaClInfoBarDelegate : public ConfirmInfoBarDelegate {
+ public:
+ virtual string16 GetMessageText() const OVERRIDE;
+ virtual string16 GetLinkText() const OVERRIDE;
+ virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
+ virtual int GetButtons() const OVERRIDE;
+ static void Create(InfoBarService* ibs, WebContents* wc);
+ private:
+ NaClInfoBarDelegate(WebContents* wc, InfoBarService* ibs) :
+ ConfirmInfoBarDelegate(ibs), wc_(wc) {}
+ WebContents* wc_;
+};
+
+string16 NaClInfoBarDelegate::GetMessageText() const {
+ return l10n_util::GetStringUTF16(IDS_NACL_APP_MISSING_ARCH_MESSAGE);
+}
+
+string16 NaClInfoBarDelegate::GetLinkText() const {
+ return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
+}
+
+bool NaClInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
+ content::OpenURLParams params(
+ GURL(kNaClLearnMoreUrl), content::Referrer(),
+ (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
+ content::PAGE_TRANSITION_LINK,
+ false);
+ wc_->OpenURL(params);
+ return false;
+}
+
+int NaClInfoBarDelegate::GetButtons() const { return BUTTON_NONE; }
+
+// static
+void NaClInfoBarDelegate::Create(InfoBarService* ibs, WebContents *wc) {
+ ibs->AddInfoBar(scoped_ptr<InfoBarDelegate>(
+ new NaClInfoBarDelegate(wc, ibs)));
+}
void ShowInfobar(int render_process_id, int render_view_id,
int error_id) {
@@ -29,9 +74,7 @@ void ShowInfobar(int render_process_id, int render_view_id,
RenderViewHost* rvh = RenderViewHost::FromID(render_process_id,
render_view_id);
WebContents* wc = WebContents::FromRenderViewHost(rvh);
- InfoBarService* ibs = InfoBarService::FromWebContents(wc);
- SimpleAlertInfoBarDelegate::Create(ibs, NULL,
- l10n_util::GetStringUTF16(IDS_NACL_APP_MISSING_ARCH_MESSAGE), true);
+ NaClInfoBarDelegate::Create(InfoBarService::FromWebContents(wc), wc);
}
} // namespace
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698