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

Side by Side Diff: chrome/browser/extensions/api/api_resource.h

Issue 10919201: Make sure that a given app/extension requests only its own resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improve tests; fix merge conflicts. Created 8 years, 3 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/api/api_resource.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "chrome/common/extensions/extension.h"
10 11
11 namespace extensions { 12 namespace extensions {
12 13
13 class ApiResourceEventNotifier; 14 class ApiResourceEventNotifier;
14 15
15 // An ApiResource represents something that an extension API manages, such as a 16 // An ApiResource represents something that an extension API manages, such as a
16 // socket or a serial-port connection. Typically, an ApiResourceManager will 17 // socket or a serial-port connection. Typically, an ApiResourceManager will
17 // control the lifetime of all ApiResources of a specific derived type. 18 // control the lifetime of all ApiResources of a specific derived type.
18 class ApiResource { 19 class ApiResource {
19 public: 20 public:
20 virtual ~ApiResource(); 21 virtual ~ApiResource();
21 22
23 const std::string& owner_extension_id() const {
24 return owner_extension_id_;
25 }
26
22 protected: 27 protected:
23 ApiResource(ApiResourceEventNotifier* event_notifier); 28 ApiResource(const std::string& owner_extension_id,
29 ApiResourceEventNotifier* event_notifier);
24 30
25 ApiResourceEventNotifier* event_notifier() const; 31 ApiResourceEventNotifier* event_notifier() const;
26 32
27 private: 33 private:
34 // The extension that owns this resource. This could be derived from
35 // event_notifier, but that's a little too cute; to make future code
36 // maintenance easier, we'll require callers to explicitly specify the owner,
37 // and for now we'll assert that the owner implied by the event_notifier is
38 // consistent with the explicit one.
39 const std::string& owner_extension_id_;
40
41 // The object that lets this resource report events to the owner application.
28 scoped_refptr<ApiResourceEventNotifier> event_notifier_; 42 scoped_refptr<ApiResourceEventNotifier> event_notifier_;
29 43
30 DISALLOW_COPY_AND_ASSIGN(ApiResource); 44 DISALLOW_COPY_AND_ASSIGN(ApiResource);
31 }; 45 };
32 46
33 } // namespace extensions 47 } // namespace extensions
34 48
35 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_H_ 49 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/api_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698