Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 EXTENSIONS_RENDERER_EXTENSION_BINDINGS_SYSTEM_H_ | |
| 6 #define EXTENSIONS_RENDERER_EXTENSION_BINDINGS_SYSTEM_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 namespace base { | |
| 11 class DictionaryValue; | |
| 12 class ListValue; | |
| 13 } | |
| 14 | |
| 15 namespace extensions { | |
| 16 class RequestSender; | |
| 17 class ScriptContext; | |
| 18 | |
| 19 // The class responsible for creating extension bindings in different contexts, | |
| 20 // as well as dispatching requests and handling responses, and dispatching | |
| 21 // events to listeners. | |
| 22 // This is designed to be used on a single thread, but should be safe to use on | |
| 23 // threads other than the main thread (so that worker threads can have extension | |
| 24 // bindings). | |
| 25 class ExtensionBindingsSystem { | |
| 26 public: | |
| 27 virtual ~ExtensionBindingsSystem() {} | |
| 28 | |
| 29 // Called when a new ScriptContext is created. | |
| 30 virtual void DidCreateScriptContext(ScriptContext* context) = 0; | |
| 31 | |
| 32 // Called when a ScriptContext is about to be released. | |
| 33 virtual void WillReleaseScriptContext(ScriptContext* context) = 0; | |
| 34 | |
| 35 // Updates the bindings for a given |context|. This happens at initialization, | |
| 36 // but also when e.g. an extension gets updated permissions. | |
| 37 virtual void UpdateBindingsForContext(ScriptContext* context) = 0; | |
| 38 | |
| 39 // Dispatches an event with the given |name|, |event_args|, and | |
| 40 // |filtering_info| in the given |context|. | |
| 41 virtual void DispatchEventInContext( | |
| 42 const std::string& event_name, | |
| 43 const base::ListValue* event_args, | |
| 44 const base::DictionaryValue* filtering_info, | |
| 45 ScriptContext* context) = 0; | |
| 46 | |
| 47 // Handles the response associated with the given |id|. | |
|
lazyboy
2016/11/19 03:23:01
|request_id| or just id to use it as a word
Devlin
2016/11/21 19:29:41
Done.
| |
| 48 virtual void HandleResponse(int request_id, | |
| 49 bool success, | |
| 50 const base::ListValue& response, | |
| 51 const std::string& error) = 0; | |
| 52 | |
| 53 // Returns the associated RequestSender, if any. | |
| 54 // TODO(devlin): Factor this out. | |
| 55 virtual RequestSender* GetRequestSender() = 0; | |
| 56 }; | |
| 57 | |
| 58 } // namespace extensions | |
| 59 | |
| 60 #endif // EXTENSIONS_RENDERER_EXTENSION_BINDINGS_SYSTEM_H_ | |
| OLD | NEW |