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.
4
5#ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_PERMISSIONS_H_
6#define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_PERMISSIONS_H_
7
8#include "base/macros.h"
9#include "third_party/WebKit/public/web/WebPermissionClient.h"
10
11namespace content {
12
13class WebTestDelegate;
14
15class WebPermissions : public blink::WebPermissionClient {
16 public:
17  WebPermissions();
18  virtual ~WebPermissions();
19
20  // blink::WebPermissionClient:
21  virtual bool allowImage(bool enabledPerSettings,
22                          const blink::WebURL& imageURL);
23  virtual bool allowMedia(const blink::WebURL& mediaURL);
24  virtual bool allowScriptFromSource(bool enabledPerSettings,
25                                     const blink::WebURL& scriptURL);
26  virtual bool allowStorage(bool local);
27  virtual bool allowPlugins(bool enabledPerSettings);
28  virtual bool allowDisplayingInsecureContent(bool enabledPerSettings,
29                                              const blink::WebSecurityOrigin&,
30                                              const blink::WebURL&);
31  virtual bool allowRunningInsecureContent(bool enabledPerSettings,
32                                           const blink::WebSecurityOrigin&,
33                                           const blink::WebURL&);
34
35  // Hooks to set the different policies.
36  void SetImagesAllowed(bool);
37  void SetMediaAllowed(bool);
38  void SetScriptsAllowed(bool);
39  void SetStorageAllowed(bool);
40  void SetPluginsAllowed(bool);
41  void SetDisplayingInsecureContentAllowed(bool);
42  void SetRunningInsecureContentAllowed(bool);
43
44  void SetDelegate(WebTestDelegate*);
45  void SetDumpCallbacks(bool);
46
47  // Resets the policy to allow everything, except for running insecure content.
48  void Reset();
49
50 private:
51  WebTestDelegate* delegate_;
52  bool dump_callbacks_;
53
54  bool images_allowed_;
55  bool media_allowed_;
56  bool scripts_allowed_;
57  bool storage_allowed_;
58  bool plugins_allowed_;
59  bool displaying_insecure_content_allowed_;
60  bool running_insecure_content_allowed_;
61
62  DISALLOW_COPY_AND_ASSIGN(WebPermissions);
63};
64
65}  // namespace content
66
67#endif  // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_PERMISSIONS_H_
68