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 |
deleted file mode 100644 |
index 8f031c45eee8a5c512ff6773c2dcdada8eb10e5f..0000000000000000000000000000000000000000 |
--- a/chrome/browser/android/search_geolocation_disclosure_infobar_delegate.cc |
+++ /dev/null |
@@ -1,126 +0,0 @@ |
-// 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 "base/metrics/histogram_macros.h" |
-#include "chrome/browser/android/android_theme_resources.h" |
-#include "chrome/browser/infobars/infobar_service.h" |
-#include "chrome/browser/profiles/profile.h" |
-#include "chrome/browser/ui/android/infobars/search_geolocation_disclosure_infobar.h" |
-#include "chrome/common/chrome_features.h" |
-#include "chrome/common/pref_names.h" |
-#include "chrome/grit/generated_resources.h" |
-#include "components/prefs/pref_service.h" |
-#include "components/variations/variations_associated_data.h" |
-#include "content/public/browser/web_contents.h" |
-#include "ui/base/l10n/l10n_util.h" |
- |
-namespace { |
- |
-const char kUseControlTextVariation[] = "UseControlText"; |
- |
-int ShouldUseControlText() { |
- std::string variation = variations::GetVariationParamValueByFeature( |
- features::kConsistentOmniboxGeolocation, kUseControlTextVariation); |
- return !variation.empty(); |
-} |
- |
-} // namespace |
- |
-// This enum is used in histograms, and is thus append only. Do not remove or |
-// re-order items. |
-enum class SearchGeolocationDisclosureInfoBarDelegate::DisclosureResult { |
- IGNORED = 0, |
- SETTINGS_CLICKED, |
- DISMISSED, |
- COUNT, |
-}; |
- |
-SearchGeolocationDisclosureInfoBarDelegate:: |
- ~SearchGeolocationDisclosureInfoBarDelegate() { |
- UMA_HISTOGRAM_ENUMERATION( |
- "GeolocationDisclosure.DisclosureResult", |
- static_cast<base::HistogramBase::Sample>(result_), |
- static_cast<base::HistogramBase::Sample>(DisclosureResult::COUNT)); |
- UMA_HISTOGRAM_MEDIUM_TIMES("GeolocationDisclosure.InfoBarVisibleTime", |
- base::Time::Now() - creation_time_); |
-} |
- |
-// static |
-void SearchGeolocationDisclosureInfoBarDelegate::Create( |
- content::WebContents* web_contents, |
- const GURL& search_url) { |
- InfoBarService* infobar_service = |
- InfoBarService::FromWebContents(web_contents); |
- // Add the new delegate. |
- infobar_service->AddInfoBar( |
- base::MakeUnique<SearchGeolocationDisclosureInfoBar>( |
- base::WrapUnique(new SearchGeolocationDisclosureInfoBarDelegate( |
- web_contents, search_url)))); |
-} |
- |
-// static |
-bool SearchGeolocationDisclosureInfoBarDelegate:: |
- IsSearchGeolocationDisclosureOpen(content::WebContents* web_contents) { |
- InfoBarService* infobar_service = |
- InfoBarService::FromWebContents(web_contents); |
- for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { |
- infobars::InfoBar* existing_infobar = infobar_service->infobar_at(i); |
- if (existing_infobar->delegate()->GetIdentifier() == |
- infobars::InfoBarDelegate:: |
- SEARCH_GEOLOCATION_DISCLOSURE_INFOBAR_DELEGATE) { |
- return true; |
- } |
- } |
- |
- return false; |
-} |
- |
-void SearchGeolocationDisclosureInfoBarDelegate::RecordSettingsClicked() { |
- result_ = DisclosureResult::SETTINGS_CLICKED; |
- // This counts as a dismissed so the dialog isn't shown again. |
- pref_service_->SetBoolean(prefs::kSearchGeolocationDisclosureDismissed, true); |
-} |
- |
-SearchGeolocationDisclosureInfoBarDelegate:: |
- SearchGeolocationDisclosureInfoBarDelegate( |
- content::WebContents* web_contents, |
- const GURL& search_url) |
- : infobars::InfoBarDelegate(), |
- search_url_(search_url), |
- result_(DisclosureResult::IGNORED), |
- creation_time_(base::Time::Now()) { |
- pref_service_ = Profile::FromBrowserContext(web_contents->GetBrowserContext()) |
- ->GetPrefs(); |
- base::string16 link = l10n_util::GetStringUTF16( |
- IDS_SEARCH_GEOLOCATION_DISCLOSURE_INFOBAR_SETTINGS_LINK_TEXT); |
- size_t offset; |
- message_text_ = l10n_util::GetStringFUTF16( |
- ShouldUseControlText() |
- ? IDS_SEARCH_GEOLOCATION_DISCLOSURE_INFOBAR_CONTROL_TEXT |
- : IDS_SEARCH_GEOLOCATION_DISCLOSURE_INFOBAR_TEXT, |
- link, &offset); |
- inline_link_range_ = gfx::Range(offset, offset + link.length()); |
-} |
- |
-void SearchGeolocationDisclosureInfoBarDelegate::InfoBarDismissed() { |
- result_ = DisclosureResult::DISMISSED; |
- pref_service_->SetBoolean(prefs::kSearchGeolocationDisclosureDismissed, true); |
-} |
- |
-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; |
-} |