Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: chrome/browser/android/search_geolocation_disclosure_infobar_delegate.cc

Issue 2482023002: Put a Settings link on the new Google Search geolocation disclosure. (Closed)
Patch Set: Update comment Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/search_geolocation_disclosure_infobar_delegate. h" 5 #include "chrome/browser/android/search_geolocation_disclosure_infobar_delegate. h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/android/android_theme_resources.h" 8 #include "chrome/browser/android/android_theme_resources.h"
9 #include "chrome/browser/infobars/infobar_service.h" 9 #include "chrome/browser/infobars/infobar_service.h"
10 #include "chrome/browser/ui/android/infobars/search_geolocation_disclosure_infob ar.h" 10 #include "chrome/browser/ui/android/infobars/search_geolocation_disclosure_infob ar.h"
11 #include "chrome/grit/generated_resources.h" 11 #include "chrome/grit/generated_resources.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 14
15 SearchGeolocationDisclosureInfoBarDelegate:: 15 SearchGeolocationDisclosureInfoBarDelegate::
16 ~SearchGeolocationDisclosureInfoBarDelegate() {} 16 ~SearchGeolocationDisclosureInfoBarDelegate() {}
17 17
18 // static 18 // static
19 void SearchGeolocationDisclosureInfoBarDelegate::Create( 19 void SearchGeolocationDisclosureInfoBarDelegate::Create(
20 content::WebContents* web_contents) { 20 content::WebContents* web_contents, const GURL& search_url) {
21 InfoBarService* infobar_service = 21 InfoBarService* infobar_service =
22 InfoBarService::FromWebContents(web_contents); 22 InfoBarService::FromWebContents(web_contents);
23 // Add the new delegate. 23 // Add the new delegate.
24 infobar_service->AddInfoBar( 24 infobar_service->AddInfoBar(
25 base::MakeUnique<SearchGeolocationDisclosureInfoBar>( 25 base::MakeUnique<SearchGeolocationDisclosureInfoBar>(base::WrapUnique(
26 base::WrapUnique(new SearchGeolocationDisclosureInfoBarDelegate()))); 26 new SearchGeolocationDisclosureInfoBarDelegate(search_url))));
27 } 27 }
28 28
29 base::string16 SearchGeolocationDisclosureInfoBarDelegate::GetMessageText()
30 const {
31 return l10n_util::GetStringUTF16(
32 IDS_SEARCH_GEOLOCATION_DISCLOSURE_INFOBAR_TEXT);
33 };
34
35 SearchGeolocationDisclosureInfoBarDelegate:: 29 SearchGeolocationDisclosureInfoBarDelegate::
36 SearchGeolocationDisclosureInfoBarDelegate() 30 SearchGeolocationDisclosureInfoBarDelegate(const GURL& search_url)
37 : infobars::InfoBarDelegate() {} 31 : infobars::InfoBarDelegate(),
32 search_url_(search_url) {
33 base::string16 link = l10n_util::GetStringUTF16(
34 IDS_SEARCH_GEOLOCATION_DISCLOSURE_INFOBAR_SETTINGS_LINK_TEXT);
35 size_t offset;
36 message_text_ = l10n_util::GetStringFUTF16(
37 IDS_SEARCH_GEOLOCATION_DISCLOSURE_INFOBAR_TEXT, link, &offset);
38 inline_link_range_ = gfx::Range(offset, offset + link.length());
39 }
38 40
39 infobars::InfoBarDelegate::Type 41 infobars::InfoBarDelegate::Type
40 SearchGeolocationDisclosureInfoBarDelegate::GetInfoBarType() const { 42 SearchGeolocationDisclosureInfoBarDelegate::GetInfoBarType() const {
41 return PAGE_ACTION_TYPE; 43 return PAGE_ACTION_TYPE;
42 } 44 }
43 45
44 infobars::InfoBarDelegate::InfoBarIdentifier 46 infobars::InfoBarDelegate::InfoBarIdentifier
45 SearchGeolocationDisclosureInfoBarDelegate::GetIdentifier() const { 47 SearchGeolocationDisclosureInfoBarDelegate::GetIdentifier() const {
46 return SEARCH_GEOLOCATION_DISCLOSURE_INFOBAR_DELEGATE; 48 return SEARCH_GEOLOCATION_DISCLOSURE_INFOBAR_DELEGATE;
47 } 49 }
48 50
49 int SearchGeolocationDisclosureInfoBarDelegate::GetIconId() const { 51 int SearchGeolocationDisclosureInfoBarDelegate::GetIconId() const {
50 return IDR_ANDROID_INFOBAR_GEOLOCATION; 52 return IDR_ANDROID_INFOBAR_GEOLOCATION;
51 } 53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698