| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_EXTENSIONS_ACTIVE_TAB_PERMISSION_GRANTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_GRANTER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_GRANTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_GRANTER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 // Responsible for granting and revoking tab-specific permissions to extensions | 28 // Responsible for granting and revoking tab-specific permissions to extensions |
| 29 // with the activeTab or tabCapture permission. | 29 // with the activeTab or tabCapture permission. |
| 30 class ActiveTabPermissionGranter | 30 class ActiveTabPermissionGranter |
| 31 : public content::WebContentsObserver, | 31 : public content::WebContentsObserver, |
| 32 public extensions::ExtensionRegistryObserver { | 32 public extensions::ExtensionRegistryObserver { |
| 33 public: | 33 public: |
| 34 ActiveTabPermissionGranter(content::WebContents* web_contents, | 34 ActiveTabPermissionGranter(content::WebContents* web_contents, |
| 35 int tab_id, | 35 int tab_id, |
| 36 Profile* profile); | 36 Profile* profile); |
| 37 virtual ~ActiveTabPermissionGranter(); | 37 ~ActiveTabPermissionGranter() override; |
| 38 | 38 |
| 39 // If |extension| has the activeTab or tabCapture permission, grants | 39 // If |extension| has the activeTab or tabCapture permission, grants |
| 40 // tab-specific permissions to it until the next page navigation or refresh. | 40 // tab-specific permissions to it until the next page navigation or refresh. |
| 41 void GrantIfRequested(const Extension* extension); | 41 void GrantIfRequested(const Extension* extension); |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 // content::WebContentsObserver implementation. | 44 // content::WebContentsObserver implementation. |
| 45 virtual void DidNavigateMainFrame( | 45 void DidNavigateMainFrame( |
| 46 const content::LoadCommittedDetails& details, | 46 const content::LoadCommittedDetails& details, |
| 47 const content::FrameNavigateParams& params) override; | 47 const content::FrameNavigateParams& params) override; |
| 48 virtual void WebContentsDestroyed() override; | 48 void WebContentsDestroyed() override; |
| 49 | 49 |
| 50 // extensions::ExtensionRegistryObserver implementation. | 50 // extensions::ExtensionRegistryObserver implementation. |
| 51 virtual void OnExtensionUnloaded(content::BrowserContext* browser_context, | 51 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
| 52 const Extension* extension, | 52 const Extension* extension, |
| 53 UnloadedExtensionInfo::Reason reason) | 53 UnloadedExtensionInfo::Reason reason) override; |
| 54 override; | |
| 55 | 54 |
| 56 // Clears any tab-specific permissions for all extensions on |tab_id_| and | 55 // Clears any tab-specific permissions for all extensions on |tab_id_| and |
| 57 // notifies renderers. | 56 // notifies renderers. |
| 58 void ClearActiveExtensionsAndNotify(); | 57 void ClearActiveExtensionsAndNotify(); |
| 59 | 58 |
| 60 // The tab ID for this tab. | 59 // The tab ID for this tab. |
| 61 int tab_id_; | 60 int tab_id_; |
| 62 | 61 |
| 63 // Extensions with the activeTab permission that have been granted | 62 // Extensions with the activeTab permission that have been granted |
| 64 // tab-specific permissions until the next navigation/refresh. | 63 // tab-specific permissions until the next navigation/refresh. |
| 65 ExtensionSet granted_extensions_; | 64 ExtensionSet granted_extensions_; |
| 66 | 65 |
| 67 // Listen to extension unloaded notifications. | 66 // Listen to extension unloaded notifications. |
| 68 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 67 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 69 extension_registry_observer_; | 68 extension_registry_observer_; |
| 70 | 69 |
| 71 DISALLOW_COPY_AND_ASSIGN(ActiveTabPermissionGranter); | 70 DISALLOW_COPY_AND_ASSIGN(ActiveTabPermissionGranter); |
| 72 }; | 71 }; |
| 73 | 72 |
| 74 } // namespace extensions | 73 } // namespace extensions |
| 75 | 74 |
| 76 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_GRANTER_H_ | 75 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_GRANTER_H_ |
| OLD | NEW |