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

Side by Side Diff: chrome/browser/infobars/alternate_nav_infobar_delegate.cc

Issue 11721003: Eliminate the LinkInfoBar[Delegate] classes entirely. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address some nits - testing-automation matters? 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/infobars/alternate_nav_infobar_delegate.h"
6
7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/api/infobars/infobar_service.h"
9 #include "content/public/browser/web_contents.h"
10 #include "grit/generated_resources.h"
11 #include "grit/theme_resources.h"
12 #include "ui/base/l10n/l10n_util.h"
13 #include "ui/base/resource/resource_bundle.h"
14
15 AlternateNavInfoBarDelegate::AlternateNavInfoBarDelegate(
16 InfoBarService* owner,
17 const GURL& alternate_nav_url)
18 : InfoBarDelegate(owner),
19 alternate_nav_url_(alternate_nav_url) {
20 }
21
22 AlternateNavInfoBarDelegate::~AlternateNavInfoBarDelegate() {
23 }
24
25 string16 AlternateNavInfoBarDelegate::GetMessageTextWithOffset(
26 size_t* link_offset) const {
27 const string16 label = l10n_util::GetStringFUTF16(
28 IDS_ALTERNATE_NAV_URL_VIEW_LABEL, string16(), link_offset);
29 return label;
30 }
31
32 string16 AlternateNavInfoBarDelegate::GetLinkText() const {
33 return UTF8ToUTF16(alternate_nav_url_.spec());
34 }
35
36 bool AlternateNavInfoBarDelegate::LinkClicked(
37 WindowOpenDisposition disposition) {
38 content::OpenURLParams params(
39 alternate_nav_url_, content::Referrer(), disposition,
40 // Pretend the user typed this URL, so that navigating to
41 // it will be the default action when it's typed again in
42 // the future.
43 content::PAGE_TRANSITION_TYPED,
44 false);
45 owner()->GetWebContents()->OpenURL(params);
46
47 // We should always close, even if the navigation did not occur within this
48 // WebContents.
49 return true;
50 }
51
52 AlternateNavInfoBarDelegate*
53 AlternateNavInfoBarDelegate::AsAlternateNavInfoBarDelegate() {
54 return this;
55 }
56
57 gfx::Image* AlternateNavInfoBarDelegate::GetIcon() const {
58 return &ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
59 IDR_INFOBAR_ALT_NAV_URL);
60 }
61
62 InfoBarDelegate::Type AlternateNavInfoBarDelegate::GetInfoBarType() const {
63 return PAGE_ACTION_TYPE;
64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698