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_activex.h" | 5 #include "chrome_frame/chrome_frame_activex.h" |
6 | 6 |
7 #include <wininet.h> | 7 #include <wininet.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 203 |
204 void ChromeFrameActivex::OnMessageFromChromeFrame(int tab_handle, | 204 void ChromeFrameActivex::OnMessageFromChromeFrame(int tab_handle, |
205 const std::string& message, | 205 const std::string& message, |
206 const std::string& origin, | 206 const std::string& origin, |
207 const std::string& target) { | 207 const std::string& target) { |
208 DVLOG(1) << __FUNCTION__; | 208 DVLOG(1) << __FUNCTION__; |
209 | 209 |
210 if (target.compare("*") != 0) { | 210 if (target.compare("*") != 0) { |
211 bool drop = true; | 211 bool drop = true; |
212 | 212 |
213 if (is_privileged_) { | 213 if (is_privileged()) { |
214 // Forward messages if the control is in privileged mode. | 214 // Forward messages if the control is in privileged mode. |
215 ScopedComPtr<IDispatch> message_event; | 215 ScopedComPtr<IDispatch> message_event; |
216 if (SUCCEEDED(CreateDomEvent("message", message, origin, | 216 if (SUCCEEDED(CreateDomEvent("message", message, origin, |
217 message_event.Receive()))) { | 217 message_event.Receive()))) { |
218 base::win::ScopedBstr target_bstr(UTF8ToWide(target).c_str()); | 218 base::win::ScopedBstr target_bstr(UTF8ToWide(target).c_str()); |
219 Fire_onprivatemessage(message_event, target_bstr); | 219 Fire_onprivatemessage(message_event, target_bstr); |
220 | 220 |
221 FireEvent(onprivatemessage_, message_event, target_bstr); | 221 FireEvent(onprivatemessage_, message_event, target_bstr); |
222 } | 222 } |
223 } else { | 223 } else { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 265 |
266 NOTREACHED(); | 266 NOTREACHED(); |
267 return true; | 267 return true; |
268 } | 268 } |
269 | 269 |
270 void ChromeFrameActivex::OnAutomationServerLaunchFailed( | 270 void ChromeFrameActivex::OnAutomationServerLaunchFailed( |
271 AutomationLaunchResult reason, const std::string& server_version) { | 271 AutomationLaunchResult reason, const std::string& server_version) { |
272 Base::OnAutomationServerLaunchFailed(reason, server_version); | 272 Base::OnAutomationServerLaunchFailed(reason, server_version); |
273 | 273 |
274 if (reason == AUTOMATION_VERSION_MISMATCH && | 274 if (reason == AUTOMATION_VERSION_MISMATCH && |
275 ShouldShowVersionMismatchDialog(is_privileged_, m_spClientSite)) { | 275 ShouldShowVersionMismatchDialog(is_privileged(), m_spClientSite)) { |
276 THREAD_SAFE_UMA_HISTOGRAM_COUNTS( | 276 THREAD_SAFE_UMA_HISTOGRAM_COUNTS( |
277 "ChromeFrame.VersionMismatchDisplayed", 1); | 277 "ChromeFrame.VersionMismatchDisplayed", 1); |
278 DisplayVersionMismatchWarning(m_hWnd, server_version); | 278 DisplayVersionMismatchWarning(m_hWnd, server_version); |
279 } | 279 } |
280 } | 280 } |
281 | 281 |
282 void ChromeFrameActivex::OnExtensionInstalled( | 282 void ChromeFrameActivex::OnExtensionInstalled( |
283 const FilePath& path, | 283 const FilePath& path, |
284 void* user_data, | 284 void* user_data, |
285 AutomationMsg_ExtensionResponseValues response) { | 285 AutomationMsg_ExtensionResponseValues response) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 &onloaderror_, | 420 &onloaderror_, |
421 &onload_, | 421 &onload_, |
422 &onreadystatechanged_, | 422 &onreadystatechanged_, |
423 &onextensionready_, | 423 &onextensionready_, |
424 }; | 424 }; |
425 | 425 |
426 for (int i = 0; i < arraysize(handlers); ++i) | 426 for (int i = 0; i < arraysize(handlers); ++i) |
427 handlers[i]->clear(); | 427 handlers[i]->clear(); |
428 | 428 |
429 // Drop privileged mode on uninitialization. | 429 // Drop privileged mode on uninitialization. |
430 is_privileged_ = false; | 430 set_is_privileged(false); |
431 } else { | 431 } else { |
432 ScopedComPtr<IHTMLDocument2> document; | 432 ScopedComPtr<IHTMLDocument2> document; |
433 GetContainingDocument(document.Receive()); | 433 GetContainingDocument(document.Receive()); |
434 if (document) { | 434 if (document) { |
435 base::win::ScopedBstr url; | 435 base::win::ScopedBstr url; |
436 if (SUCCEEDED(document->get_URL(url.Receive()))) | 436 if (SUCCEEDED(document->get_URL(url.Receive()))) |
437 WideToUTF8(url, url.Length(), &document_url_); | 437 WideToUTF8(url, url.Length(), &document_url_); |
438 } | 438 } |
439 | 439 |
440 // Probe to see whether the host implements the privileged service. | 440 // Probe to see whether the host implements the privileged service. |
441 ScopedComPtr<IChromeFramePrivileged> service; | 441 ScopedComPtr<IChromeFramePrivileged> service; |
442 HRESULT service_hr = DoQueryService(SID_ChromeFramePrivileged, | 442 HRESULT service_hr = DoQueryService(SID_ChromeFramePrivileged, |
443 m_spClientSite, | 443 m_spClientSite, |
444 service.Receive()); | 444 service.Receive()); |
445 if (SUCCEEDED(service_hr) && service) { | 445 if (SUCCEEDED(service_hr) && service) { |
446 // Does the host want privileged mode? | 446 // Does the host want privileged mode? |
447 boolean wants_privileged = false; | 447 boolean wants_privileged = false; |
448 service_hr = service->GetWantsPrivileged(&wants_privileged); | 448 service_hr = service->GetWantsPrivileged(&wants_privileged); |
449 | 449 |
450 if (SUCCEEDED(service_hr) && wants_privileged) | 450 if (SUCCEEDED(service_hr) && wants_privileged) |
451 is_privileged_ = true; | 451 set_is_privileged(true); |
452 | 452 |
453 url_fetcher_->set_privileged_mode(is_privileged_); | 453 url_fetcher_->set_privileged_mode(is_privileged()); |
454 } | 454 } |
455 | 455 |
456 std::wstring profile_name(GetHostProcessName(false)); | 456 std::wstring profile_name(GetHostProcessName(false)); |
457 if (is_privileged_) { | 457 if (is_privileged()) { |
458 | 458 |
459 base::win::ScopedBstr automated_functions_arg; | 459 base::win::ScopedBstr automated_functions_arg; |
460 service_hr = service->GetExtensionApisToAutomate( | 460 service_hr = service->GetExtensionApisToAutomate( |
461 automated_functions_arg.Receive()); | 461 automated_functions_arg.Receive()); |
462 if (S_OK == service_hr && automated_functions_arg) { | 462 if (S_OK == service_hr && automated_functions_arg) { |
463 std::string automated_functions( | 463 std::string automated_functions( |
464 WideToASCII(static_cast<BSTR>(automated_functions_arg))); | 464 WideToASCII(static_cast<BSTR>(automated_functions_arg))); |
465 functions_enabled_.clear(); | 465 functions_enabled_.clear(); |
466 // base::SplitString writes one empty entry for blank strings, so we | 466 // base::SplitString writes one empty entry for blank strings, so we |
467 // need this to allow specifying zero automation of API functions. | 467 // need this to allow specifying zero automation of API functions. |
(...skipping 16 matching lines...) Expand all Loading... |
484 | 484 |
485 // To avoid http://code.google.com/p/chromium/issues/detail?id=63427, | 485 // To avoid http://code.google.com/p/chromium/issues/detail?id=63427, |
486 // we always pass this flag needed by CEEE. It has no effect on | 486 // we always pass this flag needed by CEEE. It has no effect on |
487 // normal CF operation. | 487 // normal CF operation. |
488 // | 488 // |
489 // Extra arguments are passed on verbatim, so we add the -- prefix. | 489 // Extra arguments are passed on verbatim, so we add the -- prefix. |
490 std::wstring chrome_extra_arguments(L"--"); | 490 std::wstring chrome_extra_arguments(L"--"); |
491 chrome_extra_arguments.append( | 491 chrome_extra_arguments.append( |
492 ASCIIToWide(switches::kEnableExperimentalExtensionApis)); | 492 ASCIIToWide(switches::kEnableExperimentalExtensionApis)); |
493 | 493 |
494 url_fetcher_->set_frame_busting(!is_privileged_); | 494 url_fetcher_->set_frame_busting(!is_privileged()); |
495 automation_client_->SetUrlFetcher(url_fetcher_.get()); | 495 automation_client_->SetUrlFetcher(url_fetcher_.get()); |
496 if (!InitializeAutomation(profile_name, chrome_extra_arguments, | 496 if (!InitializeAutomation(profile_name, chrome_extra_arguments, |
497 IsIEInPrivate(), true, GURL(utf8_url), | 497 IsIEInPrivate(), true, GURL(utf8_url), |
498 GURL(), false)) { | 498 GURL(), false)) { |
499 DLOG(ERROR) << "Failed to navigate to url:" << utf8_url; | 499 DLOG(ERROR) << "Failed to navigate to url:" << utf8_url; |
500 return E_FAIL; | 500 return E_FAIL; |
501 } | 501 } |
502 | 502 |
503 // Log a metric that Chrome Frame is being used in Widget mode | 503 // Log a metric that Chrome Frame is being used in Widget mode |
504 THREAD_SAFE_UMA_LAUNCH_TYPE_COUNT(RENDERER_TYPE_CHROME_WIDGET); | 504 THREAD_SAFE_UMA_LAUNCH_TYPE_COUNT(RENDERER_TYPE_CHROME_WIDGET); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 if (FAILED(hr)) { | 687 if (FAILED(hr)) { |
688 NOTREACHED() << "ChromeFrame BHO SetSite failed. Error:" | 688 NOTREACHED() << "ChromeFrame BHO SetSite failed. Error:" |
689 << base::StringPrintf(" 0x%08X", hr); | 689 << base::StringPrintf(" 0x%08X", hr); |
690 return hr; | 690 return hr; |
691 } | 691 } |
692 | 692 |
693 web_browser2->PutProperty(base::win::ScopedBstr(bho_class_id_as_string), | 693 web_browser2->PutProperty(base::win::ScopedBstr(bho_class_id_as_string), |
694 base::win::ScopedVariant(bho)); | 694 base::win::ScopedVariant(bho)); |
695 return S_OK; | 695 return S_OK; |
696 } | 696 } |
OLD | NEW |