Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: content/shell/renderer/test_runner/WebPermissions.cpp

Issue 322713002: test_runner: Migrate WebPermissions to our Chromium C++ style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 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 #include "content/shell/renderer/test_runner/WebPermissions.h"
6
7 #include "content/shell/renderer/test_runner/TestCommon.h"
8 #include "content/shell/renderer/test_runner/WebTestDelegate.h"
9 #include "third_party/WebKit/public/platform/WebCString.h"
10 #include "third_party/WebKit/public/platform/WebURL.h"
11
12 using namespace std;
13
14 namespace content {
15
16 WebPermissions::WebPermissions()
17 : m_delegate(0)
18 {
19 reset();
20 }
21
22 WebPermissions::~WebPermissions()
23 {
24 }
25
26 bool WebPermissions::allowImage(bool enabledPerSettings, const blink::WebURL& im ageURL)
27 {
28 bool allowed = enabledPerSettings && m_imagesAllowed;
29 if (m_dumpCallbacks && m_delegate)
30 m_delegate->printMessage(std::string("PERMISSION CLIENT: allowImage(") + normalizeLayoutTestURL(imageURL.spec()) + "): " + (allowed ? "true" : "false") + "\n");
31 return allowed;
32 }
33
34 bool WebPermissions::allowMedia(const blink::WebURL& imageURL)
35 {
36 bool allowed = m_mediaAllowed;
37 if (m_dumpCallbacks && m_delegate)
38 m_delegate->printMessage(std::string("PERMISSION CLIENT: allowMedia(") + normalizeLayoutTestURL(imageURL.spec()) + "): " + (allowed ? "true" : "false") + "\n");
39 return allowed;
40 }
41
42 bool WebPermissions::allowScriptFromSource(bool enabledPerSettings, const blink: :WebURL& scriptURL)
43 {
44 bool allowed = enabledPerSettings && m_scriptsAllowed;
45 if (m_dumpCallbacks && m_delegate)
46 m_delegate->printMessage(std::string("PERMISSION CLIENT: allowScriptFrom Source(") + normalizeLayoutTestURL(scriptURL.spec()) + "): " + (allowed ? "true" : "false") + "\n");
47 return allowed;
48 }
49
50 bool WebPermissions::allowStorage(bool)
51 {
52 return m_storageAllowed;
53 }
54
55 bool WebPermissions::allowPlugins(bool enabledPerSettings)
56 {
57 return enabledPerSettings && m_pluginsAllowed;
58 }
59
60 bool WebPermissions::allowDisplayingInsecureContent(bool enabledPerSettings, con st blink::WebSecurityOrigin&, const blink::WebURL&)
61 {
62 return enabledPerSettings || m_displayingInsecureContentAllowed;
63 }
64
65 bool WebPermissions::allowRunningInsecureContent(bool enabledPerSettings, const blink::WebSecurityOrigin&, const blink::WebURL&)
66 {
67 return enabledPerSettings || m_runningInsecureContentAllowed;
68 }
69
70 void WebPermissions::setImagesAllowed(bool imagesAllowed)
71 {
72 m_imagesAllowed = imagesAllowed;
73 }
74
75 void WebPermissions::setMediaAllowed(bool mediaAllowed)
76 {
77 m_mediaAllowed = mediaAllowed;
78 }
79
80 void WebPermissions::setScriptsAllowed(bool scriptsAllowed)
81 {
82 m_scriptsAllowed = scriptsAllowed;
83 }
84
85 void WebPermissions::setStorageAllowed(bool storageAllowed)
86 {
87 m_storageAllowed = storageAllowed;
88 }
89
90 void WebPermissions::setPluginsAllowed(bool pluginsAllowed)
91 {
92 m_pluginsAllowed = pluginsAllowed;
93 }
94
95 void WebPermissions::setDisplayingInsecureContentAllowed(bool allowed)
96 {
97 m_displayingInsecureContentAllowed = allowed;
98 }
99
100 void WebPermissions::setRunningInsecureContentAllowed(bool allowed)
101 {
102 m_runningInsecureContentAllowed = allowed;
103 }
104
105 void WebPermissions::setDelegate(WebTestDelegate* delegate)
106 {
107 m_delegate = delegate;
108 }
109
110 void WebPermissions::setDumpCallbacks(bool dumpCallbacks)
111 {
112 m_dumpCallbacks = dumpCallbacks;
113 }
114
115 void WebPermissions::reset()
116 {
117 m_dumpCallbacks = false;
118 m_imagesAllowed = true;
119 m_mediaAllowed = true;
120 m_scriptsAllowed = true;
121 m_storageAllowed = true;
122 m_pluginsAllowed = true;
123 m_displayingInsecureContentAllowed = false;
124 m_runningInsecureContentAllowed = false;
125 }
126
127 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/WebPermissions.h ('k') | content/shell/renderer/test_runner/test_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698