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