| OLD | NEW |
| 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 "chrome/browser/ui/website_settings/permission_bubble_view.h" | 11 #include "chrome/browser/ui/website_settings/permission_bubble_view.h" |
| 11 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
| 12 #include "content/public/browser/web_contents_user_data.h" | 13 #include "content/public/browser/web_contents_user_data.h" |
| 13 | 14 |
| 14 class PermissionBubbleRequest; | 15 class PermissionBubbleRequest; |
| 15 | 16 |
| 16 // Provides access to permissions bubbles. Allows clients to add a request | 17 // Provides access to permissions bubbles. Allows clients to add a request |
| 17 // callback interface to the existing permission bubble configuration. | 18 // callback interface to the existing permission bubble configuration. |
| 18 // 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 |
| 19 // 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 Loading... |
| 48 // 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. |
| 49 // 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 |
| 50 // 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. |
| 51 virtual void CancelRequest(PermissionBubbleRequest* request); | 52 virtual void CancelRequest(PermissionBubbleRequest* request); |
| 52 | 53 |
| 53 // 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 |
| 54 // 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 |
| 55 // take ownership of the view. | 56 // take ownership of the view. |
| 56 virtual void SetView(PermissionBubbleView* view) OVERRIDE; | 57 virtual void SetView(PermissionBubbleView* view) OVERRIDE; |
| 57 | 58 |
| 59 protected: |
| 60 // Sets the coalesce time interval to |interval_ms|. For testing only. |
| 61 void SetCoalesceIntervalForTesting(int interval_ms); |
| 62 |
| 58 private: | 63 private: |
| 59 friend class PermissionBubbleManagerTest; | 64 friend class PermissionBubbleManagerTest; |
| 60 friend class DownloadRequestLimiterTest; | 65 friend class DownloadRequestLimiterTest; |
| 61 friend class content::WebContentsUserData<PermissionBubbleManager>; | 66 friend class content::WebContentsUserData<PermissionBubbleManager>; |
| 62 | 67 |
| 63 explicit PermissionBubbleManager(content::WebContents* web_contents); | 68 explicit PermissionBubbleManager(content::WebContents* web_contents); |
| 64 | 69 |
| 65 // WebContentsObserver: | 70 // contents::WebContentsObserver: |
| 66 | 71 // TODO(leng): Investigate the ordering and timing of page loading and |
| 67 // TODO(leng): Finalize policy for permission requests with iFrames. | 72 // permission requests with iFrames. DocumentOnLoadCompletedInMainFrame() |
| 68 // DocumentLoadedInFrame() might be needed as well. | 73 // and DocumentLoadedInFrame() might be needed as well. |
| 69 virtual void DocumentOnLoadCompletedInMainFrame(int32 page_id) OVERRIDE; | 74 virtual void DidFinishLoad( |
| 70 | 75 int64 frame_id, |
| 76 const GURL& validated_url, |
| 77 bool is_main_frame, |
| 78 content::RenderViewHost* render_view_host) OVERRIDE; |
| 71 // If a page on which permissions requests are pending is navigated, | 79 // If a page on which permissions requests are pending is navigated, |
| 72 // they will be finalized as if canceled by the user. | 80 // they will be finalized as if canceled by the user. |
| 73 virtual void NavigationEntryCommitted( | 81 virtual void NavigationEntryCommitted( |
| 74 const content::LoadCommittedDetails& details) OVERRIDE; | 82 const content::LoadCommittedDetails& details) OVERRIDE; |
| 75 virtual void WebContentsDestroyed( | 83 virtual void WebContentsDestroyed( |
| 76 content::WebContents* web_contents) OVERRIDE; | 84 content::WebContents* web_contents) OVERRIDE; |
| 77 | 85 |
| 78 // PermissionBubbleView::Delegate: | 86 // PermissionBubbleView::Delegate: |
| 79 virtual void ToggleAccept(int request_index, bool new_value) OVERRIDE; | 87 virtual void ToggleAccept(int request_index, bool new_value) OVERRIDE; |
| 80 virtual void SetCustomizationMode() OVERRIDE; | 88 virtual void SetCustomizationMode() OVERRIDE; |
| 81 virtual void Accept() OVERRIDE; | 89 virtual void Accept() OVERRIDE; |
| 82 virtual void Deny() OVERRIDE; | 90 virtual void Deny() OVERRIDE; |
| 83 virtual void Closing() OVERRIDE; | 91 virtual void Closing() OVERRIDE; |
| 84 | 92 |
| 93 // Called when the coalescing timer is done. Presents the bubble. |
| 85 void ShowBubble(); | 94 void ShowBubble(); |
| 86 | 95 |
| 87 // Finalize the pending permissions request. | 96 // Finalize the pending permissions request. |
| 88 void FinalizeBubble(); | 97 void FinalizeBubble(); |
| 89 | 98 |
| 90 // Cancel any pending requests. This is called if the WebContents | 99 // Cancel any pending requests. This is called if the WebContents |
| 91 // on which permissions calls are pending is destroyed or navigated away | 100 // on which permissions calls are pending is destroyed or navigated away |
| 92 // from the requesting page. | 101 // from the requesting page. |
| 93 void CancelPendingQueue(); | 102 void CancelPendingQueue(); |
| 94 | 103 |
| 95 // Whether or not we are showing the bubble in this tab. | 104 // Whether or not we are showing the bubble in this tab. |
| 96 bool bubble_showing_; | 105 bool bubble_showing_; |
| 97 | 106 |
| 98 // Set to the UI surface to be used to display the permissions requests. | 107 // Set to the UI surface to be used to display the permissions requests. |
| 99 PermissionBubbleView* view_; | 108 PermissionBubbleView* view_; |
| 100 | 109 |
| 101 std::vector<PermissionBubbleRequest*> requests_; | 110 std::vector<PermissionBubbleRequest*> requests_; |
| 102 std::vector<PermissionBubbleRequest*> queued_requests_; | 111 std::vector<PermissionBubbleRequest*> queued_requests_; |
| 103 GURL request_url_; | 112 GURL request_url_; |
| 104 bool request_url_has_loaded_; | |
| 105 std::vector<bool> accept_states_; | 113 std::vector<bool> accept_states_; |
| 106 bool customization_mode_; | 114 bool customization_mode_; |
| 115 |
| 116 scoped_ptr<base::Timer> timer_; |
| 107 }; | 117 }; |
| 108 | 118 |
| 109 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ | 119 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ |
| OLD | NEW |