Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: chrome/browser/guest_view/web_view/web_view_guest.cc

Issue 301303003: GuestView: Move Disable Drag and Drop Out to Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@change_browser_plugin_guest_delegate_lifetime
Patch Set: Addressed Istiaque's comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/guest_view/web_view/web_view_guest.h" 5 #include "chrome/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 "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 SetUserAgentOverride(user_agent_override); 327 SetUserAgentOverride(user_agent_override);
328 } else { 328 } else {
329 SetUserAgentOverride(""); 329 SetUserAgentOverride("");
330 } 330 }
331 331
332 GuestViewBase::Attach(embedder_web_contents, args); 332 GuestViewBase::Attach(embedder_web_contents, args);
333 333
334 AddWebViewToExtensionRendererState(); 334 AddWebViewToExtensionRendererState();
335 } 335 }
336 336
337 void WebViewGuest::DidStopLoading() {
338 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
339 DispatchEvent(new GuestViewBase::Event(webview::kEventLoadStop, args.Pass()));
340 }
341
337 void WebViewGuest::EmbedderDestroyed() { 342 void WebViewGuest::EmbedderDestroyed() {
338 // TODO(fsamuel): WebRequest event listeners for <webview> should survive 343 // TODO(fsamuel): WebRequest event listeners for <webview> should survive
339 // reparenting of a <webview> within a single embedder. Right now, we keep 344 // reparenting of a <webview> within a single embedder. Right now, we keep
340 // around the browser state for the listener for the lifetime of the embedder. 345 // around the browser state for the listener for the lifetime of the embedder.
341 // Ideally, the lifetime of the listeners should match the lifetime of the 346 // Ideally, the lifetime of the listeners should match the lifetime of the
342 // <webview> DOM node. Once http://crbug.com/156219 is resolved we can move 347 // <webview> DOM node. Once http://crbug.com/156219 is resolved we can move
343 // the call to RemoveWebViewEventListenersOnIOThread back to 348 // the call to RemoveWebViewEventListenersOnIOThread back to
344 // WebViewGuest::WebContentsDestroyed. 349 // WebViewGuest::WebContentsDestroyed.
345 content::BrowserThread::PostTask( 350 content::BrowserThread::PostTask(
346 content::BrowserThread::IO, 351 content::BrowserThread::IO,
347 FROM_HERE, 352 FROM_HERE,
348 base::Bind( 353 base::Bind(
349 &RemoveWebViewEventListenersOnIOThread, 354 &RemoveWebViewEventListenersOnIOThread,
350 browser_context(), embedder_extension_id(), 355 browser_context(), embedder_extension_id(),
351 embedder_render_process_id(), 356 embedder_render_process_id(),
352 view_instance_id())); 357 view_instance_id()));
353 } 358 }
354 359
360 bool WebViewGuest::IsDragAndDropEnabled() const {
361 return true;
362 }
363
355 bool WebViewGuest::AddMessageToConsole(WebContents* source, 364 bool WebViewGuest::AddMessageToConsole(WebContents* source,
356 int32 level, 365 int32 level,
357 const base::string16& message, 366 const base::string16& message,
358 int32 line_no, 367 int32 line_no,
359 const base::string16& source_id) { 368 const base::string16& source_id) {
360 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 369 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
361 // Log levels are from base/logging.h: LogSeverity. 370 // Log levels are from base/logging.h: LogSeverity.
362 args->SetInteger(webview::kLevel, level); 371 args->SetInteger(webview::kLevel, level);
363 args->SetString(webview::kMessage, message); 372 args->SetString(webview::kMessage, message);
364 args->SetInteger(webview::kLine, line_no); 373 args->SetInteger(webview::kLine, line_no);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // Send the unhandled keyboard events back to the embedder to reprocess them. 450 // Send the unhandled keyboard events back to the embedder to reprocess them.
442 // TODO(fsamuel): This introduces the possibility of out-of-order keyboard 451 // TODO(fsamuel): This introduces the possibility of out-of-order keyboard
443 // events because the guest may be arbitrarily delayed when responding to 452 // events because the guest may be arbitrarily delayed when responding to
444 // keyboard events. In that time, the embedder may have received and processed 453 // keyboard events. In that time, the embedder may have received and processed
445 // additional key events. This needs to be fixed as soon as possible. 454 // additional key events. This needs to be fixed as soon as possible.
446 // See http://crbug.com/229882. 455 // See http://crbug.com/229882.
447 embedder_web_contents()->GetDelegate()->HandleKeyboardEvent( 456 embedder_web_contents()->GetDelegate()->HandleKeyboardEvent(
448 web_contents(), event); 457 web_contents(), event);
449 } 458 }
450 459
451 bool WebViewGuest::IsDragAndDropEnabled() {
452 return true;
453 }
454
455 void WebViewGuest::LoadProgressChanged(content::WebContents* source, 460 void WebViewGuest::LoadProgressChanged(content::WebContents* source,
456 double progress) { 461 double progress) {
457 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 462 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
458 args->SetString(guestview::kUrl, guest_web_contents()->GetURL().spec()); 463 args->SetString(guestview::kUrl, guest_web_contents()->GetURL().spec());
459 args->SetDouble(webview::kProgress, progress); 464 args->SetDouble(webview::kProgress, progress);
460 DispatchEvent( 465 DispatchEvent(
461 new GuestViewBase::Event(webview::kEventLoadProgress, args.Pass())); 466 new GuestViewBase::Event(webview::kEventLoadProgress, args.Pass()));
462 } 467 }
463 468
464 void WebViewGuest::LoadAbort(bool is_top_level, 469 void WebViewGuest::LoadAbort(bool is_top_level,
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 new GuestViewBase::Event(webview::kEventLoadStart, args.Pass())); 848 new GuestViewBase::Event(webview::kEventLoadStart, args.Pass()));
844 } 849 }
845 850
846 void WebViewGuest::DocumentLoadedInFrame( 851 void WebViewGuest::DocumentLoadedInFrame(
847 int64 frame_id, 852 int64 frame_id,
848 content::RenderViewHost* render_view_host) { 853 content::RenderViewHost* render_view_host) {
849 if (frame_id == main_frame_id_) 854 if (frame_id == main_frame_id_)
850 InjectChromeVoxIfNeeded(render_view_host); 855 InjectChromeVoxIfNeeded(render_view_host);
851 } 856 }
852 857
853 void WebViewGuest::DidStopLoading(content::RenderViewHost* render_view_host) {
854 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
855 DispatchEvent(new GuestViewBase::Event(webview::kEventLoadStop, args.Pass()));
856 }
857
858 bool WebViewGuest::OnMessageReceived(const IPC::Message& message, 858 bool WebViewGuest::OnMessageReceived(const IPC::Message& message,
859 RenderFrameHost* render_frame_host) { 859 RenderFrameHost* render_frame_host) {
860 bool handled = true; 860 bool handled = true;
861 IPC_BEGIN_MESSAGE_MAP(WebViewGuest, message) 861 IPC_BEGIN_MESSAGE_MAP(WebViewGuest, message)
862 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_UpdateFrameName, OnUpdateFrameName) 862 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_UpdateFrameName, OnUpdateFrameName)
863 IPC_MESSAGE_UNHANDLED(handled = false) 863 IPC_MESSAGE_UNHANDLED(handled = false)
864 IPC_END_MESSAGE_MAP() 864 IPC_END_MESSAGE_MAP()
865 return handled; 865 return handled;
866 } 866 }
867 867
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 bool allow, 1413 bool allow,
1414 const std::string& user_input) { 1414 const std::string& user_input) {
1415 WebViewGuest* guest = 1415 WebViewGuest* guest =
1416 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); 1416 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id);
1417 if (!guest) 1417 if (!guest)
1418 return; 1418 return;
1419 1419
1420 if (!allow) 1420 if (!allow)
1421 guest->Destroy(); 1421 guest->Destroy();
1422 } 1422 }
OLDNEW
« no previous file with comments | « chrome/browser/guest_view/web_view/web_view_guest.h ('k') | content/browser/browser_plugin/browser_plugin_guest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698