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

Unified Diff: blimp/client/core/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: Changed BlimpContentsObserver's navigation methods to OnNavigationStateChanged Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: blimp/client/core/blimp_navigation_controller_impl.cc
diff --git a/blimp/client/core/blimp_navigation_controller_impl.cc b/blimp/client/core/blimp_navigation_controller_impl.cc
index 6c57ea09eb0aefe8f195ddde3362d4028c84236f..4dd21abd5f22e5c9f8032e13ec543dfee3940f5f 100644
--- a/blimp/client/core/blimp_navigation_controller_impl.cc
+++ b/blimp/client/core/blimp_navigation_controller_impl.cc
@@ -10,33 +10,83 @@
#include "base/threading/thread_task_runner_handle.h"
#include "blimp/client/core/blimp_navigation_controller_delegate.h"
+namespace {
+// TODO(shaktisahu): NavigationFeautre currently needs a tab_id. Remove this
David Trainor- moved to gerrit 2016/07/27 16:55:00 NavigationFeautre -> NavigationFeature.
shaktisahu 2016/07/28 19:32:51 Done.
+// later when it is fully integrated with BlimpClientContext.
+const int kDummyTabId = 0;
+} // namespace
+
namespace blimp {
namespace client {
BlimpNavigationControllerImpl::BlimpNavigationControllerImpl(
- BlimpNavigationControllerDelegate* delegate)
- : delegate_(delegate), weak_ptr_factory_(this) {}
+ BlimpNavigationControllerDelegate* delegate,
+ NavigationFeature* feature)
+ : navigation_feature_(feature), delegate_(delegate) {
+ if (navigation_feature_)
+ navigation_feature_->SetDelegate(kDummyTabId, this);
+}
BlimpNavigationControllerImpl::~BlimpNavigationControllerImpl() = default;
+void BlimpNavigationControllerImpl::SetNavigationFeatureForTesting(
+ NavigationFeature* feature) {
+ navigation_feature_ = feature;
+ navigation_feature_->SetDelegate(kDummyTabId, this);
+}
+
void BlimpNavigationControllerImpl::LoadURL(const GURL& url) {
current_url_ = url;
- // Temporary trick to ensure that the delegate is not invoked before this
- // method has finished executing. This enables tests to test the
- // asynchronous nature of the API.
- // TODO(shaktisahu): Remove this after integration with NavigationFeature.
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&BlimpNavigationControllerImpl::NotifyDelegateURLLoaded,
- weak_ptr_factory_.GetWeakPtr(), url));
+ navigation_feature_->NavigateToUrlText(kDummyTabId, current_url_.spec());
+}
+
+void BlimpNavigationControllerImpl::Reload() {
+ navigation_feature_->Reload(kDummyTabId);
+}
+
+bool BlimpNavigationControllerImpl::CanGoBack() const {
+ // TODO(shaktisahu): Implement the client-side logic.
+ return false;
+}
+
+bool BlimpNavigationControllerImpl::CanGoForward() const {
+ // TODO(shaktisahu): Implement the client-side logic.
+ return false;
+}
+
+void BlimpNavigationControllerImpl::GoBack() {
+ navigation_feature_->GoBack(kDummyTabId);
+}
+
+void BlimpNavigationControllerImpl::GoForward() {
+ navigation_feature_->GoForward(kDummyTabId);
}
const GURL& BlimpNavigationControllerImpl::GetURL() {
return current_url_;
}
-void BlimpNavigationControllerImpl::NotifyDelegateURLLoaded(const GURL& url) {
- delegate_->NotifyURLLoaded(url);
+void BlimpNavigationControllerImpl::OnUrlChanged(int tab_id, const GURL& url) {
+ delegate_->OnNavigationStateChanged();
+}
+
+void BlimpNavigationControllerImpl::OnFaviconChanged(int tab_id,
+ const SkBitmap& favicon) {
+ delegate_->OnNavigationStateChanged();
+}
+
+void BlimpNavigationControllerImpl::OnTitleChanged(int tab_id,
+ const std::string& title) {
+ delegate_->OnNavigationStateChanged();
+}
+
+void BlimpNavigationControllerImpl::OnLoadingChanged(int tab_id, bool loading) {
+ delegate_->OnNavigationStateChanged();
+}
+
+void BlimpNavigationControllerImpl::OnPageLoadStatusUpdate(int tab_id,
+ bool completed) {
+ delegate_->OnNavigationStateChanged();
}
} // namespace client

Powered by Google App Engine
This is Rietveld 408576698