Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: chrome/browser/extensions/active_tab_permission_granter.h

Issue 2858013002: PS - Showing permission prompt for activeTab (Closed)
Patch Set: Rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 14 matching lines...) Expand all
25 25
26 class Extension; 26 class Extension;
27 class ExtensionRegistry; 27 class ExtensionRegistry;
28 28
29 // Responsible for granting and revoking tab-specific permissions to extensions 29 // Responsible for granting and revoking tab-specific permissions to extensions
30 // with the activeTab or tabCapture permission. 30 // with the activeTab or tabCapture permission.
31 class ActiveTabPermissionGranter 31 class ActiveTabPermissionGranter
32 : public content::WebContentsObserver, 32 : public content::WebContentsObserver,
33 public extensions::ExtensionRegistryObserver { 33 public extensions::ExtensionRegistryObserver {
34 public: 34 public:
35 // Platform specific delegate.
36 class Delegate {
37 public:
38 virtual ~Delegate() {}
39 // Platform specific check whether the user granted activeTab permission.
Devlin 2017/05/12 14:56:45 I think rather than "whether the user granted acti
Ivan Šandrk 2017/05/12 18:27:44 Good point, done.
40 virtual bool ActiveTabPermissionGranted(
Devlin 2017/05/12 14:56:45 "ActiveTabPermissionGranted" is a strange name for
Ivan Šandrk 2017/05/12 18:27:44 Another good one, done.
41 const Extension* extension, content::WebContents* web_contents) = 0;
42 };
43
35 ActiveTabPermissionGranter(content::WebContents* web_contents, 44 ActiveTabPermissionGranter(content::WebContents* web_contents,
36 int tab_id, 45 int tab_id,
37 Profile* profile); 46 Profile* profile);
38 ~ActiveTabPermissionGranter() override; 47 ~ActiveTabPermissionGranter() override;
39 48
49 // Platform specific delegate should be set during startup. |delegate| is a
50 // singleton instance and is leaked.
51 static void SetPlatformDelegate(Delegate* delegate);
52
40 // If |extension| has the activeTab or tabCapture permission, grants 53 // If |extension| has the activeTab or tabCapture permission, grants
41 // tab-specific permissions to it until the next page navigation or refresh. 54 // tab-specific permissions to it until the next page navigation or refresh.
42 void GrantIfRequested(const Extension* extension); 55 void GrantIfRequested(const Extension* extension);
43 56
44 // Clears tab-specific permissions for all extensions. Used only for testing. 57 // Clears tab-specific permissions for all extensions. Used only for testing.
45 void RevokeForTesting(); 58 void RevokeForTesting();
46 59
47 private: 60 private:
48 // content::WebContentsObserver implementation. 61 // content::WebContentsObserver implementation.
49 void DidFinishNavigation( 62 void DidFinishNavigation(
(...skipping 19 matching lines...) Expand all
69 // Listen to extension unloaded notifications. 82 // Listen to extension unloaded notifications.
70 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 83 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
71 extension_registry_observer_; 84 extension_registry_observer_;
72 85
73 DISALLOW_COPY_AND_ASSIGN(ActiveTabPermissionGranter); 86 DISALLOW_COPY_AND_ASSIGN(ActiveTabPermissionGranter);
74 }; 87 };
75 88
76 } // namespace extensions 89 } // namespace extensions
77 90
78 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_GRANTER_H_ 91 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_GRANTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698