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

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: Kevin's comments 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" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "blimp/client/core/contents/blimp_navigation_controller_delegate.h" 11 #include "blimp/client/core/contents/blimp_navigation_controller_delegate.h"
12 12
13 namespace {
14 // TODO(shaktisahu): NavigationFeature currently needs a tab_id. Remove this
15 // later when it is fully integrated with BlimpClientContext.
16 const int kDummyTabId = 0;
Kevin M 2016/07/29 21:05:32 We should use a shared constant instead of redefin
shaktisahu 2016/07/29 22:57:30 Acknowledged.
17 } // namespace
18
13 namespace blimp { 19 namespace blimp {
14 namespace client { 20 namespace client {
15 21
16 BlimpNavigationControllerImpl::BlimpNavigationControllerImpl( 22 BlimpNavigationControllerImpl::BlimpNavigationControllerImpl(
17 BlimpNavigationControllerDelegate* delegate) 23 BlimpNavigationControllerDelegate* delegate,
18 : delegate_(delegate), weak_ptr_factory_(this) {} 24 NavigationFeature* feature)
25 : navigation_feature_(feature), delegate_(delegate) {
26 if (navigation_feature_)
Kevin M 2016/07/29 21:05:32 Why would this be non-null? If there's no reason,
shaktisahu 2016/07/29 22:57:30 Yea, I should DCHECK. But currently the hookup is
27 navigation_feature_->SetDelegate(kDummyTabId, this);
28 }
19 29
20 BlimpNavigationControllerImpl::~BlimpNavigationControllerImpl() = default; 30 BlimpNavigationControllerImpl::~BlimpNavigationControllerImpl() = default;
21 31
32 void BlimpNavigationControllerImpl::SetNavigationFeatureForTesting(
33 NavigationFeature* feature) {
34 navigation_feature_ = feature;
35 navigation_feature_->SetDelegate(kDummyTabId, this);
36 }
37
22 void BlimpNavigationControllerImpl::LoadURL(const GURL& url) { 38 void BlimpNavigationControllerImpl::LoadURL(const GURL& url) {
23 current_url_ = url; 39 current_url_ = url;
24 // Temporary trick to ensure that the delegate is not invoked before this 40 navigation_feature_->NavigateToUrlText(kDummyTabId, current_url_.spec());
25 // method has finished executing. This enables tests to test the 41 }
26 // asynchronous nature of the API. 42
27 // TODO(shaktisahu): Remove this after integration with NavigationFeature. 43 void BlimpNavigationControllerImpl::Reload() {
28 base::ThreadTaskRunnerHandle::Get()->PostTask( 44 navigation_feature_->Reload(kDummyTabId);
29 FROM_HERE, 45 }
30 base::Bind(&BlimpNavigationControllerImpl::NotifyDelegateURLLoaded, 46
31 weak_ptr_factory_.GetWeakPtr(), url)); 47 bool BlimpNavigationControllerImpl::CanGoBack() const {
48 // TODO(shaktisahu): Implement the client-side logic.
Kevin M 2016/07/29 21:05:32 Replace these TODOs with NOTIMPLEMENTED()
shaktisahu 2016/07/29 22:57:30 Done.
49 return false;
50 }
51
52 bool BlimpNavigationControllerImpl::CanGoForward() const {
53 // TODO(shaktisahu): Implement the client-side logic.
54 return false;
55 }
56
57 void BlimpNavigationControllerImpl::GoBack() {
58 navigation_feature_->GoBack(kDummyTabId);
59 }
60
61 void BlimpNavigationControllerImpl::GoForward() {
62 navigation_feature_->GoForward(kDummyTabId);
32 } 63 }
33 64
34 const GURL& BlimpNavigationControllerImpl::GetURL() { 65 const GURL& BlimpNavigationControllerImpl::GetURL() {
35 return current_url_; 66 return current_url_;
36 } 67 }
37 68
38 void BlimpNavigationControllerImpl::NotifyDelegateURLLoaded(const GURL& url) { 69 void BlimpNavigationControllerImpl::OnUrlChanged(int tab_id, const GURL& url) {
39 delegate_->NotifyURLLoaded(url); 70 delegate_->OnNavigationStateChanged();
71 }
72
73 void BlimpNavigationControllerImpl::OnFaviconChanged(int tab_id,
74 const SkBitmap& favicon) {
75 delegate_->OnNavigationStateChanged();
76 }
77
78 void BlimpNavigationControllerImpl::OnTitleChanged(int tab_id,
79 const std::string& title) {
80 delegate_->OnNavigationStateChanged();
81 }
82
83 void BlimpNavigationControllerImpl::OnLoadingChanged(int tab_id, bool loading) {
84 delegate_->OnNavigationStateChanged();
85 }
86
87 void BlimpNavigationControllerImpl::OnPageLoadStatusUpdate(int tab_id,
88 bool completed) {
89 delegate_->OnNavigationStateChanged();
40 } 90 }
41 91
42 } // namespace client 92 } // namespace client
43 } // namespace blimp 93 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698