1 // Copyright (c) 2013 Intel Corporation. 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 XWALK_EXTENSIONS_EXTENSION_PROCESS_XWALK_EXTENSION_PROCESS_H_
6 #define XWALK_EXTENSIONS_EXTENSION_PROCESS_XWALK_EXTENSION_PROCESS_H_
11 #include "base/values.h"
12 #include "base/synchronization/waitable_event.h"
13 #include "base/threading/thread.h"
14 #include "ipc/ipc_channel_handle.h"
15 #include "ipc/ipc_listener.h"
16 #include "xwalk/extensions/common/xwalk_extension_permission_types.h"
17 #include "xwalk/extensions/common/xwalk_extension_server.h"
28 namespace extensions {
31 class XWalkExtensionRunner;
34 // This class represents the Extension Process itself.
35 // It not only represents the extension side of the browser <->
36 // extension process communication channel, but also the extension side
37 // of the extension <-> render process channel.
38 // It will be responsible for handling the native side (instances) of
39 // External extensions through its XWalkExtensionServer.
40 class XWalkExtensionProcess : public IPC::Listener,
41 public XWalkExtension::PermissionsDelegate {
43 XWalkExtensionProcess();
44 virtual ~XWalkExtensionProcess();
45 virtual bool CheckAPIAccessControl(const std::string& extension_name,
46 const std::string& api_name) OVERRIDE;
47 virtual bool RegisterPermissions(const std::string& extension_name,
48 const std::string& perm_table) OVERRIDE;
51 // IPC::Listener implementation.
52 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
54 // Handlers for IPC messages from XWalkExtensionProcessHost.
55 void OnRegisterExtensions(const base::FilePath& extension_path,
56 const base::ListValue& browser_variables);
58 void CreateBrowserProcessChannel();
59 void CreateRenderProcessChannel();
61 base::WaitableEvent shutdown_event_;
62 base::Thread io_thread_;
63 scoped_ptr<IPC::SyncChannel> browser_process_channel_;
64 XWalkExtensionServer extensions_server_;
65 scoped_ptr<IPC::SyncChannel> render_process_channel_;
66 IPC::ChannelHandle rp_channel_handle_;
67 typedef std::map<std::string, RuntimePermission> PermissionCacheType;
68 PermissionCacheType permission_cache_;
70 DISALLOW_COPY_AND_ASSIGN(XWalkExtensionProcess);
73 } // namespace extensions
76 #endif // XWALK_EXTENSIONS_EXTENSION_PROCESS_XWALK_EXTENSION_PROCESS_H_