OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "services/navigation/public/cpp/view.h" |
| 6 |
| 7 #include "services/navigation/public/cpp/view_delegate.h" |
| 8 |
| 9 namespace navigation { |
| 10 |
| 11 //////////////////////////////////////////////////////////////////////////////// |
| 12 // View, public: |
| 13 |
| 14 View::View(ViewDelegate* delegate) : delegate_(delegate), binding_(this) {} |
| 15 View::~View() {} |
| 16 |
| 17 void View::Init(mojom::ViewFactoryPtr factory) { |
| 18 factory->CreateView(binding_.CreateInterfacePtrAndBind(), GetProxy(&view_)); |
| 19 } |
| 20 |
| 21 void View::NavigateTo(const GURL& url) { |
| 22 view_->NavigateTo(url); |
| 23 } |
| 24 |
| 25 void View::GoBack() { |
| 26 if (can_go_back_) |
| 27 view_->GoBack(); |
| 28 } |
| 29 |
| 30 void View::GoForward() { |
| 31 if (can_go_forward_) |
| 32 view_->GoForward(); |
| 33 } |
| 34 |
| 35 void View::Reload(bool skip_cache) { |
| 36 view_->Reload(skip_cache); |
| 37 } |
| 38 |
| 39 void View::Stop() { |
| 40 view_->Stop(); |
| 41 } |
| 42 |
| 43 void View::ShowInterstitial(const std::string& html) { |
| 44 view_->ShowInterstitial(html); |
| 45 } |
| 46 |
| 47 void View::HideInterstitial() { |
| 48 view_->HideInterstitial(); |
| 49 } |
| 50 |
| 51 void View::SetResizerSize(const gfx::Size& size) { |
| 52 view_->SetResizerSize(size); |
| 53 } |
| 54 |
| 55 //////////////////////////////////////////////////////////////////////////////// |
| 56 // View, mojom::ViewClient implementation: |
| 57 |
| 58 void View::LoadingStateChanged(bool is_loading) { |
| 59 is_loading_ = is_loading; |
| 60 if (delegate_) |
| 61 delegate_->LoadingStateChanged(is_loading); |
| 62 } |
| 63 |
| 64 void View::NavigationStateChanged(const GURL& url, |
| 65 const mojo::String& title, |
| 66 bool can_go_back, |
| 67 bool can_go_forward) { |
| 68 title_ = title; |
| 69 can_go_back_ = can_go_back; |
| 70 can_go_forward_ = can_go_forward; |
| 71 if (delegate_) |
| 72 delegate_->NavigationStateChanged(url, title, can_go_back, can_go_forward); |
| 73 } |
| 74 |
| 75 void View::LoadProgressChanged(double progress) { |
| 76 load_progress_ = progress; |
| 77 if (delegate_) |
| 78 delegate_->LoadProgressChanged(progress); |
| 79 } |
| 80 |
| 81 void View::UpdateHoverURL(const GURL& url) { |
| 82 hover_url_ = url; |
| 83 if (delegate_) |
| 84 delegate_->UpdateHoverURL(url); |
| 85 } |
| 86 |
| 87 void View::ViewCreated(mojom::ViewPtr view, |
| 88 mojom::ViewClientRequest client, |
| 89 bool is_popup, |
| 90 const gfx::Rect& initial_rect, |
| 91 bool user_gesture) { |
| 92 if (!delegate_) |
| 93 return; |
| 94 delegate_->ViewCreated(std::move(view), std::move(client), is_popup, |
| 95 initial_rect, user_gesture); |
| 96 } |
| 97 |
| 98 void View::Close() { |
| 99 if (delegate_) |
| 100 delegate_->Close(); |
| 101 } |
| 102 |
| 103 } // namespace navigation |
OLD | NEW |