| 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 #ifndef SERVICES_NAVIGATION_PUBLIC_CPP_VIEW_H_ | |
| 6 #define SERVICES_NAVIGATION_PUBLIC_CPP_VIEW_H_ | |
| 7 | |
| 8 #include "base/observer_list.h" | |
| 9 #include "base/strings/string16.h" | |
| 10 #include "mojo/public/cpp/bindings/binding.h" | |
| 11 #include "services/navigation/public/interfaces/view.mojom.h" | |
| 12 | |
| 13 namespace aura { | |
| 14 class Window; | |
| 15 } | |
| 16 | |
| 17 namespace navigation { | |
| 18 | |
| 19 class ViewDelegate; | |
| 20 class ViewObserver; | |
| 21 | |
| 22 // Represents an item in a View's navigation list. | |
| 23 struct NavigationListItem { | |
| 24 NavigationListItem(const base::string16& title, int offset) | |
| 25 : title(title), offset(offset) {} | |
| 26 ~NavigationListItem() {} | |
| 27 | |
| 28 base::string16 title; | |
| 29 // The navigation offset from the current page in the navigation list. | |
| 30 int offset; | |
| 31 }; | |
| 32 | |
| 33 class View : public mojom::ViewClient { | |
| 34 public: | |
| 35 explicit View(mojom::ViewFactoryPtr factory); | |
| 36 View(mojom::ViewPtr view, mojom::ViewClientRequest request); | |
| 37 View(const View&) = delete; | |
| 38 void operator=(const View&) = delete; | |
| 39 ~View() override; | |
| 40 | |
| 41 void set_delegate(ViewDelegate* delegate) { delegate_ = delegate; } | |
| 42 | |
| 43 void AddObserver(ViewObserver* observer); | |
| 44 void RemoveObserver(ViewObserver* observer); | |
| 45 | |
| 46 // Loading. | |
| 47 void NavigateToURL(const GURL& url); | |
| 48 void NavigateToOffset(int offset); | |
| 49 bool is_loading() const { return is_loading_; } | |
| 50 const GURL& url() const { return url_; } | |
| 51 const base::string16& title() const { return title_; } | |
| 52 | |
| 53 // Back/Forward. | |
| 54 void GoBack(); | |
| 55 void GoForward(); | |
| 56 bool can_go_back() const { return can_go_back_; } | |
| 57 bool can_go_forward() const { return can_go_forward_; } | |
| 58 void GetBackMenuItems(std::vector<NavigationListItem>* items); | |
| 59 void GetForwardMenuItems(std::vector<NavigationListItem>* items); | |
| 60 | |
| 61 // Reload/Stop. | |
| 62 void Reload(bool bypass_cache); | |
| 63 void Stop(); | |
| 64 | |
| 65 // Interstitials. | |
| 66 void ShowInterstitial(const std::string& html); | |
| 67 void HideInterstitial(); | |
| 68 | |
| 69 // Embed the View visually within |parent|. | |
| 70 void EmbedInWindow(aura::Window* parent); | |
| 71 | |
| 72 private: | |
| 73 // mojom::ViewClient: | |
| 74 void OpenURL(mojom::OpenURLParamsPtr params) override; | |
| 75 void LoadingStateChanged(bool is_loading) override; | |
| 76 void NavigationStateChanged(const GURL& url, | |
| 77 const std::string& title, | |
| 78 bool can_go_back, | |
| 79 bool can_go_forward) override; | |
| 80 void LoadProgressChanged(double progress) override; | |
| 81 void UpdateHoverURL(const GURL& url) override; | |
| 82 void ViewCreated(mojom::ViewPtr view, | |
| 83 mojom::ViewClientRequest request, | |
| 84 bool is_popup, | |
| 85 const gfx::Rect& initial_bounds, | |
| 86 bool user_gesture) override; | |
| 87 void Close() override; | |
| 88 void NavigationPending(mojom::NavigationEntryPtr entry) override; | |
| 89 void NavigationCommitted(mojom::NavigationCommittedDetailsPtr details, | |
| 90 int current_index) override; | |
| 91 void NavigationEntryChanged(mojom::NavigationEntryPtr entry, | |
| 92 int entry_index) override; | |
| 93 void NavigationListPruned(bool from_front, int count) override; | |
| 94 | |
| 95 mojom::ViewPtr view_; | |
| 96 mojo::Binding<mojom::ViewClient> binding_; | |
| 97 | |
| 98 ViewDelegate* delegate_ = nullptr; | |
| 99 base::ObserverList<ViewObserver> observers_; | |
| 100 | |
| 101 bool is_loading_ = false; | |
| 102 GURL url_; | |
| 103 base::string16 title_; | |
| 104 bool can_go_back_ = false; | |
| 105 bool can_go_forward_ = false; | |
| 106 | |
| 107 mojom::NavigationEntryPtr pending_navigation_; | |
| 108 std::vector<mojom::NavigationEntryPtr> navigation_list_; | |
| 109 int navigation_list_cursor_ = 0; | |
| 110 }; | |
| 111 | |
| 112 } // namespace navigation | |
| 113 | |
| 114 #endif // SERVICES_NAVIGATION_PUBLIC_CPP_VIEW_H_ | |
| OLD | NEW |