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 // This file declares util functions for setup project. | 5 // This file declares util functions for setup project. |
6 | 6 |
7 #include "chrome/installer/setup/setup_util.h" | 7 #include "chrome/installer/setup/setup_util.h" |
8 | 8 |
9 #include <windows.h> | 9 #include <windows.h> |
10 | 10 |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 // Copy usagestats from the binaries to the product's ClientState key. | 387 // Copy usagestats from the binaries to the product's ClientState key. |
388 product = machine_state.GetProductState(system_level, | 388 product = machine_state.GetProductState(system_level, |
389 BrowserDistribution::CHROME_BINARIES); | 389 BrowserDistribution::CHROME_BINARIES); |
390 DWORD usagestats = 0; | 390 DWORD usagestats = 0; |
391 if (product && product->GetUsageStats(&usagestats)) { | 391 if (product && product->GetUsageStats(&usagestats)) { |
392 dist = product_to_migrate.distribution(); | 392 dist = product_to_migrate.distribution(); |
393 result = state_key.Open(root, dist->GetStateKey().c_str(), | 393 result = state_key.Open(root, dist->GetStateKey().c_str(), |
394 KEY_SET_VALUE); | 394 KEY_SET_VALUE); |
395 if (result != ERROR_SUCCESS) { | 395 if (result != ERROR_SUCCESS) { |
396 LOG(ERROR) << "Failed opening ClientState key for " | 396 LOG(ERROR) << "Failed opening ClientState key for " |
397 << dist->GetAppShortCutName() << " to migrate usagestats."; | 397 << dist->GetDisplayName() << " to migrate usagestats."; |
398 } else { | 398 } else { |
399 state_key.WriteValue(google_update::kRegUsageStatsField, usagestats); | 399 state_key.WriteValue(google_update::kRegUsageStatsField, usagestats); |
400 } | 400 } |
401 } | 401 } |
402 | 402 |
403 // Remove the migrating product from the "ap" value of other multi-install | 403 // Remove the migrating product from the "ap" value of other multi-install |
404 // products. | 404 // products. |
405 for (int i = 0; i < BrowserDistribution::NUM_TYPES; ++i) { | 405 for (int i = 0; i < BrowserDistribution::NUM_TYPES; ++i) { |
406 BrowserDistribution::Type type = | 406 BrowserDistribution::Type type = |
407 static_cast<BrowserDistribution::Type>(i); | 407 static_cast<BrowserDistribution::Type>(i); |
408 if (type == to_migrate) | 408 if (type == to_migrate) |
409 continue; | 409 continue; |
410 product = machine_state.GetProductState(system_level, type); | 410 product = machine_state.GetProductState(system_level, type); |
411 if (product && product->is_multi_install()) { | 411 if (product && product->is_multi_install()) { |
412 installer::ChannelInfo channel_info; | 412 installer::ChannelInfo channel_info; |
413 dist = BrowserDistribution::GetSpecificDistribution(type); | 413 dist = BrowserDistribution::GetSpecificDistribution(type); |
414 result = state_key.Open(root, dist->GetStateKey().c_str(), | 414 result = state_key.Open(root, dist->GetStateKey().c_str(), |
415 KEY_QUERY_VALUE | KEY_SET_VALUE); | 415 KEY_QUERY_VALUE | KEY_SET_VALUE); |
416 if (result == ERROR_SUCCESS && | 416 if (result == ERROR_SUCCESS && |
417 channel_info.Initialize(state_key) && | 417 channel_info.Initialize(state_key) && |
418 product_to_migrate.SetChannelFlags(false, &channel_info)) { | 418 product_to_migrate.SetChannelFlags(false, &channel_info)) { |
419 VLOG(1) << "Moving " << dist->GetAppShortCutName() | 419 VLOG(1) << "Moving " << dist->GetDisplayName() |
420 << " to channel: " << channel_info.value(); | 420 << " to channel: " << channel_info.value(); |
421 channel_info.Write(&state_key); | 421 channel_info.Write(&state_key); |
422 } | 422 } |
423 } | 423 } |
424 } | 424 } |
425 | 425 |
426 // Remove -multi, all product modifiers, and everything else but the channel | 426 // Remove -multi, all product modifiers, and everything else but the channel |
427 // name from the "ap" value of the product to migrate. | 427 // name from the "ap" value of the product to migrate. |
428 dist = product_to_migrate.distribution(); | 428 dist = product_to_migrate.distribution(); |
429 result = state_key.Open(root, dist->GetStateKey().c_str(), | 429 result = state_key.Open(root, dist->GetStateKey().c_str(), |
430 KEY_QUERY_VALUE | KEY_SET_VALUE); | 430 KEY_QUERY_VALUE | KEY_SET_VALUE); |
431 if (result == ERROR_SUCCESS) { | 431 if (result == ERROR_SUCCESS) { |
432 installer::ChannelInfo channel_info; | 432 installer::ChannelInfo channel_info; |
433 if (!channel_info.Initialize(state_key)) { | 433 if (!channel_info.Initialize(state_key)) { |
434 LOG(ERROR) << "Failed reading " << dist->GetAppShortCutName() | 434 LOG(ERROR) << "Failed reading " << dist->GetDisplayName() |
435 << " channel info."; | 435 << " channel info."; |
436 } else if (channel_info.RemoveAllModifiersAndSuffixes()) { | 436 } else if (channel_info.RemoveAllModifiersAndSuffixes()) { |
437 VLOG(1) << "Moving " << dist->GetAppShortCutName() | 437 VLOG(1) << "Moving " << dist->GetDisplayName() |
438 << " to channel: " << channel_info.value(); | 438 << " to channel: " << channel_info.value(); |
439 channel_info.Write(&state_key); | 439 channel_info.Write(&state_key); |
440 } | 440 } |
441 } | 441 } |
442 } | 442 } |
443 | 443 |
444 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) | 444 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) |
445 : is_enabled_(false) { | 445 : is_enabled_(false) { |
446 if (!::OpenProcessToken(::GetCurrentProcess(), | 446 if (!::OpenProcessToken(::GetCurrentProcess(), |
447 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, | 447 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, |
(...skipping 25 matching lines...) Expand all Loading... |
473 } | 473 } |
474 | 474 |
475 ScopedTokenPrivilege::~ScopedTokenPrivilege() { | 475 ScopedTokenPrivilege::~ScopedTokenPrivilege() { |
476 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { | 476 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { |
477 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, | 477 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, |
478 sizeof(TOKEN_PRIVILEGES), NULL, NULL); | 478 sizeof(TOKEN_PRIVILEGES), NULL, NULL); |
479 } | 479 } |
480 } | 480 } |
481 | 481 |
482 } // namespace installer | 482 } // namespace installer |
OLD | NEW |