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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/active_tab_permission_manager.h
diff --git a/chrome/browser/extensions/active_tab_permission_manager.h b/chrome/browser/extensions/active_tab_permission_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..4d592514f745b02e36c5c7e7c01e05bdb52fa021
--- /dev/null
+++ b/chrome/browser/extensions/active_tab_permission_manager.h
@@ -0,0 +1,73 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_MANAGER_H_
+#define CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_MANAGER_H_
+#pragma once
+
+#include <set>
+#include <string>
+
+#include "chrome/common/extensions/extension_set.h"
+#include "chrome/common/extensions/url_pattern_set.h"
+#include "content/public/browser/web_contents_observer.h"
+
+class TabContentsWrapper;
+
+namespace extensions {
+
+class Extension;
+
+// Responsible for granting and revoking tab-specific permissions to extensions
+// with the activeTab permission.
+class ActiveTabPermissionManager : public content::WebContentsObserver {
+ public:
+ explicit ActiveTabPermissionManager(TabContentsWrapper* tab_contents);
+ virtual ~ActiveTabPermissionManager();
Aaron Boodman 2012/06/06 01:03:13 I think the destructor should be private; we only
+
+ // Grants tab-specific permissions to an extension for this tab until the
+ // next navigation or refresh, if the extension has the activeTab permission.
+ void Grant(const Extension* extension);
+
+ private:
+ // content::WebContentsObserver implementation.
+ virtual void DidCommitProvisionalLoadForFrame(
+ int64 frame_id,
+ bool is_main_frame,
+ const GURL& url,
+ content::PageTransition transition_type,
+ content::RenderViewHost* render_view_host) OVERRIDE;
+ virtual void WebContentsDestroyed(content::WebContents* web_contents)
+ OVERRIDE;
+
+ // Clears any granted tab-specific permissions for all extensions and
+ // notifies renderers.
+ void ClearActiveURLsAndNotify();
+
+ // Inserts a URL pattern giving access to the entire origin for |url|.
+ void InsertActiveURL(const GURL& url);
+
+ // Gets the current page ID.
+ int32 GetPageID();
+
+ // Our owning TabContentsWrapper.
+ TabContentsWrapper* tab_contents_;
+
+ // The URLPatternSet for frames that are active on the current page. This is
+ // cleared on navigation.
+ //
+ // Note that concerned code probably only cares about the origins of these
+ // URLs, but let them deal with that.
+ URLPatternSet active_urls_;
+
+ // Extensions with the activeTab permission that have been granted
+ // tab-specific permissions until the next navigation/refresh.
+ ExtensionSet granted_;
+
+ DISALLOW_COPY_AND_ASSIGN(ActiveTabPermissionManager);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_ACTIVE_TAB_PERMISSION_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698