Make castv2 performance test work.
[chromium-blink-merge.git] / chrome / browser / geolocation / geolocation_infobar_delegate.cc
blobb69acf0cab7d70baee6a3ee3179aa34b1921bf77
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 "base/metrics/histogram.h"
8 #include "chrome/browser/content_settings/permission_queue_controller.h"
9 #include "chrome/browser/infobars/infobar_service.h"
10 #include "chrome/grit/generated_resources.h"
11 #include "chrome/grit/locale_settings.h"
12 #include "components/google/core/browser/google_util.h"
13 #include "components/infobars/core/infobar.h"
14 #include "content/public/browser/navigation_details.h"
15 #include "content/public/browser/navigation_entry.h"
16 #include "content/public/browser/web_contents.h"
17 #include "grit/generated_resources.h"
18 #include "grit/locale_settings.h"
19 #include "grit/theme_resources.h"
20 #include "net/base/net_util.h"
21 #include "ui/base/l10n/l10n_util.h"
24 // static
25 infobars::InfoBar* GeolocationInfoBarDelegate::Create(
26 InfoBarService* infobar_service,
27 PermissionQueueController* controller,
28 const PermissionRequestID& id,
29 const GURL& requesting_frame,
30 const std::string& display_languages) {
31 const content::NavigationEntry* committed_entry =
32 infobar_service->web_contents()->GetController().GetLastCommittedEntry();
33 GeolocationInfoBarDelegate* const delegate = new GeolocationInfoBarDelegate(
34 controller, id, requesting_frame,
35 committed_entry ? committed_entry->GetUniqueID() : 0,
36 display_languages);
38 return infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
39 scoped_ptr<ConfirmInfoBarDelegate>(delegate)));
42 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate(
43 PermissionQueueController* controller,
44 const PermissionRequestID& id,
45 const GURL& requesting_frame,
46 int contents_unique_id,
47 const std::string& display_languages)
48 : PermissionInfobarDelegate(controller, id, requesting_frame,
49 CONTENT_SETTINGS_TYPE_GEOLOCATION),
50 requesting_frame_(requesting_frame),
51 display_languages_(display_languages) {
54 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() {
57 int GeolocationInfoBarDelegate::GetIconID() const {
58 return IDR_INFOBAR_GEOLOCATION;
61 base::string16 GeolocationInfoBarDelegate::GetMessageText() const {
62 return l10n_util::GetStringFUTF16(IDS_GEOLOCATION_INFOBAR_QUESTION,
63 net::FormatUrl(requesting_frame_, display_languages_,
64 net::kFormatUrlOmitUsernamePassword |
65 net::kFormatUrlOmitTrailingSlashOnBareHostname,
66 net::UnescapeRule::SPACES, NULL, NULL, NULL));