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

Side by Side Diff: chrome_frame/chrome_frame_activex_base.h

Issue 5998006: Clean up Automation and Chrome Frame IPC code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome_frame/chrome_frame_activex.cc ('k') | chrome_frame/chrome_frame_automation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ 5 #ifndef CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_
6 #define CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ 6 #define CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_
7 7
8 #include <atlbase.h> 8 #include <atlbase.h>
9 #include <atlcom.h> 9 #include <atlcom.h>
10 #include <atlctl.h> 10 #include <atlctl.h>
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 doc_site_.QueryFrom(client_site); 342 doc_site_.QueryFrom(client_site);
343 } 343 }
344 344
345 if (client_site == NULL) { 345 if (client_site == NULL) {
346 in_place_frame_.Release(); 346 in_place_frame_.Release();
347 } 347 }
348 348
349 return CComControlBase::IOleObject_SetClientSite(client_site); 349 return CComControlBase::IOleObject_SetClientSite(client_site);
350 } 350 }
351 351
352 bool HandleContextMenuCommand(UINT cmd, 352 bool HandleContextMenuCommand(UINT cmd, const MiniContextMenuParams& params) {
353 const IPC::MiniContextMenuParams& params) {
354 if (cmd == IDC_ABOUT_CHROME_FRAME) { 353 if (cmd == IDC_ABOUT_CHROME_FRAME) {
355 int tab_handle = automation_client_->tab()->handle(); 354 int tab_handle = automation_client_->tab()->handle();
356 HostNavigate(GURL("about:version"), GURL(), NEW_WINDOW); 355 HostNavigate(GURL("about:version"), GURL(), NEW_WINDOW);
357 return true; 356 return true;
358 } else { 357 } else {
359 switch (cmd) { 358 switch (cmd) {
360 case IDS_CONTENT_CONTEXT_SAVEAUDIOAS: 359 case IDS_CONTENT_CONTEXT_SAVEAUDIOAS:
361 case IDS_CONTENT_CONTEXT_SAVEVIDEOAS: 360 case IDS_CONTENT_CONTEXT_SAVEVIDEOAS:
362 case IDS_CONTENT_CONTEXT_SAVEIMAGEAS: 361 case IDS_CONTENT_CONTEXT_SAVEIMAGEAS:
363 case IDS_CONTENT_CONTEXT_SAVELINKAS: { 362 case IDS_CONTENT_CONTEXT_SAVELINKAS: {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // after CF is first loaded. 407 // after CF is first loaded.
409 if (is_IE && GetIEVersion() < IE_8 && !ceee_util::IsIeCeeeRegistered()) { 408 if (is_IE && GetIEVersion() < IE_8 && !ceee_util::IsIeCeeeRegistered()) {
410 *profile_path = GetIETemporaryFilesFolder(); 409 *profile_path = GetIETemporaryFilesFolder();
411 *profile_path = profile_path->Append(L"Google Chrome Frame"); 410 *profile_path = profile_path->Append(L"Google Chrome Frame");
412 } else { 411 } else {
413 ChromeFramePlugin::GetProfilePath(profile_name, profile_path); 412 ChromeFramePlugin::GetProfilePath(profile_name, profile_path);
414 } 413 }
415 DVLOG(1) << __FUNCTION__ << ": " << profile_path->value(); 414 DVLOG(1) << __FUNCTION__ << ": " << profile_path->value();
416 } 415 }
417 416
418 void OnLoad(int tab_handle, const GURL& url) { 417 void OnLoad(const GURL& url) {
419 if (ready_state_ < READYSTATE_COMPLETE) { 418 if (ready_state_ < READYSTATE_COMPLETE) {
420 ready_state_ = READYSTATE_COMPLETE; 419 ready_state_ = READYSTATE_COMPLETE;
421 FireOnChanged(DISPID_READYSTATE); 420 FireOnChanged(DISPID_READYSTATE);
422 } 421 }
423 422
424 HRESULT hr = InvokeScriptFunction(onload_handler_, url.spec()); 423 HRESULT hr = InvokeScriptFunction(onload_handler_, url.spec());
425 } 424 }
426 425
427 void OnLoadFailed(int error_code, const std::string& url) { 426 void OnLoadFailed(int error_code, const std::string& url) {
428 HRESULT hr = InvokeScriptFunction(onerror_handler_, url); 427 HRESULT hr = InvokeScriptFunction(onerror_handler_, url);
429 } 428 }
430 429
431 void OnMessageFromChromeFrame(int tab_handle, const std::string& message, 430 void OnMessageFromChromeFrame(const std::string& message,
432 const std::string& origin, 431 const std::string& origin,
433 const std::string& target) { 432 const std::string& target) {
434 base::win::ScopedComPtr<IDispatch> message_event; 433 base::win::ScopedComPtr<IDispatch> message_event;
435 if (SUCCEEDED(CreateDomEvent("message", message, origin, 434 if (SUCCEEDED(CreateDomEvent("message", message, origin,
436 message_event.Receive()))) { 435 message_event.Receive()))) {
437 base::win::ScopedVariant event_var; 436 base::win::ScopedVariant event_var;
438 event_var.Set(static_cast<IDispatch*>(message_event)); 437 event_var.Set(static_cast<IDispatch*>(message_event));
439 InvokeScriptFunction(onmessage_handler_, event_var.AsInput()); 438 InvokeScriptFunction(onmessage_handler_, event_var.AsInput());
440 } 439 }
441 } 440 }
442 441
443 virtual void OnTabbedOut(int tab_handle, bool reverse) { 442 virtual void OnTabbedOut(bool reverse) {
444 DCHECK(m_bInPlaceActive); 443 DCHECK(m_bInPlaceActive);
445 444
446 HWND parent = ::GetParent(m_hWnd); 445 HWND parent = ::GetParent(m_hWnd);
447 ::SetFocus(parent); 446 ::SetFocus(parent);
448 base::win::ScopedComPtr<IOleControlSite> control_site; 447 base::win::ScopedComPtr<IOleControlSite> control_site;
449 control_site.QueryFrom(m_spClientSite); 448 control_site.QueryFrom(m_spClientSite);
450 if (control_site) 449 if (control_site)
451 control_site->OnFocus(FALSE); 450 control_site->OnFocus(FALSE);
452 } 451 }
453 452
454 virtual void OnOpenURL(int tab_handle, const GURL& url_to_open, 453 virtual void OnOpenURL(const GURL& url_to_open,
455 const GURL& referrer, int open_disposition) { 454 const GURL& referrer, int open_disposition) {
456 HostNavigate(url_to_open, referrer, open_disposition); 455 HostNavigate(url_to_open, referrer, open_disposition);
457 } 456 }
458 457
459 // Called when Chrome has decided that a request needs to be treated as a 458 // Called when Chrome has decided that a request needs to be treated as a
460 // download. The caller will be the UrlRequest worker thread. 459 // download. The caller will be the UrlRequest worker thread.
461 // The worker thread will block while we process the request and take 460 // The worker thread will block while we process the request and take
462 // ownership of the request object. 461 // ownership of the request object.
463 // There's room for improvement here and also see todo below. 462 // There's room for improvement here and also see todo below.
464 LPARAM OnDownloadRequestInHost(UINT message, WPARAM wparam, LPARAM lparam, 463 LPARAM OnDownloadRequestInHost(UINT message, WPARAM wparam, LPARAM lparam,
465 BOOL& handled) { 464 BOOL& handled) {
466 base::win::ScopedComPtr<IMoniker> moniker( 465 base::win::ScopedComPtr<IMoniker> moniker(
467 reinterpret_cast<IMoniker*>(lparam)); 466 reinterpret_cast<IMoniker*>(lparam));
468 DCHECK(moniker); 467 DCHECK(moniker);
469 base::win::ScopedComPtr<IBindCtx> bind_context( 468 base::win::ScopedComPtr<IBindCtx> bind_context(
470 reinterpret_cast<IBindCtx*>(wparam)); 469 reinterpret_cast<IBindCtx*>(wparam));
471 470
472 // TODO(tommi): It looks like we might have to switch the request object 471 // TODO(tommi): It looks like we might have to switch the request object
473 // into a pass-through request object and serve up any thus far received 472 // into a pass-through request object and serve up any thus far received
474 // content and headers to IE in order to prevent what can currently happen 473 // content and headers to IE in order to prevent what can currently happen
475 // which is reissuing requests and turning POST into GET. 474 // which is reissuing requests and turning POST into GET.
476 if (moniker) { 475 if (moniker) {
477 NavigateBrowserToMoniker(doc_site_, moniker, NULL, bind_context, NULL); 476 NavigateBrowserToMoniker(doc_site_, moniker, NULL, bind_context, NULL);
478 } 477 }
479 478
480 return TRUE; 479 return TRUE;
481 } 480 }
482 481
483 virtual void OnAttachExternalTab(int tab_handle, 482 virtual void OnAttachExternalTab(const AttachExternalTabParams& params) {
484 const IPC::AttachExternalTabParams& params) {
485 std::wstring wide_url = url_; 483 std::wstring wide_url = url_;
486 GURL parsed_url(WideToUTF8(wide_url)); 484 GURL parsed_url(WideToUTF8(wide_url));
487 485
488 // If Chrome-Frame is presently navigated to an extension page, navigating 486 // If Chrome-Frame is presently navigated to an extension page, navigating
489 // the host to a url with scheme chrome-extension will fail, so we 487 // the host to a url with scheme chrome-extension will fail, so we
490 // point the host at http:local_host. Note that this is NOT the URL 488 // point the host at http:local_host. Note that this is NOT the URL
491 // to which the host is directed. It is only used as a temporary message 489 // to which the host is directed. It is only used as a temporary message
492 // passing mechanism between this CF instance, and the BHO that will 490 // passing mechanism between this CF instance, and the BHO that will
493 // be constructed in the new IE tab. 491 // be constructed in the new IE tab.
494 if (parsed_url.SchemeIs("chrome-extension") && 492 if (parsed_url.SchemeIs("chrome-extension") &&
(...skipping 13 matching lines...) Expand all
508 params.cookie, 506 params.cookie,
509 params.disposition, 507 params.disposition,
510 params.dimensions.x(), 508 params.dimensions.x(),
511 params.dimensions.y(), 509 params.dimensions.y(),
512 params.dimensions.width(), 510 params.dimensions.width(),
513 params.dimensions.height(), 511 params.dimensions.height(),
514 params.profile_name.c_str()); 512 params.profile_name.c_str());
515 HostNavigate(GURL(url), GURL(), params.disposition); 513 HostNavigate(GURL(url), GURL(), params.disposition);
516 } 514 }
517 515
518 virtual void OnHandleContextMenu(int tab_handle, HANDLE menu_handle, 516 virtual void OnHandleContextMenu(HANDLE menu_handle,
519 int align_flags, 517 int align_flags,
520 const IPC::MiniContextMenuParams& params) { 518 const MiniContextMenuParams& params) {
521 scoped_refptr<BasePlugin> ref(this); 519 scoped_refptr<BasePlugin> ref(this);
522 ChromeFramePlugin<T>::OnHandleContextMenu(tab_handle, menu_handle, 520 ChromeFramePlugin<T>::OnHandleContextMenu(menu_handle, align_flags, params);
523 align_flags, params);
524 } 521 }
525 522
526 LRESULT OnCreate(UINT message, WPARAM wparam, LPARAM lparam, 523 LRESULT OnCreate(UINT message, WPARAM wparam, LPARAM lparam,
527 BOOL& handled) { // NO_LINT 524 BOOL& handled) { // NO_LINT
528 ModifyStyle(0, WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0); 525 ModifyStyle(0, WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0);
529 url_fetcher_->put_notification_window(m_hWnd); 526 url_fetcher_->put_notification_window(m_hWnd);
530 if (automation_client_.get()) { 527 if (automation_client_.get()) {
531 automation_client_->SetParentWindow(m_hWnd); 528 automation_client_->SetParentWindow(m_hWnd);
532 } else { 529 } else {
533 NOTREACHED() << "No automation server"; 530 NOTREACHED() << "No automation server";
(...skipping 26 matching lines...) Expand all
560 virtual void OnAutomationServerLaunchFailed( 557 virtual void OnAutomationServerLaunchFailed(
561 AutomationLaunchResult reason, const std::string& server_version) { 558 AutomationLaunchResult reason, const std::string& server_version) {
562 DVLOG(1) << __FUNCTION__; 559 DVLOG(1) << __FUNCTION__;
563 if (reason == AUTOMATION_SERVER_CRASHED) 560 if (reason == AUTOMATION_SERVER_CRASHED)
564 draw_sad_tab_ = true; 561 draw_sad_tab_ = true;
565 562
566 ready_state_ = READYSTATE_UNINITIALIZED; 563 ready_state_ = READYSTATE_UNINITIALIZED;
567 FireOnChanged(DISPID_READYSTATE); 564 FireOnChanged(DISPID_READYSTATE);
568 } 565 }
569 566
570 virtual void OnCloseTab(int tab_handle) { 567 virtual void OnCloseTab() {
571 Fire_onclose(); 568 Fire_onclose();
572 } 569 }
573 570
574 // Overridden to take advantage of readystate prop changes and send those 571 // Overridden to take advantage of readystate prop changes and send those
575 // to potential listeners. 572 // to potential listeners.
576 HRESULT FireOnChanged(DISPID dispid) { 573 HRESULT FireOnChanged(DISPID dispid) {
577 if (dispid == DISPID_READYSTATE) { 574 if (dispid == DISPID_READYSTATE) {
578 Fire_onreadystatechanged(ready_state_); 575 Fire_onreadystatechanged(ready_state_);
579 } 576 }
580 return __super::FireOnChanged(dispid); 577 return __super::FireOnChanged(dispid);
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 // is very simple. Just post the message to our parent window and IE 1083 // is very simple. Just post the message to our parent window and IE
1087 // will pick it up if it's an accelerator. We won't know for sure if 1084 // will pick it up if it's an accelerator. We won't know for sure if
1088 // the browser handled the keystroke or not. 1085 // the browser handled the keystroke or not.
1089 ::PostMessage(accel_message.hwnd, accel_message.message, 1086 ::PostMessage(accel_message.hwnd, accel_message.message,
1090 accel_message.wParam, accel_message.lParam); 1087 accel_message.wParam, accel_message.lParam);
1091 } 1088 }
1092 1089
1093 return hr; 1090 return hr;
1094 } 1091 }
1095 1092
1096 virtual void OnAcceleratorPressed(int tab_handle, const MSG& accel_message) { 1093 virtual void OnAcceleratorPressed(const MSG& accel_message) {
1097 DCHECK(m_spInPlaceSite != NULL); 1094 DCHECK(m_spInPlaceSite != NULL);
1098 // Allow our host a chance to handle the accelerator. 1095 // Allow our host a chance to handle the accelerator.
1099 // This catches things like Ctrl+F, Ctrl+O etc, but not browser 1096 // This catches things like Ctrl+F, Ctrl+O etc, but not browser
1100 // accelerators such as F11, Ctrl+T etc. 1097 // accelerators such as F11, Ctrl+T etc.
1101 // (see AllowFrameToTranslateAccelerator for those). 1098 // (see AllowFrameToTranslateAccelerator for those).
1102 HRESULT hr = TranslateAccelerator(const_cast<MSG*>(&accel_message)); 1099 HRESULT hr = TranslateAccelerator(const_cast<MSG*>(&accel_message));
1103 if (hr != S_OK) 1100 if (hr != S_OK)
1104 hr = AllowFrameToTranslateAccelerator(accel_message); 1101 hr = AllowFrameToTranslateAccelerator(accel_message);
1105 1102
1106 DVLOG(1) << __FUNCTION__ << " browser response: " 1103 DVLOG(1) << __FUNCTION__ << " browser response: "
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 EventHandlers onextensionready_; 1268 EventHandlers onextensionready_;
1272 1269
1273 // Handle network requests when host network stack is used. Passed to the 1270 // Handle network requests when host network stack is used. Passed to the
1274 // automation client on initialization. 1271 // automation client on initialization.
1275 scoped_ptr<UrlmonUrlRequestManager> url_fetcher_; 1272 scoped_ptr<UrlmonUrlRequestManager> url_fetcher_;
1276 1273
1277 HINSTANCE prev_resource_instance_; 1274 HINSTANCE prev_resource_instance_;
1278 }; 1275 };
1279 1276
1280 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ 1277 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_
OLDNEW
« no previous file with comments | « chrome_frame/chrome_frame_activex.cc ('k') | chrome_frame/chrome_frame_automation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698