OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_frame/chrome_frame_npapi.h" | 5 #include "chrome_frame/chrome_frame_npapi.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 // We have opened the URL so tell the browser to restore popup settings | 418 // We have opened the URL so tell the browser to restore popup settings |
419 enabled_popups_ = false; | 419 enabled_popups_ = false; |
420 npapi::PopPopupsEnabledState(instance_); | 420 npapi::PopPopupsEnabledState(instance_); |
421 } | 421 } |
422 | 422 |
423 url_fetcher_.UrlNotify(url, reason, notify_data); | 423 url_fetcher_.UrlNotify(url, reason, notify_data); |
424 } | 424 } |
425 | 425 |
426 void ChromeFrameNPAPI::OnAcceleratorPressed(int tab_handle, | 426 void ChromeFrameNPAPI::OnAcceleratorPressed(int tab_handle, |
427 const MSG& accel_message) { | 427 const MSG& accel_message) { |
428 DLOG(INFO) << __FUNCTION__ << " msg:" | 428 DVLOG(1) << __FUNCTION__ |
429 << base::StringPrintf("0x%04X", accel_message.message) << " key:" | 429 << " msg:" << base::StringPrintf("0x%04X", accel_message.message) |
430 << accel_message.wParam; | 430 << " key:" << accel_message.wParam; |
431 | 431 |
432 // The host browser does call TranslateMessage on messages like WM_KEYDOWN | 432 // The host browser does call TranslateMessage on messages like WM_KEYDOWN |
433 // WM_KEYUP, etc, which will result in messages like WM_CHAR, WM_SYSCHAR, etc | 433 // WM_KEYUP, etc, which will result in messages like WM_CHAR, WM_SYSCHAR, etc |
434 // being posted to the message queue. We don't post these messages here to | 434 // being posted to the message queue. We don't post these messages here to |
435 // avoid these messages from getting handled twice. | 435 // avoid these messages from getting handled twice. |
436 if (!is_privileged_ && | 436 if (!is_privileged_ && |
437 accel_message.message != WM_CHAR && | 437 accel_message.message != WM_CHAR && |
438 accel_message.message != WM_DEADCHAR && | 438 accel_message.message != WM_DEADCHAR && |
439 accel_message.message != WM_SYSCHAR && | 439 accel_message.message != WM_SYSCHAR && |
440 accel_message.message != WM_SYSDEADCHAR) { | 440 accel_message.message != WM_SYSDEADCHAR) { |
441 // A very primitive way to handle keystrokes. | 441 // A very primitive way to handle keystrokes. |
442 // TODO(tommi): When we've implemented a way for chrome to | 442 // TODO(tommi): When we've implemented a way for chrome to |
443 // know when keystrokes are handled (deterministically) on that side, | 443 // know when keystrokes are handled (deterministically) on that side, |
444 // then this function should get called and not otherwise. | 444 // then this function should get called and not otherwise. |
445 ::PostMessage(::GetParent(m_hWnd), accel_message.message, | 445 ::PostMessage(::GetParent(m_hWnd), accel_message.message, |
446 accel_message.wParam, accel_message.lParam); | 446 accel_message.wParam, accel_message.lParam); |
447 } | 447 } |
448 | 448 |
449 if (automation_client_.get()) { | 449 if (automation_client_.get()) { |
450 TabProxy* tab = automation_client_->tab(); | 450 TabProxy* tab = automation_client_->tab(); |
451 if (tab) { | 451 if (tab) { |
452 tab->ProcessUnhandledAccelerator(accel_message); | 452 tab->ProcessUnhandledAccelerator(accel_message); |
453 } | 453 } |
454 } | 454 } |
455 } | 455 } |
456 | 456 |
457 void ChromeFrameNPAPI::OnTabbedOut(int tab_handle, bool reverse) { | 457 void ChromeFrameNPAPI::OnTabbedOut(int tab_handle, bool reverse) { |
458 DLOG(INFO) << __FUNCTION__; | 458 DVLOG(1) << __FUNCTION__; |
459 | 459 |
460 ignore_setfocus_ = true; | 460 ignore_setfocus_ = true; |
461 HWND parent = ::GetParent(m_hWnd); | 461 HWND parent = ::GetParent(m_hWnd); |
462 ::SetFocus(parent); | 462 ::SetFocus(parent); |
463 | 463 |
464 INPUT input = {0}; | 464 INPUT input = {0}; |
465 input.type = INPUT_KEYBOARD; | 465 input.type = INPUT_KEYBOARD; |
466 input.ki.wVk = VK_TAB; | 466 input.ki.wVk = VK_TAB; |
467 SendInput(1, &input, sizeof(input)); | 467 SendInput(1, &input, sizeof(input)); |
468 input.ki.dwFlags = KEYEVENTF_KEYUP; | 468 input.ki.dwFlags = KEYEVENTF_KEYUP; |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 ChromeFrameNPAPI* plugin_instance = ChromeFrameInstanceFromNPObject(object); | 724 ChromeFrameNPAPI* plugin_instance = ChromeFrameInstanceFromNPObject(object); |
725 if (!plugin_instance) { | 725 if (!plugin_instance) { |
726 NOTREACHED(); | 726 NOTREACHED(); |
727 return false; | 727 return false; |
728 } | 728 } |
729 | 729 |
730 return plugin_instance->SetProperty(name, variant); | 730 return plugin_instance->SetProperty(name, variant); |
731 } | 731 } |
732 | 732 |
733 void ChromeFrameNPAPI::OnFocus() { | 733 void ChromeFrameNPAPI::OnFocus() { |
734 DLOG(INFO) << __FUNCTION__; | 734 DVLOG(1) << __FUNCTION__; |
735 PostMessage(WM_SETFOCUS, 0, 0); | 735 PostMessage(WM_SETFOCUS, 0, 0); |
736 } | 736 } |
737 | 737 |
738 void ChromeFrameNPAPI::OnEvent(const char* event_name) { | 738 void ChromeFrameNPAPI::OnEvent(const char* event_name) { |
739 DCHECK(event_name); | 739 DCHECK(event_name); |
740 DLOG(INFO) << event_name; | 740 DVLOG(1) << event_name; |
741 | 741 |
742 if (lstrcmpiA(event_name, "focus") == 0) { | 742 if (lstrcmpiA(event_name, "focus") == 0) { |
743 OnFocus(); | 743 OnFocus(); |
744 } else if (lstrcmpiA(event_name, "blur") == 0) { | 744 } else if (lstrcmpiA(event_name, "blur") == 0) { |
745 OnBlur(); | 745 OnBlur(); |
746 } else { | 746 } else { |
747 NOTREACHED() << event_name; | 747 NOTREACHED() << event_name; |
748 } | 748 } |
749 } | 749 } |
750 | 750 |
(...skipping 20 matching lines...) Expand all Loading... |
771 // twice for WM_SETFOCUS. | 771 // twice for WM_SETFOCUS. |
772 BOOL handled_by_base = TRUE; | 772 BOOL handled_by_base = TRUE; |
773 LRESULT ret = Base::OnSetFocus(message, wparam, lparam, handled_by_base); | 773 LRESULT ret = Base::OnSetFocus(message, wparam, lparam, handled_by_base); |
774 if (hook) | 774 if (hook) |
775 ::UnhookWindowsHookEx(hook); | 775 ::UnhookWindowsHookEx(hook); |
776 | 776 |
777 return ret; | 777 return ret; |
778 } | 778 } |
779 | 779 |
780 void ChromeFrameNPAPI::OnBlur() { | 780 void ChromeFrameNPAPI::OnBlur() { |
781 DLOG(INFO) << __FUNCTION__; | 781 DVLOG(1) << __FUNCTION__; |
782 } | 782 } |
783 | 783 |
784 void ChromeFrameNPAPI::OnLoad(int, const GURL& gurl) { | 784 void ChromeFrameNPAPI::OnLoad(int, const GURL& gurl) { |
785 DLOG(INFO) << "Firing onload"; | 785 DVLOG(1) << "Firing onload"; |
786 FireEvent("load", gurl.spec()); | 786 FireEvent("load", gurl.spec()); |
787 } | 787 } |
788 | 788 |
789 void ChromeFrameNPAPI::OnLoadFailed(int error_code, const std::string& url) { | 789 void ChromeFrameNPAPI::OnLoadFailed(int error_code, const std::string& url) { |
790 FireEvent("loaderror", url); | 790 FireEvent("loaderror", url); |
791 | 791 |
792 ScopedNpVariant result; | 792 ScopedNpVariant result; |
793 InvokeDefault(onerror_handler_, url, &result); | 793 InvokeDefault(onerror_handler_, url, &result); |
794 } | 794 } |
795 | 795 |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 } | 1468 } |
1469 | 1469 |
1470 int32 ChromeFrameNPAPI::Write(NPStream* stream, int32 offset, int32 len, | 1470 int32 ChromeFrameNPAPI::Write(NPStream* stream, int32 offset, int32 len, |
1471 void* buffer) { | 1471 void* buffer) { |
1472 return url_fetcher_.Write(stream, offset, len, buffer); | 1472 return url_fetcher_.Write(stream, offset, len, buffer); |
1473 } | 1473 } |
1474 | 1474 |
1475 NPError ChromeFrameNPAPI::DestroyStream(NPStream* stream, NPReason reason) { | 1475 NPError ChromeFrameNPAPI::DestroyStream(NPStream* stream, NPReason reason) { |
1476 return url_fetcher_.DestroyStream(stream, reason); | 1476 return url_fetcher_.DestroyStream(stream, reason); |
1477 } | 1477 } |
OLD | NEW |