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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/website_settings/website_settings_infobar_delegate.h"
7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/infobars/infobar_service.h"
10 #include "chrome/grit/generated_resources.h"
11 #include "components/infobars/core/infobar.h"
12 #include "content/public/browser/web_contents.h"
13 #include "grit/theme_resources.h"
14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/gfx/vector_icons_public.h"
18 void WebsiteSettingsInfoBarDelegate::Create(InfoBarService
* infobar_service
) {
19 infobar_service
->AddInfoBar(
20 infobar_service
->CreateConfirmInfoBar(scoped_ptr
<ConfirmInfoBarDelegate
>(
21 new WebsiteSettingsInfoBarDelegate())));
24 WebsiteSettingsInfoBarDelegate::WebsiteSettingsInfoBarDelegate()
25 : ConfirmInfoBarDelegate() {
28 WebsiteSettingsInfoBarDelegate::~WebsiteSettingsInfoBarDelegate() {
31 infobars::InfoBarDelegate::Type
32 WebsiteSettingsInfoBarDelegate::GetInfoBarType() const {
33 return PAGE_ACTION_TYPE
;
36 int WebsiteSettingsInfoBarDelegate::GetIconId() const {
37 return IDR_INFOBAR_ALT_NAV_URL
;
40 gfx::VectorIconId
WebsiteSettingsInfoBarDelegate::GetVectorIconId() const {
41 #if defined(OS_MACOSX)
42 return gfx::VectorIconId::VECTOR_ICON_NONE
;
44 return gfx::VectorIconId::GLOBE
;
48 base::string16
WebsiteSettingsInfoBarDelegate::GetMessageText() const {
49 return l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_INFOBAR_TEXT
);
52 int WebsiteSettingsInfoBarDelegate::GetButtons() const {
56 base::string16
WebsiteSettingsInfoBarDelegate::GetButtonLabel(
57 InfoBarButton button
) const {
58 DCHECK_EQ(BUTTON_OK
, button
);
59 return l10n_util::GetStringUTF16(IDS_WEBSITE_SETTINGS_INFOBAR_BUTTON
);
62 bool WebsiteSettingsInfoBarDelegate::Accept() {
63 content::WebContents
* web_contents
=
64 InfoBarService::WebContentsFromInfoBar(infobar());
65 web_contents
->GetController().Reload(true);