OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/renderer/safe_browsing/render_view_fake_resources_test.h" | 5 #include "chrome/renderer/safe_browsing/render_view_fake_resources_test.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/process.h" | 10 #include "base/process.h" |
11 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
12 #include "chrome/common/dom_storage_common.h" | 12 #include "chrome/common/dom_storage_common.h" |
13 #include "chrome/common/main_function_params.h" | 13 #include "chrome/common/main_function_params.h" |
14 #include "chrome/common/render_messages.h" | 14 #include "chrome/common/render_messages.h" |
15 #include "chrome/common/render_messages_params.h" | 15 #include "chrome/common/render_messages_params.h" |
16 #include "chrome/common/resource_response.h" | 16 #include "chrome/common/resource_response.h" |
17 #include "chrome/common/sandbox_init_wrapper.h" | 17 #include "chrome/common/sandbox_init_wrapper.h" |
18 #include "chrome/renderer/mock_render_process.h" | 18 #include "chrome/renderer/mock_render_process.h" |
19 #include "chrome/renderer/render_thread.h" | 19 #include "chrome/renderer/render_thread.h" |
20 #include "chrome/renderer/render_view.h" | 20 #include "chrome/renderer/render_view.h" |
21 #include "chrome/renderer/renderer_main_platform_delegate.h" | 21 #include "chrome/renderer/renderer_main_platform_delegate.h" |
22 #include "googleurl/src/gurl.h" | 22 #include "googleurl/src/gurl.h" |
23 #include "net/base/upload_data.h" | 23 #include "net/base/upload_data.h" |
24 #include "net/http/http_response_headers.h" | 24 #include "net/http/http_response_headers.h" |
25 #include "net/url_request/url_request_status.h" | 25 #include "net/url_request/url_request_status.h" |
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" |
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" |
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
30 #include "webkit/glue/webkit_glue.h" | 31 #include "webkit/glue/webkit_glue.h" |
31 | 32 |
32 namespace safe_browsing { | 33 namespace safe_browsing { |
33 | 34 |
34 const int32 RenderViewFakeResourcesTest::kViewId = 5; | 35 const int32 RenderViewFakeResourcesTest::kViewId = 5; |
35 | 36 |
36 RenderViewFakeResourcesTest::RenderViewFakeResourcesTest() {} | 37 RenderViewFakeResourcesTest::RenderViewFakeResourcesTest() {} |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 119 } |
119 | 120 |
120 void RenderViewFakeResourcesTest::LoadURLWithPost(const std::string& url) { | 121 void RenderViewFakeResourcesTest::LoadURLWithPost(const std::string& url) { |
121 GURL g_url(url); | 122 GURL g_url(url); |
122 WebKit::WebURLRequest request(g_url); | 123 WebKit::WebURLRequest request(g_url); |
123 request.setHTTPMethod(WebKit::WebString::fromUTF8("POST")); | 124 request.setHTTPMethod(WebKit::WebString::fromUTF8("POST")); |
124 GetMainFrame()->loadRequest(request); | 125 GetMainFrame()->loadRequest(request); |
125 message_loop_.Run(); | 126 message_loop_.Run(); |
126 } | 127 } |
127 | 128 |
| 129 void RenderViewFakeResourcesTest::GoBack() { |
| 130 WebKit::WebFrame* frame = GetMainFrame(); |
| 131 frame->loadHistoryItem(frame->previousHistoryItem()); |
| 132 message_loop_.Run(); |
| 133 } |
| 134 |
128 void RenderViewFakeResourcesTest::OnDidStopLoading() { | 135 void RenderViewFakeResourcesTest::OnDidStopLoading() { |
129 message_loop_.Quit(); | 136 message_loop_.Quit(); |
130 } | 137 } |
131 | 138 |
132 void RenderViewFakeResourcesTest::OnRequestResource( | 139 void RenderViewFakeResourcesTest::OnRequestResource( |
133 const IPC::Message& message, | 140 const IPC::Message& message, |
134 int request_id, | 141 int request_id, |
135 const ViewHostMsg_Resource_Request& request_data) { | 142 const ViewHostMsg_Resource_Request& request_data) { |
136 std::string headers, body; | 143 std::string headers, body; |
137 std::map<std::string, std::string>::const_iterator it = | 144 std::map<std::string, std::string>::const_iterator it = |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 177 |
171 void RenderViewFakeResourcesTest::OnRenderViewReady() { | 178 void RenderViewFakeResourcesTest::OnRenderViewReady() { |
172 // Grab a pointer to the new view using RenderViewVisitor. | 179 // Grab a pointer to the new view using RenderViewVisitor. |
173 ASSERT_TRUE(!view_); | 180 ASSERT_TRUE(!view_); |
174 RenderView::ForEach(this); | 181 RenderView::ForEach(this); |
175 ASSERT_TRUE(view_); | 182 ASSERT_TRUE(view_); |
176 message_loop_.Quit(); | 183 message_loop_.Quit(); |
177 } | 184 } |
178 | 185 |
179 } // namespace safe_browsing | 186 } // namespace safe_browsing |
OLD | NEW |