| 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> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/debug/trace_event.h" | 14 #include "base/debug/trace_event.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 18 #include "base/process_util.h" | 18 #include "base/process_util.h" |
| 19 #include "base/singleton.h" | 19 #include "base/singleton.h" |
| 20 #include "base/string_split.h" | 20 #include "base/string_split.h" |
| 21 #include "base/string_util.h" | 21 #include "base/string_util.h" |
| 22 #include "base/stringprintf.h" | 22 #include "base/stringprintf.h" |
| 23 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
| 24 #include "base/win/scoped_bstr.h" | 24 #include "base/win/scoped_bstr.h" |
| 25 #include "base/win/scoped_variant.h" | 25 #include "base/win/scoped_variant.h" |
| 26 #include "chrome/common/automation_messages.h" |
| 26 #include "chrome/common/chrome_constants.h" | 27 #include "chrome/common/chrome_constants.h" |
| 27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/test/automation/tab_proxy.h" | 29 #include "chrome/test/automation/tab_proxy.h" |
| 29 #include "googleurl/src/gurl.h" | 30 #include "googleurl/src/gurl.h" |
| 30 #include "chrome_frame/utils.h" | 31 #include "chrome_frame/utils.h" |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 // Class used to maintain a mapping from top-level windows to ChromeFrameActivex | 35 // Class used to maintain a mapping from top-level windows to ChromeFrameActivex |
| 35 // instances. | 36 // instances. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 109 |
| 109 // Note that this hook is installed as a LOCAL hook. | 110 // Note that this hook is installed as a LOCAL hook. |
| 110 return ::SetWindowsHookEx(WH_CALLWNDPROC, | 111 return ::SetWindowsHookEx(WH_CALLWNDPROC, |
| 111 TopWindowProc, | 112 TopWindowProc, |
| 112 NULL, | 113 NULL, |
| 113 proc_thread); | 114 proc_thread); |
| 114 } | 115 } |
| 115 | 116 |
| 116 } // unnamed namespace | 117 } // unnamed namespace |
| 117 | 118 |
| 119 namespace chrome_frame { |
| 120 std::string ActiveXCreateUrl(const GURL& parsed_url, |
| 121 const AttachExternalTabParams& params) { |
| 122 return base::StringPrintf( |
| 123 "%hs?attach_external_tab&%I64u&%d&%d&%d&%d&%d&%hs", |
| 124 parsed_url.GetOrigin().spec().c_str(), |
| 125 params.cookie, |
| 126 params.disposition, |
| 127 params.dimensions.x(), |
| 128 params.dimensions.y(), |
| 129 params.dimensions.width(), |
| 130 params.dimensions.height(), |
| 131 params.profile_name.c_str()); |
| 132 } |
| 133 |
| 134 int GetDisposition(const AttachExternalTabParams& params) { |
| 135 return params.disposition; |
| 136 } |
| 137 |
| 138 void GetMiniContextMenuData(UINT cmd, |
| 139 const MiniContextMenuParams& params, |
| 140 GURL* referrer, |
| 141 GURL* url) { |
| 142 *referrer = params.frame_url.is_empty() ? params.page_url : params.frame_url; |
| 143 *url = (cmd == IDS_CONTENT_CONTEXT_SAVELINKAS ? |
| 144 params.link_url : params.src_url); |
| 145 } |
| 146 |
| 147 } // namespace chrome_frame |
| 148 |
| 118 ChromeFrameActivex::ChromeFrameActivex() | 149 ChromeFrameActivex::ChromeFrameActivex() |
| 119 : chrome_wndproc_hook_(NULL) { | 150 : chrome_wndproc_hook_(NULL) { |
| 120 TRACE_EVENT_BEGIN("chromeframe.createactivex", this, ""); | 151 TRACE_EVENT_BEGIN("chromeframe.createactivex", this, ""); |
| 121 } | 152 } |
| 122 | 153 |
| 123 HRESULT ChromeFrameActivex::FinalConstruct() { | 154 HRESULT ChromeFrameActivex::FinalConstruct() { |
| 124 HRESULT hr = Base::FinalConstruct(); | 155 HRESULT hr = Base::FinalConstruct(); |
| 125 if (FAILED(hr)) | 156 if (FAILED(hr)) |
| 126 return hr; | 157 return hr; |
| 127 | 158 |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 if (FAILED(hr)) { | 725 if (FAILED(hr)) { |
| 695 NOTREACHED() << "ChromeFrame BHO SetSite failed. Error:" | 726 NOTREACHED() << "ChromeFrame BHO SetSite failed. Error:" |
| 696 << base::StringPrintf(" 0x%08X", hr); | 727 << base::StringPrintf(" 0x%08X", hr); |
| 697 return hr; | 728 return hr; |
| 698 } | 729 } |
| 699 | 730 |
| 700 web_browser2->PutProperty(base::win::ScopedBstr(bho_class_id_as_string), | 731 web_browser2->PutProperty(base::win::ScopedBstr(bho_class_id_as_string), |
| 701 base::win::ScopedVariant(bho)); | 732 base::win::ScopedVariant(bho)); |
| 702 return S_OK; | 733 return S_OK; |
| 703 } | 734 } |
| OLD | NEW |