summaryrefslogtreecommitdiffstats
path: root/android_webview/lib/aw_content_browser_client.cc
blob: d44a475755b544eca4744e03a13a889aeea6117d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "android_webview/lib/aw_content_browser_client.h"

#include "android_webview/browser/aw_cookie_access_policy.h"
#include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h"
#include "android_webview/common/url_constants.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/render_process_host.h"

namespace android_webview {

AwContentBrowserClient::AwContentBrowserClient()
    : ChromeContentBrowserClient() {
}

AwContentBrowserClient::~AwContentBrowserClient() {
}

void AwContentBrowserClient::RenderProcessHostCreated(
    content::RenderProcessHost* host) {
  // Grant content: scheme to the whole process, since we impose per-view
  // access checks.
  content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(
      host->GetID(), android_webview::kContentScheme);
}

void AwContentBrowserClient::ResourceDispatcherHostCreated() {
  ChromeContentBrowserClient::ResourceDispatcherHostCreated();
  AwResourceDispatcherHostDelegate::ResourceDispatcherHostCreated();
}

bool AwContentBrowserClient::AllowGetCookie(const GURL& url,
                                            const GURL& first_party,
                                            const net::CookieList& cookie_list,
                                            content::ResourceContext* context,
                                            int render_process_id,
                                            int render_view_id) {
  // Not base-calling into ChromeContentBrowserClient as we are not dependent
  // on chrome/ for any cookie policy decisions.
  return AwCookieAccessPolicy::GetInstance()->AllowGetCookie(url,
                                                             first_party,
                                                             cookie_list,
                                                             context,
                                                             render_process_id,
                                                             render_view_id);
}

bool AwContentBrowserClient::AllowSetCookie(const GURL& url,
                                            const GURL& first_party,
                                            const std::string& cookie_line,
                                            content::ResourceContext* context,
                                            int render_process_id,
                                            int render_view_id,
                                            net::CookieOptions* options) {
  // Not base-calling into ChromeContentBrowserClient as we are not dependent
  // on chrome/ for any cookie policy decisions.
  return AwCookieAccessPolicy::GetInstance()->AllowSetCookie(url,
                                                             first_party,
                                                             cookie_line,
                                                             context,
                                                             render_process_id,
                                                             render_view_id,
                                                             options);
}

}  // namespace android_webview