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

Side by Side Diff: chrome/browser/geolocation/geolocation_infobar_delegate.cc

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/geolocation/geolocation_infobar_delegate.h" 5 #include "chrome/browser/geolocation/geolocation_infobar_delegate.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "chrome/browser/content_settings/permission_queue_controller.h" 8 #include "chrome/browser/content_settings/permission_queue_controller.h"
9 #include "chrome/browser/google/google_util.h" 9 #include "chrome/browser/google/google_util.h"
10 #include "chrome/browser/infobars/infobar.h"
10 #include "chrome/browser/infobars/infobar_service.h" 11 #include "chrome/browser/infobars/infobar_service.h"
11 #include "content/public/browser/navigation_details.h" 12 #include "content/public/browser/navigation_details.h"
12 #include "content/public/browser/navigation_entry.h" 13 #include "content/public/browser/navigation_entry.h"
13 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
14 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
15 #include "grit/locale_settings.h" 16 #include "grit/locale_settings.h"
16 #include "grit/theme_resources.h" 17 #include "grit/theme_resources.h"
17 #include "net/base/net_util.h" 18 #include "net/base/net_util.h"
18 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
19 20
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 }; 55 };
55 56
56 void RecordUmaEvent(GeolocationInfoBarDelegateEvent event) { 57 void RecordUmaEvent(GeolocationInfoBarDelegateEvent event) {
57 UMA_HISTOGRAM_ENUMERATION("Geolocation.InfoBarDelegate.Event", 58 UMA_HISTOGRAM_ENUMERATION("Geolocation.InfoBarDelegate.Event",
58 event, GEOLOCATION_INFO_BAR_DELEGATE_EVENT_COUNT); 59 event, GEOLOCATION_INFO_BAR_DELEGATE_EVENT_COUNT);
59 } 60 }
60 61
61 } // namespace 62 } // namespace
62 63
63 // static 64 // static
64 InfoBarDelegate* GeolocationInfoBarDelegate::Create( 65 InfoBar* GeolocationInfoBarDelegate::Create(
65 InfoBarService* infobar_service, 66 InfoBarService* infobar_service,
66 PermissionQueueController* controller, 67 PermissionQueueController* controller,
67 const PermissionRequestID& id, 68 const PermissionRequestID& id,
68 const GURL& requesting_frame, 69 const GURL& requesting_frame,
69 const std::string& display_languages) { 70 const std::string& display_languages) {
70 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_CREATE); 71 RecordUmaEvent(GEOLOCATION_INFO_BAR_DELEGATE_EVENT_CREATE);
71 const content::NavigationEntry* committed_entry = 72 const content::NavigationEntry* committed_entry =
72 infobar_service->web_contents()->GetController().GetLastCommittedEntry(); 73 infobar_service->web_contents()->GetController().GetLastCommittedEntry();
73 return infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( 74 return infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
74 new DelegateType(infobar_service, controller, id, requesting_frame, 75 scoped_ptr<ConfirmInfoBarDelegate>(new DelegateType(
75 committed_entry ? committed_entry->GetUniqueID() : 0, 76 controller, id, requesting_frame,
76 display_languages))); 77 committed_entry ? committed_entry->GetUniqueID() : 0,
78 display_languages))));
77 } 79 }
78 80
79 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate( 81 GeolocationInfoBarDelegate::GeolocationInfoBarDelegate(
80 InfoBarService* infobar_service,
81 PermissionQueueController* controller, 82 PermissionQueueController* controller,
82 const PermissionRequestID& id, 83 const PermissionRequestID& id,
83 const GURL& requesting_frame, 84 const GURL& requesting_frame,
84 int contents_unique_id, 85 int contents_unique_id,
85 const std::string& display_languages) 86 const std::string& display_languages)
86 : ConfirmInfoBarDelegate(infobar_service), 87 : ConfirmInfoBarDelegate(),
87 controller_(controller), 88 controller_(controller),
88 id_(id), 89 id_(id),
89 requesting_frame_(requesting_frame.GetOrigin()), 90 requesting_frame_(requesting_frame.GetOrigin()),
90 contents_unique_id_(contents_unique_id), 91 contents_unique_id_(contents_unique_id),
91 display_languages_(display_languages), 92 display_languages_(display_languages),
92 user_has_interacted_(false) { 93 user_has_interacted_(false) {
93 } 94 }
94 95
95 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() { 96 GeolocationInfoBarDelegate::~GeolocationInfoBarDelegate() {
96 if (!user_has_interacted_) 97 if (!user_has_interacted_)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 "https://www.google.com/support/chrome/bin/answer.py?answer=142065"; 172 "https://www.google.com/support/chrome/bin/answer.py?answer=142065";
172 #endif 173 #endif
173 174
174 web_contents()->OpenURL(content::OpenURLParams( 175 web_contents()->OpenURL(content::OpenURLParams(
175 google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)), 176 google_util::AppendGoogleLocaleParam(GURL(kGeolocationLearnMoreUrl)),
176 content::Referrer(), 177 content::Referrer(),
177 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, 178 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
178 content::PAGE_TRANSITION_LINK, false)); 179 content::PAGE_TRANSITION_LINK, false));
179 return false; // Do not dismiss the info bar. 180 return false; // Do not dismiss the info bar.
180 } 181 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698