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

Side by Side Diff: chrome/browser/geolocation/geolocation_infobar_queue_controller.h

Issue 11183018: Refactor ChromeGeolocationPermissionContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updates from comments Created 8 years, 2 months 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 #ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_INFOBAR_QUEUE_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_INFOBAR_QUEUE_CONTROLLER_H_
6 #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_INFOBAR_QUEUE_CONTROLLER_H_ 6 #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_INFOBAR_QUEUE_CONTROLLER_H_
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "content/public/browser/notification_observer.h" 9 #include "content/public/browser/notification_observer.h"
10 #include "content/public/browser/notification_registrar.h" 10 #include "content/public/browser/notification_registrar.h"
11 11
12 class GURL; 12 class GURL;
13 class GeolocationConfirmInfoBarDelegate;
13 class InfoBarTabHelper; 14 class InfoBarTabHelper;
14 class Profile; 15 class Profile;
15 16
16 // This class controls the geolocation infobar queue per profile, and it's 17 // This class controls the geolocation infobar queue per profile, and it's
17 // used by GeolocationPermissionContext. 18 // used by GeolocationPermissionContext.
18 // An alternate approach would be to have this queue per tab, and use 19 // An alternate approach would be to have this queue per tab, and use
19 // notifications to broadcast when permission is set / listen to notification to 20 // notifications to broadcast when permission is set / listen to notification to
20 // cancel pending requests. This may be specially useful if there are other 21 // cancel pending requests. This may be specially useful if there are other
21 // things listening for such notifications. 22 // things listening for such notifications.
22 // For the time being this class is self-contained and it doesn't seem pulling 23 // For the time being this class is self-contained and it doesn't seem pulling
23 // the notification infrastructure would simplify. 24 // the notification infrastructure would simplify.
24 class GeolocationInfoBarQueueController : content::NotificationObserver { 25 class GeolocationInfoBarQueueController : content::NotificationObserver {
25 public: 26 public:
26 typedef base::Callback<void(int /* render_process_id */, 27 typedef base::Callback<void(bool /* allowed */)> PermissionDecidedCallback;
27 int /* render_view_id */,
28 int /* bridge_id */,
29 const GURL& /* requesting_frame */,
30 base::Callback<void(bool)> /* callback */,
31 bool /* allowed */)> NotifyPermissionSetCallback;
32 28
33 GeolocationInfoBarQueueController( 29 explicit GeolocationInfoBarQueueController(Profile* profile);
34 NotifyPermissionSetCallback notify_permission_set_callback,
35 Profile* profile);
36 virtual ~GeolocationInfoBarQueueController(); 30 virtual ~GeolocationInfoBarQueueController();
37 31
38 // The InfoBar will be displayed immediately if the tab is not already 32 // The InfoBar will be displayed immediately if the tab is not already
39 // displaying one, otherwise it'll be queued. 33 // displaying one, otherwise it'll be queued.
40 void CreateInfoBarRequest(int render_process_id, 34 void CreateInfoBarRequest(int render_process_id,
41 int render_view_id, 35 int render_view_id,
42 int bridge_id, 36 int bridge_id,
43 const GURL& requesting_frame, 37 const GURL& requesting_frame,
44 const GURL& emebedder, 38 const GURL& embedder,
45 base::Callback<void(bool)> callback); 39 PermissionDecidedCallback callback);
46 40
47 // Cancels a specific infobar request. 41 // Cancels a specific infobar request.
48 void CancelInfoBarRequest(int render_process_id, 42 void CancelInfoBarRequest(int render_process_id,
49 int render_view_id, 43 int render_view_id,
50 int bridge_id); 44 int bridge_id);
51 45
52 // Called by the InfoBarDelegate to notify permission has been set. 46 // Called by the InfoBarDelegate to notify permission has been set.
53 // It'll notify and dismiss any other pending InfoBar request for the same 47 // It'll notify and dismiss any other pending InfoBar request for the same
54 // |requesting_frame| and embedder. 48 // |requesting_frame| and embedder.
55 void OnPermissionSet(int render_process_id, 49 void OnPermissionSet(int render_process_id,
56 int render_view_id, 50 int render_view_id,
57 int bridge_id, 51 int bridge_id,
58 const GURL& requesting_frame, 52 const GURL& requesting_frame,
59 const GURL& embedder, 53 const GURL& embedder,
54 bool update_content_setting,
60 bool allowed); 55 bool allowed);
61 56
62 // content::NotificationObserver 57 // content::NotificationObserver
63 virtual void Observe(int type, 58 virtual void Observe(int type,
64 const content::NotificationSource& source, 59 const content::NotificationSource& source,
65 const content::NotificationDetails& details) OVERRIDE; 60 const content::NotificationDetails& details) OVERRIDE;
66 61
62 protected:
63 // Create an Infobar delegate to ask the whether the requesting frame
64 // url should be granted geolocation permission. Overrided in
65 // derived classes to implement alternative UI.
66 virtual GeolocationConfirmInfoBarDelegate* CreateInfoBarDelegate(
67 InfoBarTabHelper* infobar_helper,
68 GeolocationInfoBarQueueController* controller,
69 int render_process_id,
70 int render_view_id,
71 int bridge_id,
72 const GURL& requesting_frame_url,
73 const std::string& display_languages);
74
67 private: 75 private:
68 struct PendingInfoBarRequest; 76 struct PendingInfoBarRequest;
69 class RequestEquals; 77 class RequestEquals;
70 78
71 typedef std::vector<PendingInfoBarRequest> PendingInfoBarRequests; 79 typedef std::vector<PendingInfoBarRequest> PendingInfoBarRequests;
72 80
73 // Shows the first pending infobar for this tab, if any. 81 // Shows the first pending infobar for this tab, if any.
74 void ShowQueuedInfoBar(int render_process_id, int render_view_id, 82 void ShowQueuedInfoBar(int render_process_id, int render_view_id,
75 InfoBarTabHelper* helper); 83 InfoBarTabHelper* helper);
76 84
77 // Removes any pending requests for a given tab. 85 // Removes any pending requests for a given tab.
78 void ClearPendingInfoBarRequestsForTab(int render_process_id, 86 void ClearPendingInfoBarRequestsForTab(int render_process_id,
79 int render_view_id); 87 int render_view_id);
80 88
81 InfoBarTabHelper* GetInfoBarHelper(int render_process_id, int render_view_id); 89 InfoBarTabHelper* GetInfoBarHelper(int render_process_id, int render_view_id);
82 bool AlreadyShowingInfoBar(int render_process_id, int render_view_id); 90 bool AlreadyShowingInfoBar(int render_process_id, int render_view_id);
83 91
84 void RegisterForInfoBarNotifications(InfoBarTabHelper* helper); 92 void RegisterForInfoBarNotifications(InfoBarTabHelper* helper);
85 void UnregisterForInfoBarNotifications(InfoBarTabHelper* helper); 93 void UnregisterForInfoBarNotifications(InfoBarTabHelper* helper);
86 94
87 content::NotificationRegistrar registrar_; 95 content::NotificationRegistrar registrar_;
88 96
89 NotifyPermissionSetCallback notify_permission_set_callback_;
90 Profile* const profile_; 97 Profile* const profile_;
91 PendingInfoBarRequests pending_infobar_requests_; 98 PendingInfoBarRequests pending_infobar_requests_;
92 }; 99 };
93 100
94 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_INFOBAR_QUEUE_CONTROLLER_H_ 101 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_INFOBAR_QUEUE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698