| 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_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ |
| 6 #define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/containers/scoped_ptr_hash_map.h" | 9 #include "base/containers/scoped_ptr_hash_map.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // - Create a class that inherits from PermissionContextBase and passes the | 39 // - Create a class that inherits from PermissionContextBase and passes the |
| 40 // new permission. | 40 // new permission. |
| 41 // - Inherit from PermissionInfobarDelegate and implement | 41 // - Inherit from PermissionInfobarDelegate and implement |
| 42 // |GetMessageText| | 42 // |GetMessageText| |
| 43 // - Edit the PermissionBubbleRequestImpl methods to add the new text for | 43 // - Edit the PermissionBubbleRequestImpl methods to add the new text for |
| 44 // the bubble. | 44 // the bubble. |
| 45 // - Hit several asserts for the missing plumbing and fix them :) | 45 // - Hit several asserts for the missing plumbing and fix them :) |
| 46 // After this you can override several other methods to customize behavior, | 46 // After this you can override several other methods to customize behavior, |
| 47 // in particular it is advised to override UpdateTabContext in order to manage | 47 // in particular it is advised to override UpdateTabContext in order to manage |
| 48 // the permission from the omnibox. | 48 // the permission from the omnibox. |
| 49 // It is mandatory to override IsRestrictedToSecureOrigin. |
| 49 // See midi_permission_context.h/cc or push_permission_context.cc/h for some | 50 // See midi_permission_context.h/cc or push_permission_context.cc/h for some |
| 50 // examples. | 51 // examples. |
| 51 | 52 |
| 52 class PermissionContextBase : public KeyedService { | 53 class PermissionContextBase : public KeyedService { |
| 53 public: | 54 public: |
| 54 PermissionContextBase(Profile* profile, | 55 PermissionContextBase(Profile* profile, |
| 55 const ContentSettingsType permission_type); | 56 const ContentSettingsType permission_type); |
| 56 ~PermissionContextBase() override; | 57 ~PermissionContextBase() override; |
| 57 | 58 |
| 58 // The renderer is requesting permission to push messages. | 59 // The renderer is requesting permission to push messages. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // Returns the profile associated with this permission context. | 117 // Returns the profile associated with this permission context. |
| 117 Profile* profile() const; | 118 Profile* profile() const; |
| 118 | 119 |
| 119 // Store the decided permission as a content setting. | 120 // Store the decided permission as a content setting. |
| 120 // virtual since the permission might be stored with different restrictions | 121 // virtual since the permission might be stored with different restrictions |
| 121 // (for example for desktop notifications). | 122 // (for example for desktop notifications). |
| 122 virtual void UpdateContentSetting(const GURL& requesting_origin, | 123 virtual void UpdateContentSetting(const GURL& requesting_origin, |
| 123 const GURL& embedding_origin, | 124 const GURL& embedding_origin, |
| 124 ContentSetting content_setting); | 125 ContentSetting content_setting); |
| 125 | 126 |
| 127 // Whether the permission should be restricted to secure origins. |
| 128 virtual bool IsRestrictedToSecureOrigins() const = 0; |
| 129 |
| 126 private: | 130 private: |
| 127 // Called when a bubble is no longer used so it can be cleaned up. | 131 // Called when a bubble is no longer used so it can be cleaned up. |
| 128 void CleanUpBubble(const PermissionRequestID& id); | 132 void CleanUpBubble(const PermissionRequestID& id); |
| 129 | 133 |
| 130 Profile* profile_; | 134 Profile* profile_; |
| 131 const ContentSettingsType permission_type_; | 135 const ContentSettingsType permission_type_; |
| 132 scoped_ptr<PermissionQueueController> permission_queue_controller_; | 136 scoped_ptr<PermissionQueueController> permission_queue_controller_; |
| 133 base::ScopedPtrHashMap<std::string, scoped_ptr<PermissionBubbleRequest>> | 137 base::ScopedPtrHashMap<std::string, scoped_ptr<PermissionBubbleRequest>> |
| 134 pending_bubbles_; | 138 pending_bubbles_; |
| 135 | 139 |
| 136 // Must be the last member, to ensure that it will be | 140 // Must be the last member, to ensure that it will be |
| 137 // destroyed first, which will invalidate weak pointers | 141 // destroyed first, which will invalidate weak pointers |
| 138 base::WeakPtrFactory<PermissionContextBase> weak_factory_; | 142 base::WeakPtrFactory<PermissionContextBase> weak_factory_; |
| 139 }; | 143 }; |
| 140 | 144 |
| 141 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ | 145 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ |
| OLD | NEW |