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