OLD | NEW |
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 "content/public/test/layouttest_support.h" | 5 #include "content/public/test/layouttest_support.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 |
| 9 #include <algorithm> |
| 10 #include <unordered_map> |
8 #include <utility> | 11 #include <utility> |
9 | 12 |
10 #include "base/callback.h" | 13 #include "base/callback.h" |
11 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
12 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
13 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
15 #include "build/build_config.h" | 18 #include "build/build_config.h" |
16 #include "cc/base/switches.h" | 19 #include "cc/base/switches.h" |
17 #include "cc/output/copy_output_request.h" | 20 #include "cc/output/copy_output_request.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 256 |
254 void FetchManifest(blink::WebView* view, const GURL& url, | 257 void FetchManifest(blink::WebView* view, const GURL& url, |
255 const FetchManifestCallback& callback) { | 258 const FetchManifestCallback& callback) { |
256 ManifestFetcher* fetcher = new ManifestFetcher(url); | 259 ManifestFetcher* fetcher = new ManifestFetcher(url); |
257 std::unique_ptr<ManifestFetcher> autodeleter(fetcher); | 260 std::unique_ptr<ManifestFetcher> autodeleter(fetcher); |
258 | 261 |
259 // Start is called on fetcher which is also bound to the callback. | 262 // Start is called on fetcher which is also bound to the callback. |
260 // A raw pointer is used instead of a scoped_ptr as base::Passes passes | 263 // A raw pointer is used instead of a scoped_ptr as base::Passes passes |
261 // ownership and thus nulls the scoped_ptr. On MSVS this happens before | 264 // ownership and thus nulls the scoped_ptr. On MSVS this happens before |
262 // the call to Start, resulting in a crash. | 265 // the call to Start, resulting in a crash. |
263 fetcher->Start(view->MainFrame(), false, | 266 CHECK(view->MainFrame()->IsWebLocalFrame()) |
| 267 << "This function cannot be called if the main frame is not a " |
| 268 "local frame."; |
| 269 fetcher->Start(view->MainFrame()->ToWebLocalFrame(), false, |
264 base::Bind(&FetchManifestDoneCallback, | 270 base::Bind(&FetchManifestDoneCallback, |
265 base::Passed(&autodeleter), callback)); | 271 base::Passed(&autodeleter), callback)); |
266 } | 272 } |
267 | 273 |
268 void SetMockGamepadProvider(std::unique_ptr<RendererGamepadProvider> provider) { | 274 void SetMockGamepadProvider(std::unique_ptr<RendererGamepadProvider> provider) { |
269 RenderThreadImpl::current_blink_platform_impl() | 275 RenderThreadImpl::current_blink_platform_impl() |
270 ->SetPlatformEventObserverForTesting(blink::kWebPlatformEventTypeGamepad, | 276 ->SetPlatformEventObserverForTesting(blink::kWebPlatformEventTypeGamepad, |
271 std::move(provider)); | 277 std::move(provider)); |
272 } | 278 } |
273 | 279 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 } | 550 } |
545 | 551 |
546 std::string DumpHistoryItem(HistoryEntry::HistoryNode* node, | 552 std::string DumpHistoryItem(HistoryEntry::HistoryNode* node, |
547 int indent, | 553 int indent, |
548 bool is_current_index) { | 554 bool is_current_index) { |
549 std::string result; | 555 std::string result; |
550 | 556 |
551 const blink::WebHistoryItem& item = node->item(); | 557 const blink::WebHistoryItem& item = node->item(); |
552 if (is_current_index) { | 558 if (is_current_index) { |
553 result.append("curr->"); | 559 result.append("curr->"); |
554 result.append(indent - 6, ' '); // 6 == "curr->".length() | 560 result.append(indent - 6, ' '); // 6 == "curr->".length() |
555 } else { | 561 } else { |
556 result.append(indent, ' '); | 562 result.append(indent, ' '); |
557 } | 563 } |
558 | 564 |
559 std::string url = | 565 std::string url = |
560 test_runner::NormalizeLayoutTestURL(item.UrlString().Utf8()); | 566 test_runner::NormalizeLayoutTestURL(item.UrlString().Utf8()); |
561 result.append(url); | 567 result.append(url); |
562 if (!item.Target().IsEmpty()) { | 568 if (!item.Target().IsEmpty()) { |
563 result.append(" (in frame \""); | 569 result.append(" (in frame \""); |
564 result.append(item.Target().Utf8()); | 570 result.append(item.Target().Utf8()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 } | 611 } |
606 } | 612 } |
607 | 613 |
608 bool IsNavigationInitiatedByRenderer(const blink::WebURLRequest& request) { | 614 bool IsNavigationInitiatedByRenderer(const blink::WebURLRequest& request) { |
609 RequestExtraData* extra_data = | 615 RequestExtraData* extra_data = |
610 static_cast<RequestExtraData*>(request.GetExtraData()); | 616 static_cast<RequestExtraData*>(request.GetExtraData()); |
611 return extra_data && extra_data->navigation_initiated_by_renderer(); | 617 return extra_data && extra_data->navigation_initiated_by_renderer(); |
612 } | 618 } |
613 | 619 |
614 } // namespace content | 620 } // namespace content |
OLD | NEW |