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

Side by Side Diff: chrome_frame/chrome_tab.cc

Issue 6355001: Unregister previous ChromeFrame UA strings registered under the PostPlatform ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months 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 | « no previous file | no next file » | 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 // chrome_tab.cc : Implementation of DLL Exports. 5 // chrome_tab.cc : Implementation of DLL Exports.
6 6
7 // Include without path to make GYP build see it. 7 // Include without path to make GYP build see it.
8 #include "chrome_tab.h" // NOLINT 8 #include "chrome_tab.h" // NOLINT
9 9
10 #include <atlsecurity.h> 10 #include <atlsecurity.h>
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 const wchar_t kChromeFramePrefix[] = L"chromeframe/"; 427 const wchar_t kChromeFramePrefix[] = L"chromeframe/";
428 428
429 // To delete the user agent, set value to NULL. 429 // To delete the user agent, set value to NULL.
430 // The is_system parameter indicates whether this is a per machine or a per 430 // The is_system parameter indicates whether this is a per machine or a per
431 // user installation. 431 // user installation.
432 HRESULT SetChromeFrameUA(bool is_system, const wchar_t* value) { 432 HRESULT SetChromeFrameUA(bool is_system, const wchar_t* value) {
433 HRESULT hr = E_FAIL; 433 HRESULT hr = E_FAIL;
434 HKEY parent_hive = is_system ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 434 HKEY parent_hive = is_system ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
435 435
436 RegKey ua_key; 436 RegKey ua_key;
437 if (ua_key.Create(parent_hive, kPostPlatformUAKey, KEY_WRITE)) { 437 if (ua_key.Create(parent_hive, kPostPlatformUAKey, KEY_READ | KEY_WRITE)) {
438
439 // Make sure that we unregister ChromeFrame UA strings registered previously
440 std::wstring chrome_frame_ua_pattern = kChromeFramePrefix;
441 chrome_frame_ua_pattern += L"*";
442
443 wchar_t name[MAX_PATH + 1] = {};
444 wchar_t value[MAX_PATH + 1] = {};
445
446 for (DWORD value_index = 0; value_index < ua_key.ValueCount();
amit 2011/01/14 06:38:51 nit: while (value_index < ua_key.ValueCount()) and
ananta 2011/01/14 06:44:11 Done.
447 value_index++) {
448 DWORD name_size = arraysize(name);
449 DWORD value_size = arraysize(value);
450 DWORD type = 0;
451 LRESULT ret = ::RegEnumValue(ua_key.Handle(),
amit 2011/01/14 06:38:51 nit: fit more on one line to match rest of the sou
ananta 2011/01/14 06:44:11 Done.
452 value_index,
453 name,
454 &name_size,
455 NULL,
456 &type, reinterpret_cast<BYTE*>(value),
457 &value_size);
458 if (ret == ERROR_SUCCESS) {
459 if (MatchPattern(name, chrome_frame_ua_pattern)) {
amit 2011/01/14 06:38:51 A simple StartsWith is enough instead of MatchPatt
ananta 2011/01/14 06:44:11 Done.
460 ua_key.DeleteValue(name);
461 value_index--;
462 }
463 } else {
464 break;
465 }
466 }
467
438 std::wstring chrome_frame_ua_value_name = kChromeFramePrefix; 468 std::wstring chrome_frame_ua_value_name = kChromeFramePrefix;
439 chrome_frame_ua_value_name += GetCurrentModuleVersion(); 469 chrome_frame_ua_value_name += GetCurrentModuleVersion();
440 if (value) { 470 if (value) {
441 ua_key.WriteValue(chrome_frame_ua_value_name.c_str(), value); 471 ua_key.WriteValue(chrome_frame_ua_value_name.c_str(), value);
442 } else {
443 ua_key.DeleteValue(chrome_frame_ua_value_name.c_str());
444 } 472 }
445 hr = S_OK; 473 hr = S_OK;
446 } else { 474 } else {
447 DLOG(ERROR) << __FUNCTION__ << ": " << kPostPlatformUAKey; 475 DLOG(ERROR) << __FUNCTION__ << ": " << kPostPlatformUAKey;
448 hr = E_UNEXPECTED; 476 hr = E_UNEXPECTED;
449 } 477 }
450 return hr; 478 return hr;
451 } 479 }
452 480
453 enum RegistrationFlags { 481 enum RegistrationFlags {
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 sd.GetDacl(&new_dacl); 816 sd.GetDacl(&new_dacl);
789 new_dacl.AddAllowedAce(token_.GetUser(), GENERIC_WRITE | GENERIC_READ); 817 new_dacl.AddAllowedAce(token_.GetUser(), GENERIC_WRITE | GENERIC_READ);
790 if (AtlSetDacl(object_name.c_str(), SE_REGISTRY_KEY, new_dacl)) { 818 if (AtlSetDacl(object_name.c_str(), SE_REGISTRY_KEY, new_dacl)) {
791 result = SetOrDeleteMimeHandlerKey(enable, HKEY_LOCAL_MACHINE); 819 result = SetOrDeleteMimeHandlerKey(enable, HKEY_LOCAL_MACHINE);
792 } 820 }
793 } 821 }
794 822
795 backup.RestoreSecurity(object_name.c_str()); 823 backup.RestoreSecurity(object_name.c_str());
796 return result; 824 return result;
797 } 825 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698