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.
4 
5 #include "chrome/browser/ui/page_info/page_info_infobar_delegate.h"
6 
7 #include "base/check_op.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "build/build_config.h"
10 #include "chrome/browser/infobars/infobar_service.h"
11 #include "components/infobars/core/infobar.h"
12 #include "components/strings/grit/components_strings.h"
13 #include "components/vector_icons/vector_icons.h"
14 #include "content/public/browser/web_contents.h"
15 #include "ui/base/l10n/l10n_util.h"
16 
17 // static
Create(InfoBarService * infobar_service)18 void PageInfoInfoBarDelegate::Create(InfoBarService* infobar_service) {
19   infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
20       std::unique_ptr<ConfirmInfoBarDelegate>(new PageInfoInfoBarDelegate())));
21 }
22 
PageInfoInfoBarDelegate()23 PageInfoInfoBarDelegate::PageInfoInfoBarDelegate() : ConfirmInfoBarDelegate() {}
24 
~PageInfoInfoBarDelegate()25 PageInfoInfoBarDelegate::~PageInfoInfoBarDelegate() {}
26 
27 infobars::InfoBarDelegate::InfoBarIdentifier
GetIdentifier() const28 PageInfoInfoBarDelegate::GetIdentifier() const {
29   return PAGE_INFO_INFOBAR_DELEGATE;
30 }
31 
GetVectorIcon() const32 const gfx::VectorIcon& PageInfoInfoBarDelegate::GetVectorIcon() const {
33   return vector_icons::kSettingsIcon;
34 }
35 
GetMessageText() const36 base::string16 PageInfoInfoBarDelegate::GetMessageText() const {
37   return l10n_util::GetStringUTF16(IDS_PAGE_INFO_INFOBAR_TEXT);
38 }
39 
GetButtons() const40 int PageInfoInfoBarDelegate::GetButtons() const {
41   return BUTTON_OK;
42 }
43 
GetButtonLabel(InfoBarButton button) const44 base::string16 PageInfoInfoBarDelegate::GetButtonLabel(
45     InfoBarButton button) const {
46   DCHECK_EQ(BUTTON_OK, button);
47   return l10n_util::GetStringUTF16(IDS_PAGE_INFO_INFOBAR_BUTTON);
48 }
49 
Accept()50 bool PageInfoInfoBarDelegate::Accept() {
51   content::WebContents* web_contents =
52       InfoBarService::WebContentsFromInfoBar(infobar());
53   web_contents->GetController().Reload(content::ReloadType::NORMAL, true);
54   return true;
55 }
56