| 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 #include "services/navigation/view_impl.h" | 5 #include "services/navigation/view_impl.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "components/mus/public/cpp/window_tree_client.h" | 8 #include "components/mus/public/cpp/window_tree_client.h" |
| 9 #include "content/public/browser/interstitial_page.h" |
| 10 #include "content/public/browser/interstitial_page_delegate.h" |
| 9 #include "content/public/browser/navigation_controller.h" | 11 #include "content/public/browser/navigation_controller.h" |
| 10 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 11 #include "ui/views/controls/webview/webview.h" | 13 #include "ui/views/controls/webview/webview.h" |
| 12 #include "ui/views/mus/native_widget_mus.h" | 14 #include "ui/views/mus/native_widget_mus.h" |
| 13 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 14 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 15 | 17 |
| 16 namespace navigation { | 18 namespace navigation { |
| 19 namespace { |
| 20 |
| 21 class InterstitialPageDelegate : public content::InterstitialPageDelegate { |
| 22 public: |
| 23 explicit InterstitialPageDelegate(const std::string& html) : html_(html) {} |
| 24 ~InterstitialPageDelegate() override {} |
| 25 InterstitialPageDelegate(const InterstitialPageDelegate&) = delete; |
| 26 void operator=(const InterstitialPageDelegate&) = delete; |
| 27 |
| 28 private: |
| 29 |
| 30 // content::InterstitialPageDelegate: |
| 31 std::string GetHTMLContents() override { |
| 32 return html_; |
| 33 } |
| 34 |
| 35 const std::string html_; |
| 36 }; |
| 37 |
| 38 } // namespace |
| 17 | 39 |
| 18 ViewImpl::ViewImpl(shell::Connector* connector, | 40 ViewImpl::ViewImpl(shell::Connector* connector, |
| 19 content::BrowserContext* browser_context, | 41 content::BrowserContext* browser_context, |
| 20 mojom::ViewClientPtr client, | 42 mojom::ViewClientPtr client, |
| 21 mojom::ViewRequest request, | 43 mojom::ViewRequest request, |
| 22 std::unique_ptr<shell::ShellConnectionRef> ref) | 44 std::unique_ptr<shell::ShellConnectionRef> ref) |
| 23 : connector_(connector), | 45 : connector_(connector), |
| 24 binding_(this, std::move(request)), | 46 binding_(this, std::move(request)), |
| 25 client_(std::move(client)), | 47 client_(std::move(client)), |
| 26 ref_(std::move(ref)), | 48 ref_(std::move(ref)), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 51 | 73 |
| 52 void ViewImpl::Stop() { | 74 void ViewImpl::Stop() { |
| 53 web_view_->GetWebContents()->Stop(); | 75 web_view_->GetWebContents()->Stop(); |
| 54 } | 76 } |
| 55 | 77 |
| 56 void ViewImpl::GetWindowTreeClient( | 78 void ViewImpl::GetWindowTreeClient( |
| 57 mus::mojom::WindowTreeClientRequest request) { | 79 mus::mojom::WindowTreeClientRequest request) { |
| 58 new mus::WindowTreeClient(this, nullptr, std::move(request)); | 80 new mus::WindowTreeClient(this, nullptr, std::move(request)); |
| 59 } | 81 } |
| 60 | 82 |
| 83 void ViewImpl::ShowInterstitial(const mojo::String& html) { |
| 84 content::InterstitialPage* interstitial = |
| 85 content::InterstitialPage::Create(web_view_->GetWebContents(), |
| 86 false, |
| 87 GURL(), |
| 88 new InterstitialPageDelegate(html)); |
| 89 interstitial->Show(); |
| 90 } |
| 91 |
| 92 void ViewImpl::HideInterstitial() { |
| 93 // TODO(beng): this is not quite right. |
| 94 if (web_view_->GetWebContents()->ShowingInterstitialPage()) |
| 95 web_view_->GetWebContents()->GetInterstitialPage()->Proceed(); |
| 96 } |
| 97 |
| 61 void ViewImpl::AddNewContents(content::WebContents* source, | 98 void ViewImpl::AddNewContents(content::WebContents* source, |
| 62 content::WebContents* new_contents, | 99 content::WebContents* new_contents, |
| 63 WindowOpenDisposition disposition, | 100 WindowOpenDisposition disposition, |
| 64 const gfx::Rect& initial_rect, | 101 const gfx::Rect& initial_rect, |
| 65 bool user_gesture, | 102 bool user_gesture, |
| 66 bool* was_blocked) { | 103 bool* was_blocked) { |
| 67 mojom::ViewClientPtr client; | 104 mojom::ViewClientPtr client; |
| 68 mojom::ViewPtr view; | 105 mojom::ViewPtr view; |
| 69 mojom::ViewRequest view_request = GetProxy(&view); | 106 mojom::ViewRequest view_request = GetProxy(&view); |
| 70 client_->ViewCreated(std::move(view), GetProxy(&client), | 107 client_->ViewCreated(std::move(view), GetProxy(&client), |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 163 |
| 127 views::Widget* ViewImpl::GetWidget() { | 164 views::Widget* ViewImpl::GetWidget() { |
| 128 return web_view_->GetWidget(); | 165 return web_view_->GetWidget(); |
| 129 } | 166 } |
| 130 | 167 |
| 131 const views::Widget* ViewImpl::GetWidget() const { | 168 const views::Widget* ViewImpl::GetWidget() const { |
| 132 return web_view_->GetWidget(); | 169 return web_view_->GetWidget(); |
| 133 } | 170 } |
| 134 | 171 |
| 135 } // navigation | 172 } // navigation |
| OLD | NEW |