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

Side by Side Diff: content/shell/renderer/test_runner/web_permissions.cc

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
« no previous file with comments | « content/shell/renderer/test_runner/web_permissions.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/renderer/test_runner/WebPermissions.h" 5 #include "content/shell/renderer/test_runner/web_permissions.h"
6 6
7 #include "content/shell/renderer/test_runner/TestCommon.h" 7 #include "content/shell/renderer/test_runner/TestCommon.h"
8 #include "content/shell/renderer/test_runner/WebTestDelegate.h" 8 #include "content/shell/renderer/test_runner/WebTestDelegate.h"
9 #include "third_party/WebKit/public/platform/WebCString.h" 9 #include "third_party/WebKit/public/platform/WebCString.h"
10 #include "third_party/WebKit/public/platform/WebURL.h" 10 #include "third_party/WebKit/public/platform/WebURL.h"
11 11
12 using namespace std;
13
14 namespace content { 12 namespace content {
15 13
16 WebPermissions::WebPermissions() 14 WebPermissions::WebPermissions() : delegate_(0) {
17 : m_delegate(0) 15 Reset();
18 {
19 reset();
20 } 16 }
21 17
22 WebPermissions::~WebPermissions() 18 WebPermissions::~WebPermissions() {}
23 { 19
20 bool WebPermissions::allowImage(bool enabled_per_settings,
21 const blink::WebURL& image_url) {
22 bool allowed = enabled_per_settings && images_allowed_;
23 if (dump_callbacks_ && delegate_) {
24 delegate_->printMessage(std::string("PERMISSION CLIENT: allowImage(") +
25 normalizeLayoutTestURL(image_url.spec()) + "): " +
26 (allowed ? "true" : "false") + "\n");
27 }
28 return allowed;
24 } 29 }
25 30
26 bool WebPermissions::allowImage(bool enabledPerSettings, const blink::WebURL& im ageURL) 31 bool WebPermissions::allowMedia(const blink::WebURL& image_url) {
27 { 32 bool allowed = media_allowed_;
28 bool allowed = enabledPerSettings && m_imagesAllowed; 33 if (dump_callbacks_ && delegate_)
29 if (m_dumpCallbacks && m_delegate) 34 delegate_->printMessage(std::string("PERMISSION CLIENT: allowMedia(") +
30 m_delegate->printMessage(std::string("PERMISSION CLIENT: allowImage(") + normalizeLayoutTestURL(imageURL.spec()) + "): " + (allowed ? "true" : "false") + "\n"); 35 normalizeLayoutTestURL(image_url.spec()) + "): " +
31 return allowed; 36 (allowed ? "true" : "false") + "\n");
37 return allowed;
32 } 38 }
33 39
34 bool WebPermissions::allowMedia(const blink::WebURL& imageURL) 40 bool WebPermissions::allowScriptFromSource(bool enabled_per_settings,
35 { 41 const blink::WebURL& scriptURL) {
36 bool allowed = m_mediaAllowed; 42 bool allowed = enabled_per_settings && scripts_allowed_;
37 if (m_dumpCallbacks && m_delegate) 43 if (dump_callbacks_ && delegate_) {
38 m_delegate->printMessage(std::string("PERMISSION CLIENT: allowMedia(") + normalizeLayoutTestURL(imageURL.spec()) + "): " + (allowed ? "true" : "false") + "\n"); 44 delegate_->printMessage(
39 return allowed; 45 std::string("PERMISSION CLIENT: allowScriptFromSource(") +
46 normalizeLayoutTestURL(scriptURL.spec()) + "): " +
47 (allowed ? "true" : "false") + "\n");
48 }
49 return allowed;
40 } 50 }
41 51
42 bool WebPermissions::allowScriptFromSource(bool enabledPerSettings, const blink: :WebURL& scriptURL) 52 bool WebPermissions::allowStorage(bool) {
43 { 53 return storage_allowed_;
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 } 54 }
49 55
50 bool WebPermissions::allowStorage(bool) 56 bool WebPermissions::allowPlugins(bool enabled_per_settings) {
51 { 57 return enabled_per_settings && plugins_allowed_;
52 return m_storageAllowed;
53 } 58 }
54 59
55 bool WebPermissions::allowPlugins(bool enabledPerSettings) 60 bool WebPermissions::allowDisplayingInsecureContent(
56 { 61 bool enabled_per_settings,
57 return enabledPerSettings && m_pluginsAllowed; 62 const blink::WebSecurityOrigin&,
63 const blink::WebURL&) {
64 return enabled_per_settings || displaying_insecure_content_allowed_;
58 } 65 }
59 66
60 bool WebPermissions::allowDisplayingInsecureContent(bool enabledPerSettings, con st blink::WebSecurityOrigin&, const blink::WebURL&) 67 bool WebPermissions::allowRunningInsecureContent(
61 { 68 bool enabled_per_settings,
62 return enabledPerSettings || m_displayingInsecureContentAllowed; 69 const blink::WebSecurityOrigin&,
70 const blink::WebURL&) {
71 return enabled_per_settings || running_insecure_content_allowed_;
63 } 72 }
64 73
65 bool WebPermissions::allowRunningInsecureContent(bool enabledPerSettings, const blink::WebSecurityOrigin&, const blink::WebURL&) 74 void WebPermissions::SetImagesAllowed(bool images_allowed) {
66 { 75 images_allowed_ = images_allowed;
67 return enabledPerSettings || m_runningInsecureContentAllowed;
68 } 76 }
69 77
70 void WebPermissions::setImagesAllowed(bool imagesAllowed) 78 void WebPermissions::SetMediaAllowed(bool media_allowed) {
71 { 79 media_allowed_ = media_allowed;
72 m_imagesAllowed = imagesAllowed;
73 } 80 }
74 81
75 void WebPermissions::setMediaAllowed(bool mediaAllowed) 82 void WebPermissions::SetScriptsAllowed(bool scripts_allowed) {
76 { 83 scripts_allowed_ = scripts_allowed;
77 m_mediaAllowed = mediaAllowed;
78 } 84 }
79 85
80 void WebPermissions::setScriptsAllowed(bool scriptsAllowed) 86 void WebPermissions::SetStorageAllowed(bool storage_allowed) {
81 { 87 storage_allowed_ = storage_allowed;
82 m_scriptsAllowed = scriptsAllowed;
83 } 88 }
84 89
85 void WebPermissions::setStorageAllowed(bool storageAllowed) 90 void WebPermissions::SetPluginsAllowed(bool plugins_allowed) {
86 { 91 plugins_allowed_ = plugins_allowed;
87 m_storageAllowed = storageAllowed;
88 } 92 }
89 93
90 void WebPermissions::setPluginsAllowed(bool pluginsAllowed) 94 void WebPermissions::SetDisplayingInsecureContentAllowed(bool allowed) {
91 { 95 displaying_insecure_content_allowed_ = allowed;
92 m_pluginsAllowed = pluginsAllowed;
93 } 96 }
94 97
95 void WebPermissions::setDisplayingInsecureContentAllowed(bool allowed) 98 void WebPermissions::SetRunningInsecureContentAllowed(bool allowed) {
96 { 99 running_insecure_content_allowed_ = allowed;
97 m_displayingInsecureContentAllowed = allowed;
98 } 100 }
99 101
100 void WebPermissions::setRunningInsecureContentAllowed(bool allowed) 102 void WebPermissions::SetDelegate(WebTestDelegate* delegate) {
101 { 103 delegate_ = delegate;
102 m_runningInsecureContentAllowed = allowed;
103 } 104 }
104 105
105 void WebPermissions::setDelegate(WebTestDelegate* delegate) 106 void WebPermissions::SetDumpCallbacks(bool dump_callbacks) {
106 { 107 dump_callbacks_ = dump_callbacks;
107 m_delegate = delegate;
108 } 108 }
109 109
110 void WebPermissions::setDumpCallbacks(bool dumpCallbacks) 110 void WebPermissions::Reset() {
111 { 111 dump_callbacks_ = false;
112 m_dumpCallbacks = dumpCallbacks; 112 images_allowed_ = true;
113 } 113 media_allowed_ = true;
114 114 scripts_allowed_ = true;
115 void WebPermissions::reset() 115 storage_allowed_ = true;
116 { 116 plugins_allowed_ = true;
117 m_dumpCallbacks = false; 117 displaying_insecure_content_allowed_ = false;
118 m_imagesAllowed = true; 118 running_insecure_content_allowed_ = false;
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 } 119 }
126 120
127 } // namespace content 121 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/web_permissions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698