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

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

Issue 10443105: Take 2 at implementing activeTab. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: many more tests Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_MANAGER_H_
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_MANAGER_H_
7 #pragma once
8
9 #include <set>
10 #include <string>
11
12 #include "chrome/common/extensions/extension_set.h"
13 #include "chrome/common/extensions/url_pattern_set.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/web_contents_observer.h"
17
18 class TabContents;
19
20 namespace extensions {
21
22 class Extension;
23
24 // Responsible for granting and revoking tab-specific permissions to extensions
25 // with the activeTab permission.
26 class ActiveTabPermissionManager : public content::WebContentsObserver,
27 public content::NotificationObserver {
28 public:
29 explicit ActiveTabPermissionManager(TabContents* tab_contents);
30 virtual ~ActiveTabPermissionManager();
31
32 // If |extension| has the activeTab permission, grants tab-specific
33 // permissions to it until the next page navigation or refresh.
34 void MaybeGrant(const Extension* extension);
35
36 // content::WebContentsObserver implementation.
37 virtual void DidCommitProvisionalLoadForFrame(
38 int64 frame_id,
39 bool is_main_frame,
40 const GURL& url,
41 content::PageTransition transition_type,
42 content::RenderViewHost* render_view_host) OVERRIDE;
43 virtual void WebContentsDestroyed(content::WebContents* web_contents)
Aaron Boodman 2012/06/08 05:31:30 Add a blank line here. Also, can this be private?
not at google - send to devlin 2012/06/12 20:40:51 I usually see methods bunched together like this w
44 OVERRIDE;
45
46 private:
47 // content::NotificationObserver implementation.
48 virtual void Observe(int type,
49 const content::NotificationSource& source,
50 const content::NotificationDetails& details) OVERRIDE;
51
52 // Clears any granted tab-specific permissions for all extensions and
53 // notifies renderers.
54 void ClearActiveURLsAndNotify();
55
56 // Inserts a URL pattern giving access to the entire origin for |url|.
57 void InsertActiveURL(const GURL& url);
58
59 // Gets the tab's id.
60 int tab_id();
61
62 // Gets the current page id.
63 int32 GetPageID();
64
65 // Our owning TabContents.
66 TabContents* tab_contents_;
67
68 // The URLPatternSet for frames that are active on the current page. This is
69 // cleared on navigation.
70 //
71 // Note that concerned code probably only cares about the origins of these
72 // URLs, but let them deal with that.
73 URLPatternSet active_urls_;
74
75 // Extensions with the activeTab permission that have been granted
76 // tab-specific permissions until the next navigation/refresh.
77 ExtensionSet granted_;
78
79 // Listen to extension unloaded notifications.
80 content::NotificationRegistrar registrar_;
81
82 DISALLOW_COPY_AND_ASSIGN(ActiveTabPermissionManager);
83 };
84
85 } // namespace extensions
86
87 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698