| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/guest_view/web_view/web_view_guest.h" | 5 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 bool WebViewGuest::HandleContextMenu( | 427 bool WebViewGuest::HandleContextMenu( |
| 428 const content::ContextMenuParams& params) { | 428 const content::ContextMenuParams& params) { |
| 429 if (!web_view_guest_delegate_) | 429 if (!web_view_guest_delegate_) |
| 430 return false; | 430 return false; |
| 431 return web_view_guest_delegate_->HandleContextMenu(params); | 431 return web_view_guest_delegate_->HandleContextMenu(params); |
| 432 } | 432 } |
| 433 | 433 |
| 434 void WebViewGuest::HandleKeyboardEvent( | 434 void WebViewGuest::HandleKeyboardEvent( |
| 435 WebContents* source, | 435 WebContents* source, |
| 436 const content::NativeWebKeyboardEvent& event) { | 436 const content::NativeWebKeyboardEvent& event) { |
| 437 if (!attached()) | |
| 438 return; | |
| 439 | |
| 440 if (HandleKeyboardShortcuts(event)) | 437 if (HandleKeyboardShortcuts(event)) |
| 441 return; | 438 return; |
| 442 | 439 |
| 443 // Send the unhandled keyboard events back to the embedder to reprocess them. | 440 GuestViewBase::HandleKeyboardEvent(source, event); |
| 444 // TODO(fsamuel): This introduces the possibility of out-of-order keyboard | |
| 445 // events because the guest may be arbitrarily delayed when responding to | |
| 446 // keyboard events. In that time, the embedder may have received and processed | |
| 447 // additional key events. This needs to be fixed as soon as possible. | |
| 448 // See http://crbug.com/229882. | |
| 449 embedder_web_contents()->GetDelegate()->HandleKeyboardEvent( | |
| 450 web_contents(), event); | |
| 451 } | 441 } |
| 452 | 442 |
| 453 void WebViewGuest::LoadProgressChanged(content::WebContents* source, | 443 void WebViewGuest::LoadProgressChanged(content::WebContents* source, |
| 454 double progress) { | 444 double progress) { |
| 455 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 445 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 456 args->SetString(guestview::kUrl, web_contents()->GetURL().spec()); | 446 args->SetString(guestview::kUrl, web_contents()->GetURL().spec()); |
| 457 args->SetDouble(webview::kProgress, progress); | 447 args->SetDouble(webview::kProgress, progress); |
| 458 DispatchEventToView( | 448 DispatchEventToView( |
| 459 new GuestViewBase::Event(webview::kEventLoadProgress, args.Pass())); | 449 new GuestViewBase::Event(webview::kEventLoadProgress, args.Pass())); |
| 460 } | 450 } |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 WebViewGuest::From(owner_web_contents()->GetRenderProcessHost()->GetID(), | 1226 WebViewGuest::From(owner_web_contents()->GetRenderProcessHost()->GetID(), |
| 1237 new_window_instance_id); | 1227 new_window_instance_id); |
| 1238 if (!guest) | 1228 if (!guest) |
| 1239 return; | 1229 return; |
| 1240 | 1230 |
| 1241 if (!allow) | 1231 if (!allow) |
| 1242 guest->Destroy(); | 1232 guest->Destroy(); |
| 1243 } | 1233 } |
| 1244 | 1234 |
| 1245 } // namespace extensions | 1235 } // namespace extensions |
| OLD | NEW |