1 // Copyright 2014 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.
5 #ifndef EXTENSIONS_RENDERER_DISPATCHER_DELEGATE_H
6 #define EXTENSIONS_RENDERER_DISPATCHER_DELEGATE_H
11 #include "base/memory/scoped_ptr.h"
12 #include "extensions/common/features/feature.h"
13 #include "v8/include/v8.h"
19 namespace extensions
{
23 class ResourceBundleSourceMap
;
27 // Base class and default implementation for an extensions::Dispacher delegate.
28 // DispatcherDelegate can be used to override and extend the behavior of the
29 // extensions system's renderer side.
30 class DispatcherDelegate
{
32 virtual ~DispatcherDelegate() {}
34 // Creates a new ScriptContext for a given v8 context.
35 virtual scoped_ptr
<ScriptContext
> CreateScriptContext(
36 const v8::Handle
<v8::Context
>& v8_context
,
37 blink::WebFrame
* frame
,
38 const Extension
* extension
,
39 Feature::Context context_type
) = 0;
41 // Initializes origin permissions for a newly created extension context.
42 virtual void InitOriginPermissions(const Extension
* extension
,
43 bool is_extension_active
) {}
45 // Includes additional native handlers in a ScriptContext's ModuleSystem.
46 virtual void RegisterNativeHandlers(Dispatcher
* dispatcher
,
47 ModuleSystem
* module_system
,
48 ScriptContext
* context
) {}
50 // Includes additional source resources into the resource map.
51 virtual void PopulateSourceMap(ResourceBundleSourceMap
* source_map
) {}
53 // Requires additional modules within an extension context's module system.
54 virtual void RequireAdditionalModules(ScriptContext
* context
,
55 bool is_within_platform_app
) {}
57 // Allows the delegate to respond to an updated set of active extensions in
59 virtual void OnActiveExtensionsUpdated(
60 const std::set
<std::string
>& extension_ids
) {}
62 // Sets the current Chrome channel.
63 // TODO(rockot): This doesn't belong in a generic extensions system interface.
64 // See http://crbug.com/368431.
65 virtual void SetChannel(int channel
) {}
67 // Clears extension permissions specific to a given tab.
68 // TODO(rockot): This doesn't belong in a generic extensions system interface.
69 // See http://crbug.com/368431.
70 virtual void ClearTabSpecificPermissions(
71 const extensions::Dispatcher
* dispatcher
,
73 const std::vector
<std::string
>& extension_ids
) {}
75 // Updates extension permissions specific to a given tab.
76 // TODO(rockot): This doesn't belong in a generic extensions system interface.
77 // See http://crbug.com/368431.
78 virtual void UpdateTabSpecificPermissions(
79 const extensions::Dispatcher
* dispatcher
,
82 const std::string
& extension_id
,
83 const extensions::URLPatternSet
& origin_set
) {}
85 // Allows the delegate to respond to reports from the browser about WebRequest
86 // API usage from within this process.
87 virtual void HandleWebRequestAPIUsage(bool webrequest_used
) {}
90 } // namespace extensions
92 #endif // EXTENSIONS_RENDERER_DISPATCHER_DELEGATE_H