| 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 defines functions that integrate Chrome in Windows shell. These | 5 // This file defines functions that integrate Chrome in Windows shell. These |
| 6 // functions can be used by Chrome as well as Chrome installer. All of the | 6 // functions can be used by Chrome as well as Chrome installer. All of the |
| 7 // work is done by the local functions defined in anonymous namespace in | 7 // work is done by the local functions defined in anonymous namespace in |
| 8 // this class. | 8 // this class. |
| 9 | 9 |
| 10 #include "chrome/installer/util/shell_util.h" | 10 #include "chrome/installer/util/shell_util.h" |
| 11 | 11 |
| 12 #include <windows.h> | 12 #include <windows.h> |
| 13 #include <shlobj.h> | 13 #include <shlobj.h> |
| 14 #include <shobjidl.h> | 14 #include <shobjidl.h> |
| 15 | 15 |
| 16 #include <limits> | 16 #include <limits> |
| 17 #include <string> | 17 #include <string> |
| 18 | 18 |
| 19 #include "base/bind.h" | 19 #include "base/bind.h" |
| 20 #include "base/command_line.h" | 20 #include "base/command_line.h" |
| 21 #include "base/files/file_enumerator.h" | 21 #include "base/files/file_enumerator.h" |
| 22 #include "base/files/file_path.h" | 22 #include "base/files/file_path.h" |
| 23 #include "base/files/file_util.h" | 23 #include "base/files/file_util.h" |
| 24 #include "base/lazy_instance.h" | 24 #include "base/lazy_instance.h" |
| 25 #include "base/logging.h" | 25 #include "base/logging.h" |
| 26 #include "base/macros.h" | 26 #include "base/macros.h" |
| 27 #include "base/md5.h" | 27 #include "base/md5.h" |
| 28 #include "base/memory/scoped_ptr.h" | 28 #include "base/memory/scoped_ptr.h" |
| 29 #include "base/memory/scoped_vector.h" | 29 #include "base/memory/scoped_vector.h" |
| 30 #include "base/metrics/sparse_histogram.h" |
| 30 #include "base/path_service.h" | 31 #include "base/path_service.h" |
| 31 #include "base/strings/string16.h" | 32 #include "base/strings/string16.h" |
| 32 #include "base/strings/string_number_conversions.h" | 33 #include "base/strings/string_number_conversions.h" |
| 33 #include "base/strings/string_split.h" | 34 #include "base/strings/string_split.h" |
| 34 #include "base/strings/string_util.h" | 35 #include "base/strings/string_util.h" |
| 35 #include "base/strings/stringprintf.h" | 36 #include "base/strings/stringprintf.h" |
| 36 #include "base/strings/utf_string_conversions.h" | 37 #include "base/strings/utf_string_conversions.h" |
| 37 #include "base/synchronization/cancellation_flag.h" | 38 #include "base/synchronization/cancellation_flag.h" |
| 38 #include "base/values.h" | 39 #include "base/values.h" |
| 39 #include "base/win/registry.h" | 40 #include "base/win/registry.h" |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 bool LaunchDefaultAppsSettingsModernDialog() { | 714 bool LaunchDefaultAppsSettingsModernDialog() { |
| 714 base::win::ScopedComPtr<IApplicationActivationManager> activator; | 715 base::win::ScopedComPtr<IApplicationActivationManager> activator; |
| 715 HRESULT hr = activator.CreateInstance(CLSID_ApplicationActivationManager); | 716 HRESULT hr = activator.CreateInstance(CLSID_ApplicationActivationManager); |
| 716 if (SUCCEEDED(hr)) { | 717 if (SUCCEEDED(hr)) { |
| 717 DWORD pid = 0; | 718 DWORD pid = 0; |
| 718 CoAllowSetForegroundWindow(activator.get(), nullptr); | 719 CoAllowSetForegroundWindow(activator.get(), nullptr); |
| 719 hr = activator->ActivateApplication( | 720 hr = activator->ActivateApplication( |
| 720 L"windows.immersivecontrolpanel_cw5n1h2txyewy" | 721 L"windows.immersivecontrolpanel_cw5n1h2txyewy" |
| 721 L"!microsoft.windows.immersivecontrolpanel", | 722 L"!microsoft.windows.immersivecontrolpanel", |
| 722 L"page=SettingsPageAppsDefaults", AO_NONE, &pid); | 723 L"page=SettingsPageAppsDefaults", AO_NONE, &pid); |
| 723 return SUCCEEDED(hr); | 724 if (SUCCEEDED(hr)) { |
| 725 hr = activator->ActivateApplication( |
| 726 L"windows.immersivecontrolpanel_cw5n1h2txyewy" |
| 727 L"!microsoft.windows.immersivecontrolpanel", |
| 728 L"page=SettingsPageAppsDefaults" |
| 729 L"&target=SystemSettings_DefaultApps_Browser", AO_NONE, &pid); |
| 730 } |
| 731 if (SUCCEEDED(hr)) |
| 732 return true; |
| 733 UMA_HISTOGRAM_SPARSE_SLOWLY("DefaultBrowser.ActivateSettings.ErrorHresult", |
| 734 hr); |
| 724 } | 735 } |
| 725 return false; | 736 return false; |
| 726 } | 737 } |
| 727 | 738 |
| 728 // Launches the Windows 7 and Windows 8 dialog for picking the application to | 739 // Launches the Windows 7 and Windows 8 dialog for picking the application to |
| 729 // handle the given protocol. Most importantly, this is used to set the default | 740 // handle the given protocol. Most importantly, this is used to set the default |
| 730 // handler for http (and, implicitly with it, https). In that case it is also | 741 // handler for http (and, implicitly with it, https). In that case it is also |
| 731 // known as the 'how do you want to open webpages' dialog. | 742 // known as the 'how do you want to open webpages' dialog. |
| 732 // It is required that Chrome be already *registered* for the given protocol. | 743 // It is required that Chrome be already *registered* for the given protocol. |
| 733 bool LaunchSelectDefaultProtocolHandlerDialog(const wchar_t* protocol) { | 744 bool LaunchSelectDefaultProtocolHandlerDialog(const wchar_t* protocol) { |
| (...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2329 itr != entries.end(); ++itr) | 2340 itr != entries.end(); ++itr) |
| 2330 (*itr)->AddToWorkItemList(root, items.get()); | 2341 (*itr)->AddToWorkItemList(root, items.get()); |
| 2331 | 2342 |
| 2332 // Apply all the registry changes and if there is a problem, rollback | 2343 // Apply all the registry changes and if there is a problem, rollback |
| 2333 if (!items->Do()) { | 2344 if (!items->Do()) { |
| 2334 items->Rollback(); | 2345 items->Rollback(); |
| 2335 return false; | 2346 return false; |
| 2336 } | 2347 } |
| 2337 return true; | 2348 return true; |
| 2338 } | 2349 } |
| OLD | NEW |