| 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/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // | 26 // |
| 27 // The PermissionBubbleManager should be addressed on the UI thread. | 27 // The PermissionBubbleManager should be addressed on the UI thread. |
| 28 class PermissionBubbleManager | 28 class PermissionBubbleManager |
| 29 : public content::WebContentsObserver, | 29 : public content::WebContentsObserver, |
| 30 public content::WebContentsUserData<PermissionBubbleManager>, | 30 public content::WebContentsUserData<PermissionBubbleManager>, |
| 31 public PermissionBubbleView::Delegate { | 31 public PermissionBubbleView::Delegate { |
| 32 public: | 32 public: |
| 33 // Return the flag-driven enabled state of permissions bubbles. | 33 // Return the flag-driven enabled state of permissions bubbles. |
| 34 static bool Enabled(); | 34 static bool Enabled(); |
| 35 | 35 |
| 36 virtual ~PermissionBubbleManager(); | 36 ~PermissionBubbleManager() override; |
| 37 | 37 |
| 38 // Adds a new request to the permission bubble. Ownership of the request | 38 // Adds a new request to the permission bubble. Ownership of the request |
| 39 // remains with the caller. The caller must arrange for the request to | 39 // remains with the caller. The caller must arrange for the request to |
| 40 // outlive the PermissionBubbleManager. If a bubble is visible when this | 40 // outlive the PermissionBubbleManager. If a bubble is visible when this |
| 41 // call is made, the request will be queued up and shown after the current | 41 // call is made, the request will be queued up and shown after the current |
| 42 // bubble closes. A request with message text identical to an outstanding | 42 // bubble closes. A request with message text identical to an outstanding |
| 43 // request will receive a RequestFinished call immediately and not be added. | 43 // request will receive a RequestFinished call immediately and not be added. |
| 44 virtual void AddRequest(PermissionBubbleRequest* request); | 44 virtual void AddRequest(PermissionBubbleRequest* request); |
| 45 | 45 |
| 46 // Cancels an outstanding request. This may have different effects depending | 46 // Cancels an outstanding request. This may have different effects depending |
| 47 // on what is going on with the bubble. If the request is pending, it will be | 47 // on what is going on with the bubble. If the request is pending, it will be |
| 48 // removed and never shown. If the request is showing, it will continue to be | 48 // removed and never shown. If the request is showing, it will continue to be |
| 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 request will have RequestFinished executed on it if it is found, | 51 // do so. The request will have RequestFinished executed on it if it is found, |
| 52 // at which time the caller is free to delete the request. | 52 // at which time the caller is free to delete the request. |
| 53 virtual void CancelRequest(PermissionBubbleRequest* request); | 53 virtual void CancelRequest(PermissionBubbleRequest* request); |
| 54 | 54 |
| 55 // Sets the active view for the permission bubble. If this is NULL, it | 55 // Sets the active view for the permission bubble. If this is NULL, it |
| 56 // means any existing permission bubble can no longer be shown. Does not | 56 // means any existing permission bubble can no longer be shown. Does not |
| 57 // take ownership of the view. | 57 // take ownership of the view. |
| 58 virtual void SetView(PermissionBubbleView* view) override; | 58 void SetView(PermissionBubbleView* view) override; |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 friend class PermissionBubbleManagerTest; | 61 friend class PermissionBubbleManagerTest; |
| 62 friend class DownloadRequestLimiterTest; | 62 friend class DownloadRequestLimiterTest; |
| 63 friend class content::WebContentsUserData<PermissionBubbleManager>; | 63 friend class content::WebContentsUserData<PermissionBubbleManager>; |
| 64 | 64 |
| 65 explicit PermissionBubbleManager(content::WebContents* web_contents); | 65 explicit PermissionBubbleManager(content::WebContents* web_contents); |
| 66 | 66 |
| 67 // WebContentsObserver: | 67 // WebContentsObserver: |
| 68 virtual void DocumentOnLoadCompletedInMainFrame() override; | 68 void DocumentOnLoadCompletedInMainFrame() override; |
| 69 virtual void DocumentLoadedInFrame( | 69 void DocumentLoadedInFrame( |
| 70 content::RenderFrameHost* render_frame_host) override; | 70 content::RenderFrameHost* render_frame_host) override; |
| 71 | 71 |
| 72 // If a page on which permissions requests are pending is navigated, | 72 // If a page on which permissions requests are pending is navigated, |
| 73 // they will be finalized as if canceled by the user. | 73 // they will be finalized as if canceled by the user. |
| 74 virtual void NavigationEntryCommitted( | 74 void NavigationEntryCommitted( |
| 75 const content::LoadCommittedDetails& details) override; | 75 const content::LoadCommittedDetails& details) override; |
| 76 virtual void WebContentsDestroyed() override; | 76 void WebContentsDestroyed() override; |
| 77 | 77 |
| 78 // PermissionBubbleView::Delegate: | 78 // PermissionBubbleView::Delegate: |
| 79 virtual void ToggleAccept(int request_index, bool new_value) override; | 79 void ToggleAccept(int request_index, bool new_value) override; |
| 80 virtual void SetCustomizationMode() override; | 80 void SetCustomizationMode() override; |
| 81 virtual void Accept() override; | 81 void Accept() override; |
| 82 virtual void Deny() override; | 82 void Deny() override; |
| 83 virtual void Closing() override; | 83 void Closing() override; |
| 84 | 84 |
| 85 // Posts a task which will allow the bubble to become visible if it is needed. | 85 // Posts a task which will allow the bubble to become visible if it is needed. |
| 86 void ScheduleShowBubble(); | 86 void ScheduleShowBubble(); |
| 87 | 87 |
| 88 // Shows the bubble if it is not already visible and there are pending | 88 // Shows the bubble if it is not already visible and there are pending |
| 89 // requests. | 89 // requests. |
| 90 void TriggerShowBubble(); | 90 void TriggerShowBubble(); |
| 91 | 91 |
| 92 // Finalize the pending permissions request. | 92 // Finalize the pending permissions request. |
| 93 void FinalizeBubble(); | 93 void FinalizeBubble(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 124 GURL request_url_; | 124 GURL request_url_; |
| 125 bool request_url_has_loaded_; | 125 bool request_url_has_loaded_; |
| 126 | 126 |
| 127 std::vector<bool> accept_states_; | 127 std::vector<bool> accept_states_; |
| 128 bool customization_mode_; | 128 bool customization_mode_; |
| 129 | 129 |
| 130 base::WeakPtrFactory<PermissionBubbleManager> weak_factory_; | 130 base::WeakPtrFactory<PermissionBubbleManager> weak_factory_; |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ | 133 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_PERMISSION_BUBBLE_MANAGER_H_ |
| OLD | NEW |