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

Side by Side Diff: blimp/client/core/contents/blimp_navigation_controller_impl.cc

Issue 2058263002: Tied up BlimpNavigationController to NavigationFeature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blimp_core
Patch Set: Removed BlimpContentsTest.java Created 4 years, 4 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 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 "blimp/client/core/contents/blimp_navigation_controller_impl.h" 5 #include "blimp/client/core/contents/blimp_navigation_controller_impl.h"
6 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/contents/blimp_navigation_controller_delegate.h" 7 #include "blimp/client/core/contents/blimp_navigation_controller_delegate.h"
12 8
9 namespace {
10 // TODO(shaktisahu): NavigationFeature currently needs a tab_id. Remove this
11 // later when it is fully integrated with BlimpClientContext.
12 const int kDummyTabId = 0;
13 } // namespace
14
13 namespace blimp { 15 namespace blimp {
14 namespace client { 16 namespace client {
15 17
16 BlimpNavigationControllerImpl::BlimpNavigationControllerImpl( 18 BlimpNavigationControllerImpl::BlimpNavigationControllerImpl(
17 BlimpNavigationControllerDelegate* delegate) 19 BlimpNavigationControllerDelegate* delegate,
18 : delegate_(delegate), weak_ptr_factory_(this) {} 20 NavigationFeature* feature)
21 : navigation_feature_(feature), delegate_(delegate) {
22 if (navigation_feature_)
23 navigation_feature_->SetDelegate(kDummyTabId, this);
24 }
19 25
20 BlimpNavigationControllerImpl::~BlimpNavigationControllerImpl() = default; 26 BlimpNavigationControllerImpl::~BlimpNavigationControllerImpl() = default;
21 27
28 void BlimpNavigationControllerImpl::SetNavigationFeatureForTesting(
29 NavigationFeature* feature) {
30 navigation_feature_ = feature;
31 navigation_feature_->SetDelegate(kDummyTabId, this);
32 }
33
22 void BlimpNavigationControllerImpl::LoadURL(const GURL& url) { 34 void BlimpNavigationControllerImpl::LoadURL(const GURL& url) {
23 current_url_ = url; 35 current_url_ = url;
24 // Temporary trick to ensure that the delegate is not invoked before this 36 navigation_feature_->NavigateToUrlText(kDummyTabId, current_url_.spec());
25 // method has finished executing. This enables tests to test the 37 }
26 // asynchronous nature of the API. 38
27 // TODO(shaktisahu): Remove this after integration with NavigationFeature. 39 void BlimpNavigationControllerImpl::Reload() {
28 base::ThreadTaskRunnerHandle::Get()->PostTask( 40 navigation_feature_->Reload(kDummyTabId);
29 FROM_HERE, 41 }
30 base::Bind(&BlimpNavigationControllerImpl::NotifyDelegateURLLoaded, 42
31 weak_ptr_factory_.GetWeakPtr(), url)); 43 bool BlimpNavigationControllerImpl::CanGoBack() const {
44 NOTIMPLEMENTED();
45 return false;
46 }
47
48 bool BlimpNavigationControllerImpl::CanGoForward() const {
49 NOTIMPLEMENTED();
50 return false;
51 }
52
53 void BlimpNavigationControllerImpl::GoBack() {
54 navigation_feature_->GoBack(kDummyTabId);
55 }
56
57 void BlimpNavigationControllerImpl::GoForward() {
58 navigation_feature_->GoForward(kDummyTabId);
32 } 59 }
33 60
34 const GURL& BlimpNavigationControllerImpl::GetURL() { 61 const GURL& BlimpNavigationControllerImpl::GetURL() {
35 return current_url_; 62 return current_url_;
36 } 63 }
37 64
38 void BlimpNavigationControllerImpl::NotifyDelegateURLLoaded(const GURL& url) { 65 void BlimpNavigationControllerImpl::OnUrlChanged(int tab_id, const GURL& url) {
39 delegate_->NotifyURLLoaded(url); 66 delegate_->OnNavigationStateChanged();
67 }
68
69 void BlimpNavigationControllerImpl::OnFaviconChanged(int tab_id,
70 const SkBitmap& favicon) {
71 delegate_->OnNavigationStateChanged();
72 }
73
74 void BlimpNavigationControllerImpl::OnTitleChanged(int tab_id,
75 const std::string& title) {
76 delegate_->OnNavigationStateChanged();
77 }
78
79 void BlimpNavigationControllerImpl::OnLoadingChanged(int tab_id, bool loading) {
80 delegate_->OnNavigationStateChanged();
81 }
82
83 void BlimpNavigationControllerImpl::OnPageLoadStatusUpdate(int tab_id,
84 bool completed) {
85 delegate_->OnNavigationStateChanged();
40 } 86 }
41 87
42 } // namespace client 88 } // namespace client
43 } // namespace blimp 89 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698