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

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: empty -> is_empty 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
« no previous file with comments | « no previous file | chrome/browser/extensions/active_tab_permission_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 GrantIfRequested(const Extension* extension);
35
36 // content::WebContentsObserver implementation.
37 //
38 // This is public to be called from ActiveTabTest as a way to fake creating
39 // frames on this tab. It's a bit fragile but there doesn't seem to be any
40 // other way to do it.
41 virtual void DidCommitProvisionalLoadForFrame(
42 int64 frame_id,
43 bool is_main_frame,
44 const GURL& url,
45 content::PageTransition transition_type,
46 content::RenderViewHost* render_view_host) OVERRIDE;
47
48 private:
49 // More content::WebContentsObserver.
50 virtual void WebContentsDestroyed(content::WebContents* web_contents)
51 OVERRIDE;
52
53 // content::NotificationObserver implementation.
54 virtual void Observe(int type,
55 const content::NotificationSource& source,
56 const content::NotificationDetails& details) OVERRIDE;
57
58 // Clears any granted tab-specific permissions for all extensions and
59 // notifies renderers.
60 void ClearActiveURLsAndNotify();
61
62 // Inserts a URL pattern giving access to the entire origin for |url|.
63 void InsertActiveURL(const GURL& url);
64
65 // Gets the tab's id.
66 int tab_id();
67
68 // Gets the current page id.
69 int32 GetPageID();
70
71 // Our owning TabContents.
72 TabContents* tab_contents_;
73
74 // The URLPatternSet for frames that are active on the current page. This is
75 // cleared on navigation.
76 //
77 // Note that concerned code probably only cares about the origins of these
78 // URLs, but let them deal with that.
79 URLPatternSet active_urls_;
80
81 // Extensions with the activeTab permission that have been granted
82 // tab-specific permissions until the next navigation/refresh.
83 ExtensionSet granted_;
84
85 // Listen to extension unloaded notifications.
86 content::NotificationRegistrar registrar_;
87
88 DISALLOW_COPY_AND_ASSIGN(ActiveTabPermissionManager);
89 };
90
91 } // namespace extensions
92
93 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/active_tab_permission_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698