Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / renderer_host / chrome_render_message_filter.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_RENDERER_HOST_CHROME_RENDER_MESSAGE_FILTER_H_
6 #define CHROME_BROWSER_RENDERER_HOST_CHROME_RENDER_MESSAGE_FILTER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/sequenced_task_runner_helpers.h"
13 #include "content/public/browser/browser_message_filter.h"
14 #include "third_party/WebKit/public/web/WebCache.h"
15
16 class CookieSettings;
17 class GURL;
18 class Profile;
19
20 namespace chrome_browser_net {
21 class Predictor;
22 }
23
24 namespace extensions {
25 class InfoMap;
26 }
27
28 // This class filters out incoming Chrome-specific IPC messages for the renderer
29 // process on the IPC thread.
30 class ChromeRenderMessageFilter : public content::BrowserMessageFilter {
31  public:
32   ChromeRenderMessageFilter(int render_process_id, Profile* profile);
33
34   class V8HeapStatsDetails {
35    public:
36     V8HeapStatsDetails(size_t v8_memory_allocated,
37                        size_t v8_memory_used)
38         : v8_memory_allocated_(v8_memory_allocated),
39           v8_memory_used_(v8_memory_used) {}
40     size_t v8_memory_allocated() const { return v8_memory_allocated_; }
41     size_t v8_memory_used() const { return v8_memory_used_; }
42    private:
43     size_t v8_memory_allocated_;
44     size_t v8_memory_used_;
45   };
46
47   // content::BrowserMessageFilter methods:
48   bool OnMessageReceived(const IPC::Message& message) override;
49   void OverrideThreadForMessage(const IPC::Message& message,
50                                 content::BrowserThread::ID* thread) override;
51
52  private:
53   friend class content::BrowserThread;
54   friend class base::DeleteHelper<ChromeRenderMessageFilter>;
55
56   ~ChromeRenderMessageFilter() override;
57
58   void OnDnsPrefetch(const std::vector<std::string>& hostnames);
59   void OnPreconnect(const GURL& url);
60   void OnResourceTypeStats(const blink::WebCache::ResourceTypeStats& stats);
61   void OnUpdatedCacheStats(const blink::WebCache::UsageStats& stats);
62   void OnV8HeapStats(int v8_memory_allocated, int v8_memory_used);
63
64   void OnAllowDatabase(int render_frame_id,
65                        const GURL& origin_url,
66                        const GURL& top_origin_url,
67                        const base::string16& name,
68                        const base::string16& display_name,
69                        bool* allowed);
70   void OnAllowDOMStorage(int render_frame_id,
71                          const GURL& origin_url,
72                          const GURL& top_origin_url,
73                          bool local,
74                          bool* allowed);
75   void OnRequestFileSystemAccessSync(int render_frame_id,
76                                      const GURL& origin_url,
77                                      const GURL& top_origin_url,
78                                      IPC::Message* message);
79 #if defined(ENABLE_EXTENSIONS)
80   static void FileSystemAccessedSyncOnUIThread(
81       int render_process_id,
82       int render_frame_id,
83       const GURL& url,
84       bool blocked_by_policy,
85       IPC::Message* reply_msg);
86 #endif
87   void OnRequestFileSystemAccessAsync(int render_frame_id,
88                                       int request_id,
89                                       const GURL& origin_url,
90                                       const GURL& top_origin_url);
91   void OnRequestFileSystemAccessSyncResponse(IPC::Message* reply_msg,
92                                              bool allowed);
93   void OnRequestFileSystemAccessAsyncResponse(int render_frame_id,
94                                               int request_id,
95                                               bool allowed);
96   void OnRequestFileSystemAccess(int render_frame_id,
97                                  const GURL& origin_url,
98                                  const GURL& top_origin_url,
99                                  base::Callback<void(bool)> callback);
100 #if defined(ENABLE_EXTENSIONS)
101   static void FileSystemAccessedOnUIThread(int render_process_id,
102                                            int render_frame_id,
103                                            const GURL& url,
104                                            bool allowed,
105                                            base::Callback<void(bool)> callback);
106   static void FileSystemAccessedResponse(int render_process_id,
107                                          int render_frame_id,
108                                          const GURL& url,
109                                          base::Callback<void(bool)> callback,
110                                          bool allowed);
111 #endif
112   void OnAllowIndexedDB(int render_frame_id,
113                         const GURL& origin_url,
114                         const GURL& top_origin_url,
115                         const base::string16& name,
116                         bool* allowed);
117 #if defined(ENABLE_PLUGINS)
118   void OnIsCrashReportingEnabled(bool* enabled);
119 #endif
120
121   const int render_process_id_;
122
123   // The Profile associated with our renderer process.  This should only be
124   // accessed on the UI thread!
125   Profile* profile_;
126   // The Predictor for the associated Profile. It is stored so that it can be
127   // used on the IO thread.
128   chrome_browser_net::Predictor* predictor_;
129
130   // Used to look up permissions at database creation time.
131   scoped_refptr<CookieSettings> cookie_settings_;
132
133   DISALLOW_COPY_AND_ASSIGN(ChromeRenderMessageFilter);
134 };
135
136 #endif  // CHROME_BROWSER_RENDERER_HOST_CHROME_RENDER_MESSAGE_FILTER_H_