| OLD | NEW |
| (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/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 gfx::Image* AlternateNavInfoBarDelegate::GetIcon() const { |
| 26 return &ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
| 27 IDR_INFOBAR_ALT_NAV_URL); |
| 28 } |
| 29 |
| 30 InfoBarDelegate::Type AlternateNavInfoBarDelegate::GetInfoBarType() const { |
| 31 return PAGE_ACTION_TYPE; |
| 32 } |
| 33 |
| 34 string16 AlternateNavInfoBarDelegate::GetMessageTextWithOffset( |
| 35 size_t* link_offset) const { |
| 36 const string16 label = l10n_util::GetStringFUTF16( |
| 37 IDS_ALTERNATE_NAV_URL_VIEW_LABEL, string16(), link_offset); |
| 38 return label; |
| 39 } |
| 40 |
| 41 string16 AlternateNavInfoBarDelegate::GetLinkText() const { |
| 42 return UTF8ToUTF16(alternate_nav_url_.spec()); |
| 43 } |
| 44 |
| 45 bool AlternateNavInfoBarDelegate::LinkClicked( |
| 46 WindowOpenDisposition disposition) { |
| 47 content::OpenURLParams params( |
| 48 alternate_nav_url_, content::Referrer(), disposition, |
| 49 // Pretend the user typed this URL, so that navigating to |
| 50 // it will be the default action when it's typed again in |
| 51 // the future. |
| 52 content::PAGE_TRANSITION_TYPED, |
| 53 false); |
| 54 owner()->GetWebContents()->OpenURL(params); |
| 55 |
| 56 // We should always close, even if the navigation did not occur within this |
| 57 // WebContents. |
| 58 return true; |
| 59 } |
| OLD | NEW |