Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / renderer / xwalk_render_process_observer_generic.h
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5
6 #ifndef XWALK_RUNTIME_RENDERER_XWALK_RENDER_PROCESS_OBSERVER_GENERIC_H_
7 #define XWALK_RUNTIME_RENDERER_XWALK_RENDER_PROCESS_OBSERVER_GENERIC_H_
8
9 #include <string>
10
11 #include "base/compiler_specific.h"
12 #include "content/public/renderer/render_process_observer.h"
13 #include "url/gurl.h"
14 #include "v8/include/v8.h"
15 #include "xwalk/application/browser/application_security_policy.h"
16
17 namespace blink {
18 class WebFrame;
19 }  // namespace blink
20
21 namespace xwalk {
22
23 // FIXME: Using filename "xwalk_render_process_observer_generic.cc(h)" temporary
24 // , due to the conflict filename with Android port.
25 // A RenderViewObserver implementation used for handling XWalkView
26 // specific render-process wide IPC messages.
27 class XWalkRenderProcessObserver : public content::RenderProcessObserver {
28  public:
29   XWalkRenderProcessObserver();
30   virtual ~XWalkRenderProcessObserver();
31
32   // content::RenderProcessObserver implementation.
33   bool OnControlMessageReceived(const IPC::Message& message) override;
34   void WebKitInitialized() override;
35   void OnRenderProcessShutdown() override;
36
37   bool IsWarpMode() const {
38     return security_mode_ == application::ApplicationSecurityPolicy::WARP;
39   }
40   bool IsCSPMode() const {
41     return security_mode_ == application::ApplicationSecurityPolicy::CSP;
42   }
43
44   const GURL& app_url() const { return app_url_; }
45 #if defined(OS_TIZEN)
46   std::string GetOverridenUserAgent() const;
47 #endif
48
49  private:
50   void OnSetAccessWhiteList(
51       const GURL& source, const GURL& dest, bool allow_subdomains);
52   void OnEnableSecurityMode(
53       const GURL& url,
54       application::ApplicationSecurityPolicy::SecurityMode mode);
55   void OnSuspendJSEngine(bool is_pause);
56 #if defined(OS_TIZEN)
57   void OnUserAgentChanged(const std::string& userAgentString);
58   std::string overriden_user_agent_;
59 #endif
60
61   bool is_blink_initialized_;
62   bool is_suspended_;
63   application::ApplicationSecurityPolicy::SecurityMode security_mode_;
64   GURL app_url_;
65 };
66 }  // namespace xwalk
67
68 #endif  // XWALK_RUNTIME_RENDERER_XWALK_RENDER_PROCESS_OBSERVER_GENERIC_H_