Chromium Code Reviews| Index: chrome/browser/android/search_geolocation_disclosure_infobar_delegate.cc |
| diff --git a/chrome/browser/android/search_geolocation_disclosure_infobar_delegate.cc b/chrome/browser/android/search_geolocation_disclosure_infobar_delegate.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ac8b1f815063dc7585e4808d8b41bd8992db77ab |
| --- /dev/null |
| +++ b/chrome/browser/android/search_geolocation_disclosure_infobar_delegate.cc |
| @@ -0,0 +1,58 @@ |
| +// Copyright 2016 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/android/search_geolocation_disclosure_infobar_delegate.h" |
| + |
| +#include "base/memory/ptr_util.h" |
| +#include "chrome/browser/android/android_theme_resources.h" |
| +#include "chrome/browser/infobars/infobar_service.h" |
| +#include "chrome/browser/ui/android/infobars/search_geolocation_disclosure_infobar.h" |
| +#include "chrome/grit/generated_resources.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| + |
| +SearchGeolocationDisclosureInfoBarDelegate:: |
| + ~SearchGeolocationDisclosureInfoBarDelegate() {} |
| + |
| +base::string16 SearchGeolocationDisclosureInfoBarDelegate::GetMessageText() |
| + const { |
| + return l10n_util::GetStringUTF16( |
| + IDS_SEARCH_GEOLOCATION_DISCLOSURE_INFOBAR_TEXT); |
| +}; |
| + |
| +// static |
| +void SearchGeolocationDisclosureInfoBarDelegate::Create( |
| + content::WebContents* web_contents) { |
| + InfoBarService* infobar_service = |
| + InfoBarService::FromWebContents(web_contents); |
| + // Add the new delegate. |
| + std::unique_ptr<infobars::InfoBar> infobar( |
|
Peter Kasting
2016/11/08 01:17:51
Nit: Prefer base::MakeUnique() to bare new:
aut
benwells
2016/11/08 02:53:40
Done.
|
| + new SearchGeolocationDisclosureInfoBar( |
| + base::WrapUnique(new SearchGeolocationDisclosureInfoBarDelegate()))); |
| + infobar_service->AddInfoBar(std::move(infobar)); |
| +} |
| + |
| +SearchGeolocationDisclosureInfoBarDelegate:: |
| + SearchGeolocationDisclosureInfoBarDelegate() |
| + : infobars::InfoBarDelegate() {} |
| + |
| +infobars::InfoBarDelegate::Type |
| +SearchGeolocationDisclosureInfoBarDelegate::GetInfoBarType() const { |
| + return PAGE_ACTION_TYPE; |
| +} |
| + |
| +infobars::InfoBarDelegate::InfoBarIdentifier |
| +SearchGeolocationDisclosureInfoBarDelegate::GetIdentifier() const { |
| + return SEARCH_GEOLOCATION_DISCLOSURE_INFOBAR_DELEGATE; |
| +} |
| + |
| +int SearchGeolocationDisclosureInfoBarDelegate::GetIconId() const { |
| + return IDR_ANDROID_INFOBAR_GEOLOCATION; |
| +} |
| + |
| +SearchGeolocationDisclosureInfoBarDelegate* |
| +SearchGeolocationDisclosureInfoBarDelegate:: |
| + AsSearchGeolocationDisclosureInfoBarDelegate() { |
| + return this; |
| +} |