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

Side by Side Diff: content/browser/renderer_host/render_view_host_unittest.cc

Issue 1836973003: Move download messages from Renderer to Frame filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: RenderViewHostTest Created 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/child_process_security_policy_impl.h" 10 #include "content/browser/child_process_security_policy_impl.h"
11 #include "content/browser/frame_host/render_frame_host_impl.h" 11 #include "content/browser/frame_host/render_frame_host_impl.h"
12 #include "content/browser/renderer_host/render_message_filter.h" 12 #include "content/browser/frame_host/render_frame_message_filter.h"
13 #include "content/browser/renderer_host/render_view_host_delegate_view.h" 13 #include "content/browser/renderer_host/render_view_host_delegate_view.h"
14 #include "content/browser/renderer_host/render_widget_helper.h" 14 #include "content/browser/renderer_host/render_widget_helper.h"
15 #include "content/common/frame_messages.h" 15 #include "content/common/frame_messages.h"
16 #include "content/common/input_messages.h" 16 #include "content/common/input_messages.h"
17 #include "content/common/view_messages.h" 17 #include "content/common/view_messages.h"
18 #include "content/public/browser/browser_context.h" 18 #include "content/public/browser/browser_context.h"
19 #include "content/public/browser/navigation_entry.h" 19 #include "content/public/browser/navigation_entry.h"
20 #include "content/public/browser/storage_partition.h" 20 #include "content/public/browser/storage_partition.h"
21 #include "content/public/common/bindings_policy.h" 21 #include "content/public/common/bindings_policy.h"
22 #include "content/public/common/drop_data.h" 22 #include "content/public/common/drop_data.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 235 }
236 236
237 TEST_F(RenderViewHostTest, RoutingIdSane) { 237 TEST_F(RenderViewHostTest, RoutingIdSane) {
238 RenderFrameHostImpl* root_rfh = 238 RenderFrameHostImpl* root_rfh =
239 contents()->GetFrameTree()->root()->current_frame_host(); 239 contents()->GetFrameTree()->root()->current_frame_host();
240 EXPECT_EQ(contents()->GetMainFrame(), root_rfh); 240 EXPECT_EQ(contents()->GetMainFrame(), root_rfh);
241 EXPECT_EQ(test_rvh()->GetProcess(), root_rfh->GetProcess()); 241 EXPECT_EQ(test_rvh()->GetProcess(), root_rfh->GetProcess());
242 EXPECT_NE(test_rvh()->GetRoutingID(), root_rfh->routing_id()); 242 EXPECT_NE(test_rvh()->GetRoutingID(), root_rfh->routing_id());
243 } 243 }
244 244
245 class TestSaveImageFromDataURL : public RenderMessageFilter { 245 class TestSaveImageFromDataURL : public RenderFrameMessageFilter {
246 public: 246 public:
247 TestSaveImageFromDataURL(BrowserContext* context) 247 TestSaveImageFromDataURL(BrowserContext* context)
248 : RenderMessageFilter(0, 248 : RenderFrameMessageFilter(
249 context, 249 0,
250 BrowserContext::GetDefaultStoragePartition(context) 250 nullptr,
251 ->GetURLRequestContext(), 251 context,
252 nullptr, 252 BrowserContext::GetDefaultStoragePartition(context)
253 nullptr, 253 ->GetURLRequestContext(),
254 nullptr, 254 nullptr) {
255 nullptr,
256 nullptr) {
257 Reset(); 255 Reset();
258 } 256 }
259 257
260 void Reset() { 258 void Reset() {
261 url_string_ = std::string(); 259 url_string_ = std::string();
262 is_downloaded_ = false; 260 is_downloaded_ = false;
263 } 261 }
264 262
265 std::string& UrlString() const { 263 std::string& UrlString() const {
266 return url_string_; 264 return url_string_;
267 } 265 }
268 266
269 bool IsDownloaded() const { 267 bool IsDownloaded() const {
270 return is_downloaded_; 268 return is_downloaded_;
271 } 269 }
272 270
273 void Test(const std::string& url) { 271 void Test(const std::string& url) {
274 OnMessageReceived(ViewHostMsg_SaveImageFromDataURL(0, 0, url)); 272 OnMessageReceived(FrameHostMsg_SaveImageFromDataURL(0, 0, url));
275 } 273 }
276 274
277 protected: 275 protected:
278 ~TestSaveImageFromDataURL() override {} 276 ~TestSaveImageFromDataURL() override {}
279 void DownloadUrl(int render_view_id, 277 void DownloadUrl(int render_view_id,
280 int render_frame_id, 278 int render_frame_id,
281 const GURL& url, 279 const GURL& url,
282 const Referrer& referrer, 280 const Referrer& referrer,
283 const base::string16& suggested_name, 281 const base::string16& suggested_name,
284 const bool use_prompt) const override { 282 const bool use_prompt) const override {
(...skipping 18 matching lines...) Expand all
303 const std::string data_url = "data:image/gif;base64," 301 const std::string data_url = "data:image/gif;base64,"
304 "R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="; 302 "R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=";
305 303
306 tester->Reset(); 304 tester->Reset();
307 tester->Test(data_url); 305 tester->Test(data_url);
308 EXPECT_EQ(tester->UrlString(), data_url); 306 EXPECT_EQ(tester->UrlString(), data_url);
309 EXPECT_TRUE(tester->IsDownloaded()); 307 EXPECT_TRUE(tester->IsDownloaded());
310 } 308 }
311 309
312 } // namespace content 310 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698