blob: 0c19470d1d4517b9ed126d15f212cff1ffeac17e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/api/infobars/infobar_service.h"
#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
// static
void AlternateNavInfoBarDelegate::Create(InfoBarService* infobar_service,
const GURL& alternate_nav_url) {
infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
new AlternateNavInfoBarDelegate(infobar_service, alternate_nav_url)));
}
AlternateNavInfoBarDelegate::AlternateNavInfoBarDelegate(
InfoBarService* owner,
const GURL& alternate_nav_url)
: InfoBarDelegate(owner),
alternate_nav_url_(alternate_nav_url) {
}
AlternateNavInfoBarDelegate::~AlternateNavInfoBarDelegate() {
}
string16 AlternateNavInfoBarDelegate::GetMessageTextWithOffset(
size_t* link_offset) const {
const string16 label = l10n_util::GetStringFUTF16(
IDS_ALTERNATE_NAV_URL_VIEW_LABEL, string16(), link_offset);
return label;
}
string16 AlternateNavInfoBarDelegate::GetLinkText() const {
return UTF8ToUTF16(alternate_nav_url_.spec());
}
bool AlternateNavInfoBarDelegate::LinkClicked(
WindowOpenDisposition disposition) {
content::OpenURLParams params(
alternate_nav_url_, content::Referrer(), disposition,
// Pretend the user typed this URL, so that navigating to
// it will be the default action when it's typed again in
// the future.
content::PAGE_TRANSITION_TYPED,
false);
owner()->GetWebContents()->OpenURL(params);
// We should always close, even if the navigation did not occur within this
// WebContents.
return true;
}
gfx::Image* AlternateNavInfoBarDelegate::GetIcon() const {
return &ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
IDR_INFOBAR_ALT_NAV_URL);
}
InfoBarDelegate::Type AlternateNavInfoBarDelegate::GetInfoBarType() const {
return PAGE_ACTION_TYPE;
}
|