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

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: a unit test 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/web_contents_observer.h"
15
16 class TabContentsWrapper;
17
18 namespace extensions {
19
20 class Extension;
21
22 // Responsible for granting and revoking tab-specific permissions to extensions
23 // with the activeTab permission.
24 class ActiveTabPermissionManager : public content::WebContentsObserver {
25 public:
26 explicit ActiveTabPermissionManager(TabContentsWrapper* tab_contents);
27 virtual ~ActiveTabPermissionManager();
Aaron Boodman 2012/06/06 01:03:13 I think the destructor should be private; we only
28
29 // Grants tab-specific permissions to an extension for this tab until the
30 // next navigation or refresh, if the extension has the activeTab permission.
31 void Grant(const Extension* extension);
32
33 private:
34 // content::WebContentsObserver implementation.
35 virtual void DidCommitProvisionalLoadForFrame(
36 int64 frame_id,
37 bool is_main_frame,
38 const GURL& url,
39 content::PageTransition transition_type,
40 content::RenderViewHost* render_view_host) OVERRIDE;
41 virtual void WebContentsDestroyed(content::WebContents* web_contents)
42 OVERRIDE;
43
44 // Clears any granted tab-specific permissions for all extensions and
45 // notifies renderers.
46 void ClearActiveURLsAndNotify();
47
48 // Inserts a URL pattern giving access to the entire origin for |url|.
49 void InsertActiveURL(const GURL& url);
50
51 // Gets the current page ID.
52 int32 GetPageID();
53
54 // Our owning TabContentsWrapper.
55 TabContentsWrapper* tab_contents_;
56
57 // The URLPatternSet for frames that are active on the current page. This is
58 // cleared on navigation.
59 //
60 // Note that concerned code probably only cares about the origins of these
61 // URLs, but let them deal with that.
62 URLPatternSet active_urls_;
63
64 // Extensions with the activeTab permission that have been granted
65 // tab-specific permissions until the next navigation/refresh.
66 ExtensionSet granted_;
67
68 DISALLOW_COPY_AND_ASSIGN(ActiveTabPermissionManager);
69 };
70
71 } // namespace extensions
72
73 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698