Add a minor text member to ui::MenuModel.
[chromium-blink-merge.git] / chrome / browser / ui / omnibox / alternate_nav_infobar_delegate.cc
blobba9fc0aad47c07846def33f962b5fc6013927de0
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.
5 #include "chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/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"
15 // static
16 void AlternateNavInfoBarDelegate::Create(InfoBarService* infobar_service,
17 const GURL& alternate_nav_url) {
18 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
19 new AlternateNavInfoBarDelegate(infobar_service, alternate_nav_url)));
22 AlternateNavInfoBarDelegate::AlternateNavInfoBarDelegate(
23 InfoBarService* owner,
24 const GURL& alternate_nav_url)
25 : InfoBarDelegate(owner),
26 alternate_nav_url_(alternate_nav_url) {
29 AlternateNavInfoBarDelegate::~AlternateNavInfoBarDelegate() {
32 string16 AlternateNavInfoBarDelegate::GetMessageTextWithOffset(
33 size_t* link_offset) const {
34 const string16 label = l10n_util::GetStringFUTF16(
35 IDS_ALTERNATE_NAV_URL_VIEW_LABEL, string16(), link_offset);
36 return label;
39 string16 AlternateNavInfoBarDelegate::GetLinkText() const {
40 return UTF8ToUTF16(alternate_nav_url_.spec());
43 bool AlternateNavInfoBarDelegate::LinkClicked(
44 WindowOpenDisposition disposition) {
45 // Pretend the user typed this URL, so that navigating to it will be the
46 // default action when it's typed again in the future.
47 web_contents()->OpenURL(content::OpenURLParams(
48 alternate_nav_url_, content::Referrer(), disposition,
49 content::PAGE_TRANSITION_TYPED, false));
51 // We should always close, even if the navigation did not occur within this
52 // WebContents.
53 return true;
56 int AlternateNavInfoBarDelegate::GetIconID() const {
57 return IDR_INFOBAR_ALT_NAV_URL;
60 InfoBarDelegate::Type AlternateNavInfoBarDelegate::GetInfoBarType() const {
61 return PAGE_ACTION_TYPE;