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

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: uninstall, tests, aa 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 TabContentsWrapper;
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(TabContentsWrapper* 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)
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 current page ID.
60 int32 GetPageID();
61
62 // Our owning TabContentsWrapper.
63 TabContentsWrapper* tab_contents_;
64
65 // The URLPatternSet for frames that are active on the current page. This is
66 // cleared on navigation.
67 //
68 // Note that concerned code probably only cares about the origins of these
69 // URLs, but let them deal with that.
70 URLPatternSet active_urls_;
71
72 // Extensions with the activeTab permission that have been granted
73 // tab-specific permissions until the next navigation/refresh.
74 ExtensionSet granted_;
75
76 // Listen to extension unloaded notifications.
77 content::NotificationRegistrar registrar_;
78
79 DISALLOW_COPY_AND_ASSIGN(ActiveTabPermissionManager);
80 };
81
82 } // namespace extensions
83
84 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698