Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / geolocation / geolocation_infobar_delegate.cc
blob497b87f7cc2e5c0afde72281484f37d02e373cb9
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/geolocation/geolocation_infobar_delegate.h"
7 #include "chrome/browser/infobars/infobar_service.h"
8 #include "chrome/grit/generated_resources.h"
9 #include "components/infobars/core/infobar.h"
10 #include "components/url_formatter/url_formatter.h"
11 #include "grit/generated_resources.h"
12 #include "grit/theme_resources.h"
13 #include "ui/base/l10n/l10n_util.h"
15 // static
16 infobars::InfoBar* GeolocationInfoBarDelegate::Create(
17 InfoBarService* infobar_service,
18 const GURL& requesting_frame,
19 const std::string& display_languages,
20 const PermissionSetCallback& callback) {
21 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
22 scoped_ptr<ConfirmInfoBarDelegate>(new GeolocationInfoBarDelegate(
23 requesting_frame, display_languages, callback))));
26 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate(
27 const GURL& requesting_frame,
28 const std::string& display_languages,
29 const PermissionSetCallback& callback)
30 : PermissionInfobarDelegate(requesting_frame,
31 CONTENT_SETTINGS_TYPE_GEOLOCATION,
32 callback),
33 requesting_frame_(requesting_frame),
34 display_languages_(display_languages) {
37 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() {
40 int GeolocationInfoBarDelegate::GetIconId() const {
41 return IDR_INFOBAR_GEOLOCATION;
44 base::string16 GeolocationInfoBarDelegate::GetMessageText() const {
45 return l10n_util::GetStringFUTF16(
46 IDS_GEOLOCATION_INFOBAR_QUESTION,
47 url_formatter::FormatUrl(
48 requesting_frame_, display_languages_,
49 url_formatter::kFormatUrlOmitUsernamePassword |
50 url_formatter::kFormatUrlOmitTrailingSlashOnBareHostname,
51 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr));