Commit 1d421c2a authored by dschuff@chromium.org's avatar dschuff@chromium.org

Add a help center link to NaCl infobar

This CL adds a help center link to the infobar which is displayed when
a NaCl app doesn't support the user's architecture.

R=jvoung@chromium.org,sehr@chromium.org (code), cstefansen (URL)
BUG= http://code.google.com/p/chromium/issues/detail?id=168607


Review URL: https://chromiumcodereview.appspot.com/11593020

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175889 0039d316-1c4b-4281-b951-d872f2087c98
parent b734490f
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment