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

Side by Side Diff: mojo/services/kiosk_wm/navigator_host_impl.cc

Issue 1049993002: Get mojo_shell building inside chromium checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 5 years, 8 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
« no previous file with comments | « mojo/services/kiosk_wm/navigator_host_impl.h ('k') | mojo/services/native_viewport/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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 "mojo/services/kiosk_wm/navigator_host_impl.h"
6
7 #include "mojo/services/kiosk_wm/kiosk_wm.h"
8
9 namespace kiosk_wm {
10
11 NavigatorHostImpl::NavigatorHostImpl(KioskWM* window_manager)
12 : current_index_(-1), kiosk_wm_(window_manager) {
13 }
14
15 NavigatorHostImpl::~NavigatorHostImpl() {
16 }
17
18 void NavigatorHostImpl::Bind(
19 mojo::InterfaceRequest<mojo::NavigatorHost> request) {
20 bindings_.AddBinding(this, request.Pass());
21 }
22
23 void NavigatorHostImpl::DidNavigateLocally(const mojo::String& url) {
24 RecordNavigation(url);
25 // TODO(abarth): Do something interesting.
26 }
27
28 void NavigatorHostImpl::RequestNavigate(mojo::Target target,
29 mojo::URLRequestPtr request) {
30 // kiosk_wm sets up default services including navigation.
31 kiosk_wm_->ReplaceContentWithURL(request->url);
32 }
33
34 void NavigatorHostImpl::RequestNavigateHistory(int32_t delta) {
35 if (history_.empty())
36 return;
37 current_index_ =
38 std::max(0, std::min(current_index_ + delta,
39 static_cast<int32_t>(history_.size()) - 1));
40 kiosk_wm_->ReplaceContentWithURL(history_[current_index_]);
41 }
42
43 void NavigatorHostImpl::RecordNavigation(const std::string& url) {
44 if (current_index_ >= 0 && history_[current_index_] == url) {
45 // This is a navigation to the current entry, ignore.
46 return;
47 }
48
49 history_.erase(history_.begin() + (current_index_ + 1), history_.end());
50 history_.push_back(url);
51 ++current_index_;
52 }
53
54 } // namespace kiosk_wm
OLDNEW
« no previous file with comments | « mojo/services/kiosk_wm/navigator_host_impl.h ('k') | mojo/services/native_viewport/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698