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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 void* notify_data) { | 422 void* notify_data) { |
423 if (enabled_popups_) { | 423 if (enabled_popups_) { |
424 // We have opened the URL so tell the browser to restore popup settings | 424 // We have opened the URL so tell the browser to restore popup settings |
425 enabled_popups_ = false; | 425 enabled_popups_ = false; |
426 npapi::PopPopupsEnabledState(instance_); | 426 npapi::PopPopupsEnabledState(instance_); |
427 } | 427 } |
428 | 428 |
429 url_fetcher_.UrlNotify(url, reason, notify_data); | 429 url_fetcher_.UrlNotify(url, reason, notify_data); |
430 } | 430 } |
431 | 431 |
432 void ChromeFrameNPAPI::OnAcceleratorPressed(int tab_handle, | 432 void ChromeFrameNPAPI::OnAcceleratorPressed(const MSG& accel_message) { |
433 const MSG& accel_message) { | |
434 DVLOG(1) << __FUNCTION__ | 433 DVLOG(1) << __FUNCTION__ |
435 << " msg:" << base::StringPrintf("0x%04X", accel_message.message) | 434 << " msg:" << base::StringPrintf("0x%04X", accel_message.message) |
436 << " key:" << accel_message.wParam; | 435 << " key:" << accel_message.wParam; |
437 | 436 |
438 // The host browser does call TranslateMessage on messages like WM_KEYDOWN | 437 // The host browser does call TranslateMessage on messages like WM_KEYDOWN |
439 // WM_KEYUP, etc, which will result in messages like WM_CHAR, WM_SYSCHAR, etc | 438 // WM_KEYUP, etc, which will result in messages like WM_CHAR, WM_SYSCHAR, etc |
440 // being posted to the message queue. We don't post these messages here to | 439 // being posted to the message queue. We don't post these messages here to |
441 // avoid these messages from getting handled twice. | 440 // avoid these messages from getting handled twice. |
442 if (!is_privileged() && | 441 if (!is_privileged() && |
443 accel_message.message != WM_CHAR && | 442 accel_message.message != WM_CHAR && |
444 accel_message.message != WM_DEADCHAR && | 443 accel_message.message != WM_DEADCHAR && |
445 accel_message.message != WM_SYSCHAR && | 444 accel_message.message != WM_SYSCHAR && |
446 accel_message.message != WM_SYSDEADCHAR) { | 445 accel_message.message != WM_SYSDEADCHAR) { |
447 // A very primitive way to handle keystrokes. | 446 // A very primitive way to handle keystrokes. |
448 // TODO(tommi): When we've implemented a way for chrome to | 447 // TODO(tommi): When we've implemented a way for chrome to |
449 // know when keystrokes are handled (deterministically) on that side, | 448 // know when keystrokes are handled (deterministically) on that side, |
450 // then this function should get called and not otherwise. | 449 // then this function should get called and not otherwise. |
451 ::PostMessage(::GetParent(m_hWnd), accel_message.message, | 450 ::PostMessage(::GetParent(m_hWnd), accel_message.message, |
452 accel_message.wParam, accel_message.lParam); | 451 accel_message.wParam, accel_message.lParam); |
453 } | 452 } |
454 | 453 |
455 if (automation_client_.get()) { | 454 if (automation_client_.get()) { |
456 TabProxy* tab = automation_client_->tab(); | 455 TabProxy* tab = automation_client_->tab(); |
457 if (tab) { | 456 if (tab) { |
458 tab->ProcessUnhandledAccelerator(accel_message); | 457 tab->ProcessUnhandledAccelerator(accel_message); |
459 } | 458 } |
460 } | 459 } |
461 } | 460 } |
462 | 461 |
463 void ChromeFrameNPAPI::OnTabbedOut(int tab_handle, bool reverse) { | 462 void ChromeFrameNPAPI::OnTabbedOut(bool reverse) { |
464 DVLOG(1) << __FUNCTION__; | 463 DVLOG(1) << __FUNCTION__; |
465 | 464 |
466 ignore_setfocus_ = true; | 465 ignore_setfocus_ = true; |
467 HWND parent = ::GetParent(m_hWnd); | 466 HWND parent = ::GetParent(m_hWnd); |
468 ::SetFocus(parent); | 467 ::SetFocus(parent); |
469 | 468 |
470 INPUT input = {0}; | 469 INPUT input = {0}; |
471 input.type = INPUT_KEYBOARD; | 470 input.type = INPUT_KEYBOARD; |
472 input.ki.wVk = VK_TAB; | 471 input.ki.wVk = VK_TAB; |
473 SendInput(1, &input, sizeof(input)); | 472 SendInput(1, &input, sizeof(input)); |
474 input.ki.dwFlags = KEYEVENTF_KEYUP; | 473 input.ki.dwFlags = KEYEVENTF_KEYUP; |
475 SendInput(1, &input, sizeof(input)); | 474 SendInput(1, &input, sizeof(input)); |
476 | 475 |
477 ignore_setfocus_ = false; | 476 ignore_setfocus_ = false; |
478 } | 477 } |
479 | 478 |
480 void ChromeFrameNPAPI::OnOpenURL(int tab_handle, | 479 void ChromeFrameNPAPI::OnOpenURL(const GURL& url, |
481 const GURL& url, | |
482 const GURL& referrer, | 480 const GURL& referrer, |
483 int open_disposition) { | 481 int open_disposition) { |
484 std::string target; | 482 std::string target; |
485 switch (open_disposition) { | 483 switch (open_disposition) { |
486 case NEW_FOREGROUND_TAB: | 484 case NEW_FOREGROUND_TAB: |
487 target = "_blank"; | 485 target = "_blank"; |
488 break; | 486 break; |
489 case NEW_BACKGROUND_TAB: | 487 case NEW_BACKGROUND_TAB: |
490 target = "_blank"; | 488 target = "_blank"; |
491 break; | 489 break; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 if (hook) | 796 if (hook) |
799 ::UnhookWindowsHookEx(hook); | 797 ::UnhookWindowsHookEx(hook); |
800 | 798 |
801 return ret; | 799 return ret; |
802 } | 800 } |
803 | 801 |
804 void ChromeFrameNPAPI::OnBlur() { | 802 void ChromeFrameNPAPI::OnBlur() { |
805 DVLOG(1) << __FUNCTION__; | 803 DVLOG(1) << __FUNCTION__; |
806 } | 804 } |
807 | 805 |
808 void ChromeFrameNPAPI::OnLoad(int, const GURL& gurl) { | 806 void ChromeFrameNPAPI::OnLoad(const GURL& gurl) { |
809 DVLOG(1) << "Firing onload"; | 807 DVLOG(1) << "Firing onload"; |
810 FireEvent("load", gurl.spec()); | 808 FireEvent("load", gurl.spec()); |
811 } | 809 } |
812 | 810 |
813 void ChromeFrameNPAPI::OnLoadFailed(int error_code, const std::string& url) { | 811 void ChromeFrameNPAPI::OnLoadFailed(int error_code, const std::string& url) { |
814 FireEvent("loaderror", url); | 812 FireEvent("loaderror", url); |
815 | 813 |
816 ScopedNpVariant result; | 814 ScopedNpVariant result; |
817 InvokeDefault(onerror_handler_, url, &result); | 815 InvokeDefault(onerror_handler_, url, &result); |
818 } | 816 } |
819 | 817 |
820 void ChromeFrameNPAPI::OnMessageFromChromeFrame(int tab_handle, | 818 void ChromeFrameNPAPI::OnMessageFromChromeFrame(const std::string& message, |
821 const std::string& message, | |
822 const std::string& origin, | 819 const std::string& origin, |
823 const std::string& target) { | 820 const std::string& target) { |
824 bool private_message = false; | 821 bool private_message = false; |
825 if (target.compare("*") != 0) { | 822 if (target.compare("*") != 0) { |
826 if (is_privileged()) { | 823 if (is_privileged()) { |
827 private_message = true; | 824 private_message = true; |
828 } else { | 825 } else { |
829 if (!HaveSameOrigin(target, document_url_)) { | 826 if (!HaveSameOrigin(target, document_url_)) { |
830 DLOG(WARNING) << "Dropping posted message since target doesn't match " | 827 DLOG(WARNING) << "Dropping posted message since target doesn't match " |
831 "the current document's origin. target=" << target; | 828 "the current document's origin. target=" << target; |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 } | 1502 } |
1506 | 1503 |
1507 int32 ChromeFrameNPAPI::Write(NPStream* stream, int32 offset, int32 len, | 1504 int32 ChromeFrameNPAPI::Write(NPStream* stream, int32 offset, int32 len, |
1508 void* buffer) { | 1505 void* buffer) { |
1509 return url_fetcher_.Write(stream, offset, len, buffer); | 1506 return url_fetcher_.Write(stream, offset, len, buffer); |
1510 } | 1507 } |
1511 | 1508 |
1512 NPError ChromeFrameNPAPI::DestroyStream(NPStream* stream, NPReason reason) { | 1509 NPError ChromeFrameNPAPI::DestroyStream(NPStream* stream, NPReason reason) { |
1513 return url_fetcher_.DestroyStream(stream, reason); | 1510 return url_fetcher_.DestroyStream(stream, reason); |
1514 } | 1511 } |
OLD | NEW |