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

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: More kmarshall 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"
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 // TODO(shaktisahu): DCHECK(navigation_feature_).
Kevin M 2016/08/03 16:55:15 Doesn't look like this comment suggests a future c
23 if (navigation_feature_)
24 navigation_feature_->SetDelegate(kDummyTabId, this);
25 }
19 26
20 BlimpNavigationControllerImpl::~BlimpNavigationControllerImpl() = default; 27 BlimpNavigationControllerImpl::~BlimpNavigationControllerImpl() = default;
21 28
29 void BlimpNavigationControllerImpl::SetNavigationFeatureForTesting(
30 NavigationFeature* feature) {
31 navigation_feature_ = feature;
32 navigation_feature_->SetDelegate(kDummyTabId, this);
33 }
34
22 void BlimpNavigationControllerImpl::LoadURL(const GURL& url) { 35 void BlimpNavigationControllerImpl::LoadURL(const GURL& url) {
23 current_url_ = url; 36 current_url_ = url;
24 // Temporary trick to ensure that the delegate is not invoked before this 37 navigation_feature_->NavigateToUrlText(kDummyTabId, current_url_.spec());
25 // method has finished executing. This enables tests to test the 38 }
26 // asynchronous nature of the API. 39
27 // TODO(shaktisahu): Remove this after integration with NavigationFeature. 40 void BlimpNavigationControllerImpl::Reload() {
28 base::ThreadTaskRunnerHandle::Get()->PostTask( 41 navigation_feature_->Reload(kDummyTabId);
29 FROM_HERE, 42 }
30 base::Bind(&BlimpNavigationControllerImpl::NotifyDelegateURLLoaded, 43
31 weak_ptr_factory_.GetWeakPtr(), url)); 44 bool BlimpNavigationControllerImpl::CanGoBack() const {
45 NOTIMPLEMENTED();
46 return false;
47 }
48
49 bool BlimpNavigationControllerImpl::CanGoForward() const {
50 NOTIMPLEMENTED();
51 return false;
52 }
53
54 void BlimpNavigationControllerImpl::GoBack() {
55 navigation_feature_->GoBack(kDummyTabId);
56 }
57
58 void BlimpNavigationControllerImpl::GoForward() {
59 navigation_feature_->GoForward(kDummyTabId);
32 } 60 }
33 61
34 const GURL& BlimpNavigationControllerImpl::GetURL() { 62 const GURL& BlimpNavigationControllerImpl::GetURL() {
35 return current_url_; 63 return current_url_;
36 } 64 }
37 65
38 void BlimpNavigationControllerImpl::NotifyDelegateURLLoaded(const GURL& url) { 66 void BlimpNavigationControllerImpl::OnUrlChanged(int tab_id, const GURL& url) {
39 delegate_->NotifyURLLoaded(url); 67 delegate_->OnNavigationStateChanged();
68 }
69
70 void BlimpNavigationControllerImpl::OnFaviconChanged(int tab_id,
71 const SkBitmap& favicon) {
72 delegate_->OnNavigationStateChanged();
73 }
74
75 void BlimpNavigationControllerImpl::OnTitleChanged(int tab_id,
76 const std::string& title) {
77 delegate_->OnNavigationStateChanged();
78 }
79
80 void BlimpNavigationControllerImpl::OnLoadingChanged(int tab_id, bool loading) {
81 delegate_->OnNavigationStateChanged();
82 }
83
84 void BlimpNavigationControllerImpl::OnPageLoadStatusUpdate(int tab_id,
85 bool completed) {
86 delegate_->OnNavigationStateChanged();
40 } 87 }
41 88
42 } // namespace client 89 } // namespace client
43 } // namespace blimp 90 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698