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" | 9 #include "content/public/browser/interstitial_page.h" |
10 #include "content/public/browser/interstitial_page_delegate.h" | 10 #include "content/public/browser/interstitial_page_delegate.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 // TODO(beng): this reply is currently synchronous, figure out a fix. | 153 // TODO(beng): this reply is currently synchronous, figure out a fix. |
154 if (was_blocked) | 154 if (was_blocked) |
155 *was_blocked = false; | 155 *was_blocked = false; |
156 } | 156 } |
157 | 157 |
158 void ViewImpl::CloseContents(content::WebContents* source) { | 158 void ViewImpl::CloseContents(content::WebContents* source) { |
159 client_->Close(); | 159 client_->Close(); |
160 } | 160 } |
161 | 161 |
| 162 content::WebContents* ViewImpl::OpenURLFromTab( |
| 163 content::WebContents* source, |
| 164 const content::OpenURLParams& params) { |
| 165 mojom::OpenURLParamsPtr params_ptr = mojom::OpenURLParams::New(); |
| 166 params_ptr->url = params.url; |
| 167 params_ptr->disposition = |
| 168 static_cast<mojom::WindowOpenDisposition>(params.disposition); |
| 169 client_->OpenURL(std::move(params_ptr)); |
| 170 // TODO(beng): Obviously this is the wrong thing to return for dispositions |
| 171 // that would lead to the creation of a new View, i.e. NEW_TAB, NEW_POPUP etc. |
| 172 // However it seems the callers of this function that we've seen so far |
| 173 // disregard the return value. Rather than returning |source| I'm returning |
| 174 // nullptr to locate (via crash) any sites that depend on a valid result. |
| 175 // If we actually had to do this then we'd have to create the new WebContents |
| 176 // here, store it with a cookie, and pass the cookie through to the client to |
| 177 // pass back with their call to CreateView(), so it would get bound to the |
| 178 // WebContents. |
| 179 return nullptr; |
| 180 } |
| 181 |
162 void ViewImpl::LoadingStateChanged(content::WebContents* source, | 182 void ViewImpl::LoadingStateChanged(content::WebContents* source, |
163 bool to_different_document) { | 183 bool to_different_document) { |
164 client_->LoadingStateChanged(source->IsLoading()); | 184 client_->LoadingStateChanged(source->IsLoading()); |
165 } | 185 } |
166 | 186 |
167 void ViewImpl::NavigationStateChanged(content::WebContents* source, | 187 void ViewImpl::NavigationStateChanged(content::WebContents* source, |
168 content::InvalidateTypes changed_flags) { | 188 content::InvalidateTypes changed_flags) { |
169 client_->NavigationStateChanged(source->GetVisibleURL(), | 189 client_->NavigationStateChanged(source->GetVisibleURL(), |
170 base::UTF16ToUTF8(source->GetTitle()), | 190 base::UTF16ToUTF8(source->GetTitle()), |
171 source->GetController().CanGoBack(), | 191 source->GetController().CanGoBack(), |
(...skipping 12 matching lines...) Expand all Loading... |
184 gfx::Rect ViewImpl::GetRootWindowResizerRect() const { | 204 gfx::Rect ViewImpl::GetRootWindowResizerRect() const { |
185 gfx::Rect bounds = web_view_->GetLocalBounds(); | 205 gfx::Rect bounds = web_view_->GetLocalBounds(); |
186 return gfx::Rect(bounds.right() - resizer_size_.width(), | 206 return gfx::Rect(bounds.right() - resizer_size_.width(), |
187 bounds.bottom() - resizer_size_.height(), | 207 bounds.bottom() - resizer_size_.height(), |
188 resizer_size_.width(), resizer_size_.height()); | 208 resizer_size_.width(), resizer_size_.height()); |
189 } | 209 } |
190 | 210 |
191 void ViewImpl::Observe(int type, | 211 void ViewImpl::Observe(int type, |
192 const content::NotificationSource& source, | 212 const content::NotificationSource& source, |
193 const content::NotificationDetails& details) { | 213 const content::NotificationDetails& details) { |
194 DCHECK(content::Source<content::NavigationController>(source).ptr() == | 214 if (content::Source<content::NavigationController>(source).ptr() != |
195 &web_view_->GetWebContents()->GetController()); | 215 &web_view_->GetWebContents()->GetController()) { |
| 216 return; |
| 217 } |
| 218 |
196 switch (type) { | 219 switch (type) { |
197 case content::NOTIFICATION_NAV_ENTRY_PENDING: { | 220 case content::NOTIFICATION_NAV_ENTRY_PENDING: { |
198 const content::NavigationEntry* entry = | 221 const content::NavigationEntry* entry = |
199 content::Details<content::NavigationEntry>(details).ptr(); | 222 content::Details<content::NavigationEntry>(details).ptr(); |
200 client_->NavigationPending(EntryPtrFromNavEntry(*entry)); | 223 client_->NavigationPending(EntryPtrFromNavEntry(*entry)); |
201 break; | 224 break; |
202 } | 225 } |
203 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: { | 226 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: { |
204 const content::LoadCommittedDetails* lcd = | 227 const content::LoadCommittedDetails* lcd = |
205 content::Details<content::LoadCommittedDetails>(details).ptr(); | 228 content::Details<content::LoadCommittedDetails>(details).ptr(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 281 |
259 views::Widget* ViewImpl::GetWidget() { | 282 views::Widget* ViewImpl::GetWidget() { |
260 return web_view_->GetWidget(); | 283 return web_view_->GetWidget(); |
261 } | 284 } |
262 | 285 |
263 const views::Widget* ViewImpl::GetWidget() const { | 286 const views::Widget* ViewImpl::GetWidget() const { |
264 return web_view_->GetWidget(); | 287 return web_view_->GetWidget(); |
265 } | 288 } |
266 | 289 |
267 } // navigation | 290 } // navigation |
OLD | NEW |