diff options
author | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-12 00:36:11 +0000 |
---|---|---|
committer | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-12 00:36:11 +0000 |
commit | 8e95ee1fcfc765f940bcb1cb0a961c8158e9bff5 (patch) | |
tree | b219c2a55afa2c1a69738b63898a7a6e92936eae /ceee | |
parent | c1afdb9074ac86f73799723cbbbd87b062bcb9de (diff) | |
download | chromium_src-8e95ee1fcfc765f940bcb1cb0a961c8158e9bff5.zip chromium_src-8e95ee1fcfc765f940bcb1cb0a961c8158e9bff5.tar.gz chromium_src-8e95ee1fcfc765f940bcb1cb0a961c8158e9bff5.tar.bz2 |
Added refreshing of elevation policy on first run of new version for all users.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/5720004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68951 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ceee')
-rw-r--r-- | ceee/ie/broker/broker_module.cc | 8 | ||||
-rw-r--r-- | ceee/ie/broker/broker_rpc_client.cc | 34 | ||||
-rw-r--r-- | ceee/ie/broker/broker_rpc_client.h | 7 | ||||
-rw-r--r-- | ceee/ie/common/ceee_module_util.cc | 35 | ||||
-rw-r--r-- | ceee/ie/common/ceee_module_util.h | 3 | ||||
-rw-r--r-- | ceee/ie/plugin/bho/browser_helper_object.cc | 5 | ||||
-rw-r--r-- | ceee/ie/plugin/bho/executor.cc | 9 | ||||
-rw-r--r-- | ceee/installer_dll/ceee_installer_dll.gyp | 3 |
8 files changed, 75 insertions, 29 deletions
diff --git a/ceee/ie/broker/broker_module.cc b/ceee/ie/broker/broker_module.cc index acb8a3e..71a007a 100644 --- a/ceee/ie/broker/broker_module.cc +++ b/ceee/ie/broker/broker_module.cc @@ -6,22 +6,22 @@ #include <atlbase.h> #include <atlhost.h> -#include <iepmapi.h> #include "base/at_exit.h" #include "base/command_line.h" #include "base/debug/trace_event.h" #include "base/logging.h" #include "base/logging_win.h" +#include "ceee/common/com_utils.h" #include "ceee/ie/broker/broker.h" #include "ceee/ie/broker/broker_rpc_server.h" #include "ceee/ie/broker/chrome_postman.h" #include "ceee/ie/broker/executors_manager.h" #include "ceee/ie/broker/resource.h" #include "ceee/ie/broker/window_events_funnel.h" -#include "ceee/ie/plugin/toolband/toolband_proxy.h" +#include "ceee/ie/common/ceee_module_util.h" #include "ceee/ie/common/crash_reporter.h" -#include "ceee/common/com_utils.h" +#include "ceee/ie/plugin/toolband/toolband_proxy.h" #include "chrome/common/url_constants.h" #include "chrome_frame/metrics_service.h" @@ -216,7 +216,7 @@ CeeeBrokerModule::~CeeeBrokerModule() { HRESULT WINAPI CeeeBrokerModule::UpdateRegistryAppId(BOOL reg) throw() { HRESULT hr = com::ModuleRegistrationWithoutAppid(IDR_BROKER_MODULE, reg); if (SUCCEEDED(hr)) { - hr = ::IERefreshElevationPolicy(); + ceee_module_util::RefreshElevationPolicyIfNeeded(); } return hr; } diff --git a/ceee/ie/broker/broker_rpc_client.cc b/ceee/ie/broker/broker_rpc_client.cc index 5d745b22..f86bae52 100644 --- a/ceee/ie/broker/broker_rpc_client.cc +++ b/ceee/ie/broker/broker_rpc_client.cc @@ -7,15 +7,17 @@ #include "ceee/ie/broker/broker_rpc_client.h" #include <atlbase.h> + #include "base/lock.h" #include "base/logging.h" #include "base/tuple.h" #include "base/win/scoped_comptr.h" -#include "broker_lib.h" // NOLINT -#include "broker_rpc_lib.h" // NOLINT #include "ceee/common/com_utils.h" #include "ceee/ie/broker/broker_rpc_utils.h" +#include "ceee/ie/common/ceee_module_util.h" +#include "broker_lib.h" // NOLINT +#include "broker_rpc_lib.h" // NOLINT namespace { @@ -115,16 +117,8 @@ void BrokerRpcClient::ReleaseContext() { } RpcEndExcept } -HRESULT BrokerRpcClient::StartServer(IUnknown** server) { - base::win::ScopedComPtr<IUnknown> broker; - // TODO(vitalybuka@google.com): Start broker without COM after the last - // COM interface is removed. - HRESULT hr = broker.CreateInstance(CLSID_CeeeBroker); - LOG_IF(ERROR, FAILED(hr)) << "Failed to create broker. " << com::LogHr(hr); - if (FAILED(hr)) - return hr; - *server = broker.Detach(); - return S_OK; +HRESULT BrokerRpcClient::StartServer(ICeeeBrokerRegistrar** server) { + return StartCeeeBroker(server); } HRESULT BrokerRpcClient::Connect(bool start_server) { @@ -132,7 +126,7 @@ HRESULT BrokerRpcClient::Connect(bool start_server) { return S_OK; // Keep alive until RPC is connected. - base::win::ScopedComPtr<IUnknown> broker; + base::win::ScopedComPtr<ICeeeBrokerRegistrar> broker; if (start_server) { HRESULT hr = StartServer(broker.Receive()); if (FAILED(hr)) @@ -211,3 +205,17 @@ HRESULT BrokerRpcClient::SendUmaHistogramData(const char* name, MakeRefTuple(binding_handle_, name, sample, min, max, bucket_count)); } + +HRESULT StartCeeeBroker(ICeeeBrokerRegistrar** broker) { + ceee_module_util::RefreshElevationPolicyIfNeeded(); + base::win::ScopedComPtr<ICeeeBrokerRegistrar> broker_tmp; + // TODO(vitalybuka@google.com): Start broker without COM after the last + // COM interface is removed. + HRESULT hr = broker_tmp.CreateInstance(CLSID_CeeeBroker); + if (FAILED(hr)) { + LOG(ERROR) << "Failed to create broker. " << com::LogHr(hr); + return hr; + } + *broker = broker_tmp.Detach(); + return S_OK; +} diff --git a/ceee/ie/broker/broker_rpc_client.h b/ceee/ie/broker/broker_rpc_client.h index 3ca59ff1..26ddd75 100644 --- a/ceee/ie/broker/broker_rpc_client.h +++ b/ceee/ie/broker/broker_rpc_client.h @@ -10,7 +10,8 @@ #include <wtypes.h> #include "base/basictypes.h" -struct IUnknown; +struct ICeeeBrokerRegistrar; + // Interface for sending events. class IEventSender { public: @@ -57,7 +58,7 @@ class BrokerRpcClient : public IEventSender { protected: // Starts ceee broker process. This is unittest seam. - virtual HRESULT StartServer(IUnknown** server); + virtual HRESULT StartServer(ICeeeBrokerRegistrar** server); private: void LockContext(); @@ -76,4 +77,6 @@ class BrokerRpcClient : public IEventSender { DISALLOW_COPY_AND_ASSIGN(BrokerRpcClient); }; +HRESULT StartCeeeBroker(ICeeeBrokerRegistrar** broker); + #endif // CEEE_IE_BROKER_BROKER_RPC_CLIENT_H_ diff --git a/ceee/ie/common/ceee_module_util.cc b/ceee/ie/common/ceee_module_util.cc index 3e18dbc..836f031 100644 --- a/ceee/ie/common/ceee_module_util.cc +++ b/ceee/ie/common/ceee_module_util.cc @@ -6,13 +6,17 @@ #include "ceee/ie/common/ceee_module_util.h" +#include <iepmapi.h> + #include "base/file_path.h" #include "base/file_util.h" #include "base/logging.h" #include "base/path_service.h" #include "base/stringize_macros.h" #include "base/win/registry.h" +#include "ceee/common/com_utils.h" #include "ceee/common/process_utils_win.h" +#include "ceee/ie/common/ie_util.h" #include "chrome/installer/util/google_update_constants.h" #include "version.h" // NOLINT @@ -306,4 +310,35 @@ bool GetCollectStatsConsent() { return (1 == value); } +bool RefreshElevationPolicyIfNeeded() { + if (ie_util::GetIeVersion() < ie_util::IEVERSION_IE7) + return false; + + // This may access InternetRegistry instead of real one. However this is + // acceptable, we just refresh policy twice. + base::win::RegKey hkcu(HKEY_CURRENT_USER, kRegistryPath, + KEY_WRITE | KEY_QUERY_VALUE); + LOG_IF(ERROR, !hkcu.Valid()) << "Failed to open reg key: " << kRegistryPath; + if (!hkcu.Valid()) + return false; + + std::wstring expected_version = TO_L_STRING(CHROME_VERSION_STRING); + + static const wchar_t kValueName[] = L"last_elevation_refresh"; + std::wstring last_elevation_refresh_version; + bool result = hkcu.ReadValue(kValueName, &last_elevation_refresh_version); + if (last_elevation_refresh_version == expected_version) + return false; + + HRESULT hr = ::IERefreshElevationPolicy(); + VLOG(1) << "Elevation policy refresh result: " << com::LogHr(hr); + + // Write after refreshing because it's better to refresh twice, than to miss + // once. + result = hkcu.WriteValue(kValueName, expected_version.c_str()); + LOG_IF(ERROR, !result) << "Failed to write a registry value: " << kValueName; + + return true; +} + } // namespace ceee_module_util diff --git a/ceee/ie/common/ceee_module_util.h b/ceee/ie/common/ceee_module_util.h index bb1291f..d3af2be 100644 --- a/ceee/ie/common/ceee_module_util.h +++ b/ceee/ie/common/ceee_module_util.h @@ -103,6 +103,9 @@ extern const wchar_t kInternetExplorerModuleName[]; // The name of the CEEE Broker executable. extern const wchar_t kCeeeBrokerModuleName[]; +// Refreshes elevation policy. Returns false if refresh was not needed. +bool RefreshElevationPolicyIfNeeded(); + } // namespace #endif // CEEE_IE_COMMON_TOOLBAND_MODULE_UTIL_H__ diff --git a/ceee/ie/plugin/bho/browser_helper_object.cc b/ceee/ie/plugin/bho/browser_helper_object.cc index 9d0e5a0a5..dc4bac2 100644 --- a/ceee/ie/plugin/bho/browser_helper_object.cc +++ b/ceee/ie/plugin/bho/browser_helper_object.cc @@ -266,10 +266,7 @@ HRESULT BrowserHelperObject::GetBrokerRegistrar(ICeeeBrokerRegistrar** broker) { DCHECK(broker); if (broker == NULL) return E_INVALIDARG; - HRESULT hr = ::CoCreateInstance(CLSID_CeeeBroker, NULL, CLSCTX_ALL, - IID_ICeeeBrokerRegistrar, - reinterpret_cast<void**>(broker)); - DCHECK(SUCCEEDED(hr) && *broker) << "CoCreating Broker. " << com::LogHr(hr); + HRESULT hr = StartCeeeBroker(broker); if (FAILED(hr) || *broker == NULL) return com::AlwaysError(hr); return hr; diff --git a/ceee/ie/plugin/bho/executor.cc b/ceee/ie/plugin/bho/executor.cc index eb80047..86ad755 100644 --- a/ceee/ie/plugin/bho/executor.cc +++ b/ceee/ie/plugin/bho/executor.cc @@ -38,6 +38,7 @@ #include "base/values.h" #include "base/stringprintf.h" #include "base/utf_string_conversions.h" +#include "base/win/scoped_comptr.h" #include "ceee/common/com_utils.h" #include "ceee/common/window_utils.h" #include "ceee/common/windows_constants.h" @@ -170,12 +171,8 @@ LRESULT CeeeExecutorCreator::GetMsgProc(int code, WPARAM wparam, DCHECK(SUCCEEDED(hr)) << "CoCreating Executor. " << com::LogHr(hr); } - CComPtr<ICeeeBrokerRegistrar> broker; - hr = broker.CoCreateInstance(CLSID_CeeeBroker); - LOG_IF(ERROR, FAILED(hr)) << "Failed to create broker, hr=" << - com::LogHr(hr); - DCHECK(SUCCEEDED(hr)) << "CoCreating Broker. " << com::LogHr(hr); - + base::win::ScopedComPtr<ICeeeBrokerRegistrar> broker; + hr = StartCeeeBroker(broker.Receive()); if (SUCCEEDED(hr)) { hr = broker->RegisterWindowExecutor(::GetCurrentThreadId(), executor); DCHECK(SUCCEEDED(hr)) << "Registering Executor. " << com::LogHr(hr); diff --git a/ceee/installer_dll/ceee_installer_dll.gyp b/ceee/installer_dll/ceee_installer_dll.gyp index 20026a1..c3795cb 100644 --- a/ceee/installer_dll/ceee_installer_dll.gyp +++ b/ceee/installer_dll/ceee_installer_dll.gyp @@ -64,6 +64,9 @@ ], }, ], + 'libraries': [ + 'iepmapi.lib', + ], }, ], } |