| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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 "chromecast/browser/test/chromecast_browser_test_helper.h" | |
| 6 | |
| 7 #include "base/memory/ptr_util.h" | |
| 8 #include "chromecast/browser/cast_browser_context.h" | |
| 9 #include "chromecast/browser/cast_browser_process.h" | |
| 10 #include "chromecast/browser/cast_content_window.h" | |
| 11 #include "chromecast/browser/cast_media_blocker.h" | |
| 12 #include "content/public/browser/media_session.h" | |
| 13 #include "content/public/browser/web_contents.h" | |
| 14 #include "content/public/test/browser_test_utils.h" | |
| 15 #include "content/public/test/test_navigation_observer.h" | |
| 16 | |
| 17 namespace chromecast { | |
| 18 namespace shell { | |
| 19 namespace { | |
| 20 | |
| 21 class DefaultHelper : public ChromecastBrowserTestHelper { | |
| 22 public: | |
| 23 ~DefaultHelper() override {} | |
| 24 | |
| 25 content::WebContents* NavigateToURL(const GURL& url) override { | |
| 26 window_.reset(new CastContentWindow); | |
| 27 | |
| 28 web_contents_ = window_->CreateWebContents( | |
| 29 CastBrowserProcess::GetInstance()->browser_context()); | |
| 30 window_->CreateWindowTree(web_contents_.get()); | |
| 31 blocker_.reset(new CastMediaBlocker( | |
| 32 content::MediaSession::Get(web_contents_.get()), web_contents_.get())); | |
| 33 | |
| 34 content::WaitForLoadStop(web_contents_.get()); | |
| 35 content::TestNavigationObserver same_tab_observer(web_contents_.get(), 1); | |
| 36 content::NavigationController::LoadURLParams params(url); | |
| 37 params.transition_type = ui::PageTransitionFromInt( | |
| 38 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); | |
| 39 web_contents_->GetController().LoadURLWithParams(params); | |
| 40 same_tab_observer.Wait(); | |
| 41 | |
| 42 return web_contents_.get(); | |
| 43 } | |
| 44 | |
| 45 void BlockMediaLoading(bool block) override { | |
| 46 blocker_->BlockMediaLoading(block); | |
| 47 } | |
| 48 | |
| 49 private: | |
| 50 std::unique_ptr<CastContentWindow> window_; | |
| 51 std::unique_ptr<content::WebContents> web_contents_; | |
| 52 std::unique_ptr<CastMediaBlocker> blocker_; | |
| 53 }; | |
| 54 | |
| 55 } // namespace | |
| 56 | |
| 57 std::unique_ptr<ChromecastBrowserTestHelper> | |
| 58 ChromecastBrowserTestHelper::Create() { | |
| 59 return base::MakeUnique<DefaultHelper>(); | |
| 60 } | |
| 61 | |
| 62 } // namespace shell | |
| 63 } // namespace chromecast | |
| OLD | NEW |