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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/nacl_host/nacl_infobar.h" 5 #include "chrome/browser/nacl_host/nacl_infobar.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/string16.h"
8 #include "chrome/browser/api/infobars/infobar_service.h" 9 #include "chrome/browser/api/infobars/infobar_service.h"
9 #include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h" 10 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
10 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/render_view_host.h" 12 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "googleurl/src/gurl.h"
13 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
14 #include "ppapi/c/private/ppb_nacl_private.h" 16 #include "ppapi/c/private/ppb_nacl_private.h"
15 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
16 18
17
18 using content::BrowserThread; 19 using content::BrowserThread;
19 using content::RenderViewHost; 20 using content::RenderViewHost;
20 using content::WebContents; 21 using content::WebContents;
21 22
22 namespace { 23 namespace {
24 // The URL for the "learn more" article.
25 const char kNaClLearnMoreUrl[] =
26 "https://support.google.com/chrome/?p=ib_nacl";
27
28 // A simple LinkInfoBarDelegate doesn't support making the link right-aligned
29 // so use a ConfirmInfoBarDelegate without any buttons instead.
30 class NaClInfobarDelegate : public ConfirmInfoBarDelegate {
jvoung (off chromium) 2013/01/07 22:13:39 Could you make the definitions out of line instead
Derek Schuff 2013/01/08 16:53:27 Done.
31 public:
32 NaClInfobarDelegate(WebContents* wc, InfoBarService* ibs) :
33 ConfirmInfoBarDelegate(ibs), wc_(wc) {}
34 virtual string16 GetMessageText() const {
35 return l10n_util::GetStringUTF16(IDS_NACL_APP_MISSING_ARCH_MESSAGE);
36 }
37 virtual string16 GetLinkText() const {
38 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
39 }
40 virtual bool LinkClicked(WindowOpenDisposition disposition) {
41 content::OpenURLParams params(
42 GURL(kNaClLearnMoreUrl), content::Referrer(),
43 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
44 content::PAGE_TRANSITION_LINK,
45 false);
46 wc_->OpenURL(params);
47 return false;
48 }
49 virtual int GetButtons() const { return BUTTON_NONE; }
50 private:
51 WebContents* wc_;
52 };
23 53
24 void ShowInfobar(int render_process_id, int render_view_id, 54 void ShowInfobar(int render_process_id, int render_view_id,
25 int error_id) { 55 int error_id) {
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
27 DCHECK(static_cast<PP_NaClError>(error_id) == 57 DCHECK(static_cast<PP_NaClError>(error_id) ==
28 PP_NACL_MANIFEST_MISSING_ARCH); 58 PP_NACL_MANIFEST_MISSING_ARCH);
29 RenderViewHost* rvh = RenderViewHost::FromID(render_process_id, 59 RenderViewHost* rvh = RenderViewHost::FromID(render_process_id,
30 render_view_id); 60 render_view_id);
31 WebContents* wc = WebContents::FromRenderViewHost(rvh); 61 WebContents* wc = WebContents::FromRenderViewHost(rvh);
32 InfoBarService* ibs = InfoBarService::FromWebContents(wc); 62 InfoBarService* ibs = InfoBarService::FromWebContents(wc);
33 ibs->AddInfoBar(new SimpleAlertInfoBarDelegate(ibs, NULL, 63 ibs->AddInfoBar(new NaClInfobarDelegate(wc, ibs));
34 l10n_util::GetStringUTF16(IDS_NACL_APP_MISSING_ARCH_MESSAGE), true));
35 } 64 }
36 65
37 } // namespace 66 } // namespace
38 67
39 void ShowNaClInfobar(int render_process_id, int render_view_id, 68 void ShowNaClInfobar(int render_process_id, int render_view_id,
40 int error_id) { 69 int error_id) {
41 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 70 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
42 base::Bind(&ShowInfobar, render_process_id, render_view_id, 71 base::Bind(&ShowInfobar, render_process_id, render_view_id,
43 error_id)); 72 error_id));
44 } 73 }
OLDNEW
« 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