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

Side by Side Diff: chrome/browser/ui/website_settings/permission_bubble_manager.h

Issue 243543003: [WebsiteSettings] Update permission bubble manager policy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: weak ptr Created 6 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_
6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/timer/timer.h" 10 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/ui/website_settings/permission_bubble_view.h" 11 #include "chrome/browser/ui/website_settings/permission_bubble_view.h"
12 #include "content/public/browser/web_contents_observer.h" 12 #include "content/public/browser/web_contents_observer.h"
13 #include "content/public/browser/web_contents_user_data.h" 13 #include "content/public/browser/web_contents_user_data.h"
14 14
15 class PermissionBubbleRequest; 15 class PermissionBubbleRequest;
16 16
17 // Provides access to permissions bubbles. Allows clients to add a request 17 // Provides access to permissions bubbles. Allows clients to add a request
18 // callback interface to the existing permission bubble configuration. 18 // callback interface to the existing permission bubble configuration.
19 // Depending on the situation and policy, that may add new UI to an existing 19 // Depending on the situation and policy, that may add new UI to an existing
20 // permission bubble, create and show a new permission bubble, or provide no 20 // permission bubble, create and show a new permission bubble, or provide no
(...skipping 28 matching lines...) Expand all
49 // shown, but the user's action won't be reported back to the request object. 49 // shown, but the user's action won't be reported back to the request object.
50 // In some circumstances, we can remove the request from the bubble, and may 50 // In some circumstances, we can remove the request from the bubble, and may
51 // do so. The caller may delete the request after calling this method. 51 // do so. The caller may delete the request after calling this method.
52 virtual void CancelRequest(PermissionBubbleRequest* request); 52 virtual void CancelRequest(PermissionBubbleRequest* request);
53 53
54 // Sets the active view for the permission bubble. If this is NULL, it 54 // Sets the active view for the permission bubble. If this is NULL, it
55 // means any existing permission bubble can no longer be shown. Does not 55 // means any existing permission bubble can no longer be shown. Does not
56 // take ownership of the view. 56 // take ownership of the view.
57 virtual void SetView(PermissionBubbleView* view) OVERRIDE; 57 virtual void SetView(PermissionBubbleView* view) OVERRIDE;
58 58
59 protected:
60 // Sets the coalesce time interval to |interval_ms|. For testing only.
61 void SetCoalesceIntervalForTesting(int interval_ms);
62
63 private: 59 private:
64 friend class PermissionBubbleManagerTest; 60 friend class PermissionBubbleManagerTest;
65 friend class DownloadRequestLimiterTest; 61 friend class DownloadRequestLimiterTest;
66 friend class content::WebContentsUserData<PermissionBubbleManager>; 62 friend class content::WebContentsUserData<PermissionBubbleManager>;
67 63
68 explicit PermissionBubbleManager(content::WebContents* web_contents); 64 explicit PermissionBubbleManager(content::WebContents* web_contents);
69 65
70 // contents::WebContentsObserver: 66 // WebContentsObserver:
71 // TODO(leng): Investigate the ordering and timing of page loading and 67
72 // permission requests with iFrames. DocumentOnLoadCompletedInMainFrame() 68 // TODO(leng): Finalize policy for permission requests with iFrames.
73 // and DocumentLoadedInFrame() might be needed as well. 69 // DocumentLoadedInFrame() might be needed as well.
74 virtual void DidFinishLoad( 70 virtual void DocumentOnLoadCompletedInMainFrame(int32 page_id) OVERRIDE;
75 int64 frame_id, 71
76 const GURL& validated_url,
77 bool is_main_frame,
78 content::RenderViewHost* render_view_host) OVERRIDE;
79 // If a page on which permissions requests are pending is navigated, 72 // If a page on which permissions requests are pending is navigated,
80 // they will be finalized as if canceled by the user. 73 // they will be finalized as if canceled by the user.
81 virtual void NavigationEntryCommitted( 74 virtual void NavigationEntryCommitted(
82 const content::LoadCommittedDetails& details) OVERRIDE; 75 const content::LoadCommittedDetails& details) OVERRIDE;
83 virtual void WebContentsDestroyed( 76 virtual void WebContentsDestroyed(
84 content::WebContents* web_contents) OVERRIDE; 77 content::WebContents* web_contents) OVERRIDE;
85 78
86 // PermissionBubbleView::Delegate: 79 // PermissionBubbleView::Delegate:
87 virtual void ToggleAccept(int request_index, bool new_value) OVERRIDE; 80 virtual void ToggleAccept(int request_index, bool new_value) OVERRIDE;
88 virtual void SetCustomizationMode() OVERRIDE; 81 virtual void SetCustomizationMode() OVERRIDE;
89 virtual void Accept() OVERRIDE; 82 virtual void Accept() OVERRIDE;
90 virtual void Deny() OVERRIDE; 83 virtual void Deny() OVERRIDE;
91 virtual void Closing() OVERRIDE; 84 virtual void Closing() OVERRIDE;
92 85
93 // Called when the coalescing timer is done. Presents the bubble.
94 void ShowBubble(); 86 void ShowBubble();
95 87
96 // Finalize the pending permissions request. 88 // Finalize the pending permissions request.
97 void FinalizeBubble(); 89 void FinalizeBubble();
98 90
99 // Cancel any pending requests. This is called if the WebContents 91 // Cancel any pending requests. This is called if the WebContents
100 // on which permissions calls are pending is destroyed or navigated away 92 // on which permissions calls are pending is destroyed or navigated away
101 // from the requesting page. 93 // from the requesting page.
102 void CancelPendingQueue(); 94 void CancelPendingQueue();
103 95
104 // Whether or not we are showing the bubble in this tab. 96 // Whether or not we are showing the bubble in this tab.
105 bool bubble_showing_; 97 bool bubble_showing_;
106 98
107 // Set to the UI surface to be used to display the permissions requests. 99 // Set to the UI surface to be used to display the permissions requests.
108 PermissionBubbleView* view_; 100 PermissionBubbleView* view_;
109 101
110 std::vector<PermissionBubbleRequest*> requests_; 102 std::vector<PermissionBubbleRequest*> requests_;
111 std::vector<PermissionBubbleRequest*> queued_requests_; 103 std::vector<PermissionBubbleRequest*> queued_requests_;
112 GURL request_url_; 104 GURL request_url_;
105 bool request_url_has_loaded_;
113 std::vector<bool> accept_states_; 106 std::vector<bool> accept_states_;
114 bool customization_mode_; 107 bool customization_mode_;
115 108
116 scoped_ptr<base::Timer> timer_; 109 base::WeakPtrFactory<PermissionBubbleManager> weak_factory_;
117 }; 110 };
118 111
119 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ 112 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698