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

Side by Side Diff: chrome/browser/extensions/api/api_resource_event_notifier.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
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_EVENT_NOTIFIER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_EVENT_NOTIFIER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_EVENT_NOTIFIER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_EVENT_NOTIFIER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 15 matching lines...) Expand all
26 API_RESOURCE_EVENT_TRANSFER_COMPLETE, 26 API_RESOURCE_EVENT_TRANSFER_COMPLETE,
27 }; 27 };
28 28
29 extern const char kSrcIdKey[]; 29 extern const char kSrcIdKey[];
30 30
31 // ApiResourceEventNotifier knows how to send an event to a specific app's 31 // ApiResourceEventNotifier knows how to send an event to a specific app's
32 // onEvent handler. 32 // onEvent handler.
33 class ApiResourceEventNotifier 33 class ApiResourceEventNotifier
34 : public base::RefCountedThreadSafe<ApiResourceEventNotifier> { 34 : public base::RefCountedThreadSafe<ApiResourceEventNotifier> {
35 public: 35 public:
36 ApiResourceEventNotifier(EventRouter* router, 36 ApiResourceEventNotifier(EventRouter* router, Profile* profile,
37 Profile* profile,
38 const std::string& src_extension_id, int src_id, 37 const std::string& src_extension_id, int src_id,
39 const GURL& src_url); 38 const GURL& src_url);
40 39
41 virtual void OnTransferComplete(UsbTransferStatus status, 40 virtual void OnTransferComplete(UsbTransferStatus status,
42 const std::string& error, 41 const std::string& error,
43 base::BinaryValue* data); 42 base::BinaryValue* data);
44 43
45 static std::string ApiResourceEventTypeToString( 44 static std::string ApiResourceEventTypeToString(
46 ApiResourceEventType event_type); 45 ApiResourceEventType event_type);
47 46
47 const std::string& src_extension_id() const { return src_extension_id_; }
48
48 private: 49 private:
49 friend class base::RefCountedThreadSafe<ApiResourceEventNotifier>; 50 friend class base::RefCountedThreadSafe<ApiResourceEventNotifier>;
50 friend class MockApiResourceEventNotifier; 51 friend class MockApiResourceEventNotifier;
51 52
52 virtual ~ApiResourceEventNotifier(); 53 virtual ~ApiResourceEventNotifier();
53 54
54 void DispatchEvent(const std::string &extension, DictionaryValue* event); 55 void DispatchEvent(const std::string &extension, DictionaryValue* event);
55 void DispatchEventOnUIThread(const std::string& extension, 56 void DispatchEventOnUIThread(const std::string& extension,
56 DictionaryValue* event); 57 DictionaryValue* event);
57 DictionaryValue* CreateApiResourceEvent(ApiResourceEventType event_type); 58 DictionaryValue* CreateApiResourceEvent(ApiResourceEventType event_type);
58 59
59 void SendEventWithResultCode(const std::string& extension, 60 void SendEventWithResultCode(const std::string& extension,
60 ApiResourceEventType event_type, 61 ApiResourceEventType event_type,
61 int result_code); 62 int result_code);
62 63
63 EventRouter* router_; 64 EventRouter* router_;
64 Profile* profile_; 65 Profile* profile_;
65 std::string src_extension_id_; 66 std::string src_extension_id_;
66 int src_id_; 67 int src_id_;
67 GURL src_url_; 68 GURL src_url_;
68 69
69 DISALLOW_COPY_AND_ASSIGN(ApiResourceEventNotifier); 70 DISALLOW_COPY_AND_ASSIGN(ApiResourceEventNotifier);
70 }; 71 };
71 72
72 } // namespace extensions 73 } // namespace extensions
73 74
74 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_EVENT_NOTIFIER_H_ 75 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_EVENT_NOTIFIER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/api_resource.cc ('k') | chrome/browser/extensions/api/api_resource_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698