Chromium Code Reviews| 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 27 matching lines...) Expand all Loading... | |
| 38 // - Define your new permission in the ContentSettingsType enum. | 38 // - Define your new permission in the ContentSettingsType enum. |
| 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. |
|
Miguel Garcia
2015/05/26 09:34:33
perhaps add here that we need to decide if the new
mlamouri (slow - plz ping)
2015/05/29 14:35:14
Done.
| |
| 49 // See midi_permission_context.h/cc or push_permission_context.cc/h for some | 49 // See midi_permission_context.h/cc or push_permission_context.cc/h for some |
| 50 // examples. | 50 // examples. |
| 51 | 51 |
| 52 class PermissionContextBase : public KeyedService { | 52 class PermissionContextBase : public KeyedService { |
| 53 public: | 53 public: |
| 54 PermissionContextBase(Profile* profile, | 54 PermissionContextBase(Profile* profile, |
| 55 const ContentSettingsType permission_type); | 55 const ContentSettingsType permission_type); |
| 56 ~PermissionContextBase() override; | 56 ~PermissionContextBase() override; |
| 57 | 57 |
| 58 // The renderer is requesting permission to push messages. | 58 // 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. | 116 // Returns the profile associated with this permission context. |
| 117 Profile* profile() const; | 117 Profile* profile() const; |
| 118 | 118 |
| 119 // Store the decided permission as a content setting. | 119 // Store the decided permission as a content setting. |
| 120 // virtual since the permission might be stored with different restrictions | 120 // virtual since the permission might be stored with different restrictions |
| 121 // (for example for desktop notifications). | 121 // (for example for desktop notifications). |
| 122 virtual void UpdateContentSetting(const GURL& requesting_origin, | 122 virtual void UpdateContentSetting(const GURL& requesting_origin, |
| 123 const GURL& embedding_origin, | 123 const GURL& embedding_origin, |
| 124 ContentSetting content_setting); | 124 ContentSetting content_setting); |
| 125 | 125 |
| 126 // Whether the permission should be restricted to secured origins. | |
| 127 virtual bool RestrictToSecureOrigins() const = 0; | |
|
Miguel Garcia
2015/05/26 09:34:33
can you add a default implementation? I guess defa
ddorwin
2015/05/26 17:31:31
Should this be IsRestrcited...?
mlamouri (slow - plz ping)
2015/05/29 14:35:15
I did not on purpose so implementations will have
| |
| 128 | |
| 126 private: | 129 private: |
| 127 // Called when a bubble is no longer used so it can be cleaned up. | 130 // Called when a bubble is no longer used so it can be cleaned up. |
| 128 void CleanUpBubble(const PermissionRequestID& id); | 131 void CleanUpBubble(const PermissionRequestID& id); |
| 129 | 132 |
| 130 Profile* profile_; | 133 Profile* profile_; |
| 131 const ContentSettingsType permission_type_; | 134 const ContentSettingsType permission_type_; |
| 132 scoped_ptr<PermissionQueueController> permission_queue_controller_; | 135 scoped_ptr<PermissionQueueController> permission_queue_controller_; |
| 133 base::ScopedPtrHashMap<std::string, scoped_ptr<PermissionBubbleRequest>> | 136 base::ScopedPtrHashMap<std::string, scoped_ptr<PermissionBubbleRequest>> |
| 134 pending_bubbles_; | 137 pending_bubbles_; |
| 135 | 138 |
| 136 // Must be the last member, to ensure that it will be | 139 // Must be the last member, to ensure that it will be |
| 137 // destroyed first, which will invalidate weak pointers | 140 // destroyed first, which will invalidate weak pointers |
| 138 base::WeakPtrFactory<PermissionContextBase> weak_factory_; | 141 base::WeakPtrFactory<PermissionContextBase> weak_factory_; |
| 139 }; | 142 }; |
| 140 | 143 |
| 141 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ | 144 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ |
| OLD | NEW |