OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // chrome_tab.cc : Implementation of DLL Exports. | 5 // chrome_tab.cc : Implementation of DLL Exports. |
6 | 6 |
7 // Need to include this before the ATL headers below. | 7 // Need to include this before the ATL headers below. |
8 #include "chrome_frame/chrome_tab.h" | 8 #include "chrome_frame/chrome_tab.h" |
9 | 9 |
10 #include <atlsecurity.h> | 10 #include <atlsecurity.h> |
11 #include <objbase.h> | 11 #include <objbase.h> |
12 | 12 |
13 #include "base/at_exit.h" | 13 #include "base/at_exit.h" |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/file_util.h" | 16 #include "base/file_util.h" |
17 #include "base/file_version_info.h" | 17 #include "base/file_version_info.h" |
| 18 #include "base/i18n/icu_util.h" |
18 #include "base/logging.h" | 19 #include "base/logging.h" |
19 #include "base/logging_win.h" | 20 #include "base/logging_win.h" |
20 #include "base/path_service.h" | 21 #include "base/path_service.h" |
21 #include "base/process/launch.h" | 22 #include "base/process/launch.h" |
22 #include "base/strings/string16.h" | 23 #include "base/strings/string16.h" |
23 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
24 #include "base/strings/string_piece.h" | 25 #include "base/strings/string_piece.h" |
25 #include "base/strings/string_util.h" | 26 #include "base/strings/string_util.h" |
26 #include "base/strings/sys_string_conversions.h" | 27 #include "base/strings/sys_string_conversions.h" |
27 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 static const char kDummyUrl[] = "http://www.google.com"; | 101 static const char kDummyUrl[] = "http://www.google.com"; |
101 | 102 |
102 url_util::IsStandard(kDummyUrl, | 103 url_util::IsStandard(kDummyUrl, |
103 url_parse::MakeRange(0, arraysize(kDummyUrl))); | 104 url_parse::MakeRange(0, arraysize(kDummyUrl))); |
104 } | 105 } |
105 | 106 |
106 class ChromeTabModule : public CAtlDllModuleT<ChromeTabModule> { | 107 class ChromeTabModule : public CAtlDllModuleT<ChromeTabModule> { |
107 public: | 108 public: |
108 typedef CAtlDllModuleT<ChromeTabModule> ParentClass; | 109 typedef CAtlDllModuleT<ChromeTabModule> ParentClass; |
109 | 110 |
110 ChromeTabModule() : do_system_registration_(true), crash_reporting_(NULL) {} | 111 ChromeTabModule() : do_system_registration_(true), |
| 112 crash_reporting_(NULL), |
| 113 icu_initialized_(false) {} |
111 | 114 |
112 DECLARE_LIBID(LIBID_ChromeTabLib) | 115 DECLARE_LIBID(LIBID_ChromeTabLib) |
113 DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CHROMETAB, | 116 DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CHROMETAB, |
114 "{FD9B1B31-F4D8-436A-8F4F-D3C2E36733D3}") | 117 "{FD9B1B31-F4D8-436A-8F4F-D3C2E36733D3}") |
115 | 118 |
116 // Override to add our SYSTIME binary value to registry scripts. | 119 // Override to add our SYSTIME binary value to registry scripts. |
117 // See chrome_frame_activex.rgs for usage. | 120 // See chrome_frame_activex.rgs for usage. |
118 virtual HRESULT AddCommonRGSReplacements(IRegistrarBase* registrar) throw() { | 121 virtual HRESULT AddCommonRGSReplacements(IRegistrarBase* registrar) throw() { |
119 HRESULT hr = ParentClass::AddCommonRGSReplacements(registrar); | 122 HRESULT hr = ParentClass::AddCommonRGSReplacements(registrar); |
120 | 123 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 wchar_t cf_clsid[64]; | 195 wchar_t cf_clsid[64]; |
193 StringFromGUID2(CLSID_ChromeFrame, &cf_clsid[0], arraysize(cf_clsid)); | 196 StringFromGUID2(CLSID_ChromeFrame, &cf_clsid[0], arraysize(cf_clsid)); |
194 hr = registrar->AddReplacement(L"CHROME_FRAME_CLSID", &cf_clsid[0]); | 197 hr = registrar->AddReplacement(L"CHROME_FRAME_CLSID", &cf_clsid[0]); |
195 } | 198 } |
196 | 199 |
197 return hr; | 200 return hr; |
198 } | 201 } |
199 | 202 |
200 // The module is "locked" when an object takes a reference on it. The first | 203 // The module is "locked" when an object takes a reference on it. The first |
201 // time it is locked, take a reference on crash reporting to bind its lifetime | 204 // time it is locked, take a reference on crash reporting to bind its lifetime |
202 // to the module. | 205 // to the module and initialize ICU. |
203 virtual LONG Lock() throw() { | 206 virtual LONG Lock() throw() { |
204 LONG result = ParentClass::Lock(); | 207 LONG result = ParentClass::Lock(); |
205 if (result == 1) { | 208 if (result == 1) { |
206 DCHECK_EQ(crash_reporting_, | 209 DCHECK_EQ(crash_reporting_, |
207 static_cast<chrome_frame::ScopedCrashReporting*>(NULL)); | 210 static_cast<chrome_frame::ScopedCrashReporting*>(NULL)); |
208 crash_reporting_ = new chrome_frame::ScopedCrashReporting(); | 211 crash_reporting_ = new chrome_frame::ScopedCrashReporting(); |
| 212 |
| 213 // Initialize ICU if this is the first time the module has been locked. |
| 214 if (!icu_initialized_) { |
| 215 icu_initialized_ = true; |
| 216 // Best-effort since something is better than nothing here. |
| 217 ignore_result(base::i18n::InitializeICU()); |
| 218 } |
209 } | 219 } |
210 return result; | 220 return result; |
211 } | 221 } |
212 | 222 |
213 // The module is "unlocked" when an object that had a reference on it is | 223 // The module is "unlocked" when an object that had a reference on it is |
214 // destroyed. The last time it is unlocked, release the reference on crash | 224 // destroyed. The last time it is unlocked, release the reference on crash |
215 // reporting. | 225 // reporting. |
216 virtual LONG Unlock() throw() { | 226 virtual LONG Unlock() throw() { |
217 LONG result = ParentClass::Unlock(); | 227 LONG result = ParentClass::Unlock(); |
218 if (!result) { | 228 if (!result) { |
219 DCHECK_NE(crash_reporting_, | 229 DCHECK_NE(crash_reporting_, |
220 static_cast<chrome_frame::ScopedCrashReporting*>(NULL)); | 230 static_cast<chrome_frame::ScopedCrashReporting*>(NULL)); |
221 delete crash_reporting_; | 231 delete crash_reporting_; |
222 crash_reporting_ = NULL; | 232 crash_reporting_ = NULL; |
223 } | 233 } |
224 return result; | 234 return result; |
225 } | 235 } |
226 | 236 |
227 // See comments in AddCommonRGSReplacements | 237 // See comments in AddCommonRGSReplacements |
228 bool do_system_registration_; | 238 bool do_system_registration_; |
229 | 239 |
230 private: | 240 private: |
231 // A scoper created when the module is initially locked and destroyed when it | 241 // A scoper created when the module is initially locked and destroyed when it |
232 // is finally unlocked. This is not a scoped_ptr since that could cause | 242 // is finally unlocked. This is not a scoped_ptr since that could cause |
233 // reporting to shut down at exit, which would lead to problems with the | 243 // reporting to shut down at exit, which would lead to problems with the |
234 // loader lock. | 244 // loader lock. |
235 chrome_frame::ScopedCrashReporting* crash_reporting_; | 245 chrome_frame::ScopedCrashReporting* crash_reporting_; |
| 246 |
| 247 // Initially false, this is flipped to true to indicate that ICU has been |
| 248 // initialized for the module. |
| 249 bool icu_initialized_; |
236 }; | 250 }; |
237 | 251 |
238 ChromeTabModule _AtlModule; | 252 ChromeTabModule _AtlModule; |
239 | 253 |
240 base::AtExitManager* g_exit_manager = NULL; | 254 base::AtExitManager* g_exit_manager = NULL; |
241 | 255 |
242 HRESULT RefreshElevationPolicy() { | 256 HRESULT RefreshElevationPolicy() { |
243 const wchar_t kIEFrameDll[] = L"ieframe.dll"; | 257 const wchar_t kIEFrameDll[] = L"ieframe.dll"; |
244 const char kIERefreshPolicy[] = "IERefreshElevationPolicy"; | 258 const char kIERefreshPolicy[] = "IERefreshElevationPolicy"; |
245 HRESULT hr = E_NOTIMPL; | 259 HRESULT hr = E_NOTIMPL; |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 HRESULT hr = CustomRegistration(ALL, FALSE, false); | 1027 HRESULT hr = CustomRegistration(ALL, FALSE, false); |
1014 return hr; | 1028 return hr; |
1015 } | 1029 } |
1016 | 1030 |
1017 // Object entries go here instead of with each object, so that we can move | 1031 // Object entries go here instead of with each object, so that we can move |
1018 // the objects to a lib. Also reduces magic. | 1032 // the objects to a lib. Also reduces magic. |
1019 OBJECT_ENTRY_AUTO(CLSID_ChromeFrameBHO, Bho) | 1033 OBJECT_ENTRY_AUTO(CLSID_ChromeFrameBHO, Bho) |
1020 OBJECT_ENTRY_AUTO(__uuidof(ChromeActiveDocument), ChromeActiveDocument) | 1034 OBJECT_ENTRY_AUTO(__uuidof(ChromeActiveDocument), ChromeActiveDocument) |
1021 OBJECT_ENTRY_AUTO(__uuidof(ChromeFrame), ChromeFrameActivex) | 1035 OBJECT_ENTRY_AUTO(__uuidof(ChromeFrame), ChromeFrameActivex) |
1022 OBJECT_ENTRY_AUTO(__uuidof(ChromeProtocol), ChromeProtocol) | 1036 OBJECT_ENTRY_AUTO(__uuidof(ChromeProtocol), ChromeProtocol) |
OLD | NEW |