| OLD | NEW |
| 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 #ifndef SERVICES_NAVIGATION_VIEW_IMPL_H_ | 5 #ifndef SERVICES_NAVIGATION_VIEW_IMPL_H_ |
| 6 #define SERVICES_NAVIGATION_VIEW_IMPL_H_ | 6 #define SERVICES_NAVIGATION_VIEW_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "components/mus/public/cpp/window_tree_client_delegate.h" | 9 #include "components/mus/public/cpp/window_tree_client_delegate.h" |
| 10 #include "content/public/browser/notification_observer.h" |
| 11 #include "content/public/browser/notification_registrar.h" |
| 10 #include "content/public/browser/web_contents_delegate.h" | 12 #include "content/public/browser/web_contents_delegate.h" |
| 11 #include "mojo/public/cpp/bindings/binding_set.h" | 13 #include "mojo/public/cpp/bindings/binding_set.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" | 14 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 13 #include "services/navigation/public/interfaces/view.mojom.h" | 15 #include "services/navigation/public/interfaces/view.mojom.h" |
| 14 #include "services/shell/public/cpp/interface_factory.h" | 16 #include "services/shell/public/cpp/interface_factory.h" |
| 15 #include "services/shell/public/cpp/shell_client.h" | 17 #include "services/shell/public/cpp/shell_client.h" |
| 16 #include "services/shell/public/cpp/shell_connection_ref.h" | 18 #include "services/shell/public/cpp/shell_connection_ref.h" |
| 17 #include "ui/gfx/geometry/size.h" | 19 #include "ui/gfx/geometry/size.h" |
| 18 #include "ui/views/widget/widget_delegate.h" | 20 #include "ui/views/widget/widget_delegate.h" |
| 19 | 21 |
| 20 namespace views { | 22 namespace views { |
| 21 class WebView; | 23 class WebView; |
| 22 class Widget; | 24 class Widget; |
| 23 } | 25 } |
| 24 | 26 |
| 25 namespace navigation { | 27 namespace navigation { |
| 26 | 28 |
| 27 class ViewImpl : public mojom::View, | 29 class ViewImpl : public mojom::View, |
| 28 public content::WebContentsDelegate, | 30 public content::WebContentsDelegate, |
| 31 public content::NotificationObserver, |
| 29 public mus::WindowTreeClientDelegate, | 32 public mus::WindowTreeClientDelegate, |
| 30 public views::WidgetDelegate { | 33 public views::WidgetDelegate { |
| 31 public: | 34 public: |
| 32 ViewImpl(shell::Connector* connector, | 35 ViewImpl(shell::Connector* connector, |
| 33 content::BrowserContext* browser_context, | 36 content::BrowserContext* browser_context, |
| 34 mojom::ViewClientPtr client, | 37 mojom::ViewClientPtr client, |
| 35 mojom::ViewRequest request, | 38 mojom::ViewRequest request, |
| 36 std::unique_ptr<shell::ShellConnectionRef> ref); | 39 std::unique_ptr<shell::ShellConnectionRef> ref); |
| 37 ~ViewImpl() override; | 40 ~ViewImpl() override; |
| 38 | 41 |
| 39 private: | 42 private: |
| 40 // mojom::View: | 43 // mojom::View: |
| 41 void NavigateTo(const GURL& url) override; | 44 void NavigateTo(const GURL& url) override; |
| 42 void GoBack() override; | 45 void GoBack() override; |
| 43 void GoForward() override; | 46 void GoForward() override; |
| 47 void NavigateToOffset(int offset) override; |
| 44 void Reload(bool skip_cache) override; | 48 void Reload(bool skip_cache) override; |
| 45 void Stop() override; | 49 void Stop() override; |
| 46 void GetWindowTreeClient( | 50 void GetWindowTreeClient( |
| 47 mus::mojom::WindowTreeClientRequest request) override; | 51 mus::mojom::WindowTreeClientRequest request) override; |
| 48 void ShowInterstitial(const mojo::String& html) override; | 52 void ShowInterstitial(const mojo::String& html) override; |
| 49 void HideInterstitial() override; | 53 void HideInterstitial() override; |
| 50 void SetResizerSize(const gfx::Size& size) override; | 54 void SetResizerSize(const gfx::Size& size) override; |
| 51 | 55 |
| 52 // content::WebContentsDelegate: | 56 // content::WebContentsDelegate: |
| 53 void AddNewContents(content::WebContents* source, | 57 void AddNewContents(content::WebContents* source, |
| 54 content::WebContents* new_contents, | 58 content::WebContents* new_contents, |
| 55 WindowOpenDisposition disposition, | 59 WindowOpenDisposition disposition, |
| 56 const gfx::Rect& initial_rect, | 60 const gfx::Rect& initial_rect, |
| 57 bool user_gesture, | 61 bool user_gesture, |
| 58 bool* was_blocked) override; | 62 bool* was_blocked) override; |
| 59 void CloseContents(content::WebContents* source) override; | 63 void CloseContents(content::WebContents* source) override; |
| 60 void LoadingStateChanged(content::WebContents* source, | 64 void LoadingStateChanged(content::WebContents* source, |
| 61 bool to_different_document) override; | 65 bool to_different_document) override; |
| 62 void NavigationStateChanged(content::WebContents* source, | 66 void NavigationStateChanged(content::WebContents* source, |
| 63 content::InvalidateTypes changed_flags) override; | 67 content::InvalidateTypes changed_flags) override; |
| 64 void LoadProgressChanged(content::WebContents* source, | 68 void LoadProgressChanged(content::WebContents* source, |
| 65 double progress) override; | 69 double progress) override; |
| 66 void UpdateTargetURL(content::WebContents* source, const GURL& url) override; | 70 void UpdateTargetURL(content::WebContents* source, const GURL& url) override; |
| 67 gfx::Rect GetRootWindowResizerRect() const override; | 71 gfx::Rect GetRootWindowResizerRect() const override; |
| 68 | 72 |
| 73 // content::NotificationObserver: |
| 74 void Observe(int type, |
| 75 const content::NotificationSource& source, |
| 76 const content::NotificationDetails& details) override; |
| 77 |
| 69 // mus::WindowTreeClientDelegate: | 78 // mus::WindowTreeClientDelegate: |
| 70 void OnEmbed(mus::Window* root) override; | 79 void OnEmbed(mus::Window* root) override; |
| 71 void OnWindowTreeClientDestroyed(mus::WindowTreeClient* client) override; | 80 void OnWindowTreeClientDestroyed(mus::WindowTreeClient* client) override; |
| 72 void OnEventObserved(const ui::Event& event, mus::Window* target) override; | 81 void OnEventObserved(const ui::Event& event, mus::Window* target) override; |
| 73 | 82 |
| 74 // views::WidgetDelegate: | 83 // views::WidgetDelegate: |
| 75 views::View* GetContentsView() override; | 84 views::View* GetContentsView() override; |
| 76 views::Widget* GetWidget() override; | 85 views::Widget* GetWidget() override; |
| 77 const views::Widget* GetWidget() const override; | 86 const views::Widget* GetWidget() const override; |
| 78 | 87 |
| 79 shell::Connector* connector_; | 88 shell::Connector* connector_; |
| 80 mojo::StrongBinding<mojom::View> binding_; | 89 mojo::StrongBinding<mojom::View> binding_; |
| 81 mojom::ViewClientPtr client_; | 90 mojom::ViewClientPtr client_; |
| 82 std::unique_ptr<shell::ShellConnectionRef> ref_; | 91 std::unique_ptr<shell::ShellConnectionRef> ref_; |
| 83 | 92 |
| 84 views::WebView* web_view_; | 93 views::WebView* web_view_; |
| 85 | 94 |
| 86 std::unique_ptr<content::WebContents> web_contents_; | 95 std::unique_ptr<content::WebContents> web_contents_; |
| 87 | 96 |
| 97 content::NotificationRegistrar registrar_; |
| 98 |
| 88 std::unique_ptr<views::Widget> widget_; | 99 std::unique_ptr<views::Widget> widget_; |
| 89 | 100 |
| 90 gfx::Size resizer_size_; | 101 gfx::Size resizer_size_; |
| 91 | 102 |
| 92 DISALLOW_COPY_AND_ASSIGN(ViewImpl); | 103 DISALLOW_COPY_AND_ASSIGN(ViewImpl); |
| 93 }; | 104 }; |
| 94 | 105 |
| 95 } // navigation | 106 } // navigation |
| 96 | 107 |
| 97 #endif // SERVICES_NAVIGATION_VIEW_IMPL_H_ | 108 #endif // SERVICES_NAVIGATION_VIEW_IMPL_H_ |
| OLD | NEW |