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 "blimp/client/core/blimp_navigation_controller_impl.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/location.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/threading/thread_task_runner_handle.h" | |
11 #include "blimp/client/core/blimp_navigation_controller_delegate.h" | |
12 | |
13 namespace blimp { | |
14 namespace client { | |
15 | |
16 BlimpNavigationControllerImpl::BlimpNavigationControllerImpl( | |
17 BlimpNavigationControllerDelegate* delegate) | |
18 : delegate_(delegate), weak_ptr_factory_(this) {} | |
19 | |
20 BlimpNavigationControllerImpl::~BlimpNavigationControllerImpl() = default; | |
21 | |
22 void BlimpNavigationControllerImpl::LoadURL(const GURL& url) { | |
23 current_url_ = url; | |
24 // Temporary trick to ensure that the delegate is not invoked before this | |
25 // method has finished executing. This enables tests to test the | |
26 // asynchronous nature of the API. | |
27 // TODO(shaktisahu): Remove this after integration with NavigationFeature. | |
28 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
29 FROM_HERE, | |
30 base::Bind(&BlimpNavigationControllerImpl::NotifyDelegateURLLoaded, | |
31 weak_ptr_factory_.GetWeakPtr(), url)); | |
32 } | |
33 | |
34 const GURL& BlimpNavigationControllerImpl::GetURL() { | |
35 return current_url_; | |
36 } | |
37 | |
38 void BlimpNavigationControllerImpl::NotifyDelegateURLLoaded(const GURL& url) { | |
39 delegate_->NotifyURLLoaded(url); | |
40 } | |
41 | |
42 } // namespace client | |
43 } // namespace blimp | |
OLD | NEW |