OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/platform_util.h" | 5 #include "chrome/browser/platform_util.h" |
6 | 6 |
7 #include <commdlg.h> | 7 #include <commdlg.h> |
8 #include <dwmapi.h> | 8 #include <dwmapi.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
11 | 11 |
12 #include "app/win/scoped_co_mem.h" | |
13 #include "app/win/shell.h" | |
14 #include "base/file_path.h" | 12 #include "base/file_path.h" |
15 #include "base/file_util.h" | 13 #include "base/file_util.h" |
16 #include "base/logging.h" | 14 #include "base/logging.h" |
17 #include "base/path_service.h" | 15 #include "base/path_service.h" |
18 #include "base/string_util.h" | 16 #include "base/string_util.h" |
19 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
20 #include "base/win/registry.h" | 18 #include "base/win/registry.h" |
21 #include "base/win/scoped_comptr.h" | 19 #include "base/win/scoped_comptr.h" |
| 20 #include "chrome/common/scoped_co_mem.h" |
22 #include "chrome/installer/util/browser_distribution.h" | 21 #include "chrome/installer/util/browser_distribution.h" |
23 #include "chrome/installer/util/google_update_constants.h" | 22 #include "chrome/installer/util/google_update_constants.h" |
24 #include "chrome/installer/util/google_update_settings.h" | 23 #include "chrome/installer/util/google_update_settings.h" |
25 #include "chrome/installer/util/install_util.h" | 24 #include "chrome/installer/util/install_util.h" |
26 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
27 #include "ui/base/message_box_win.h" | 26 #include "ui/base/message_box_win.h" |
| 27 #include "ui/base/win/shell.h" |
28 #include "ui/gfx/native_widget_types.h" | 28 #include "ui/gfx/native_widget_types.h" |
29 | 29 |
30 namespace platform_util { | 30 namespace platform_util { |
31 | 31 |
32 void ShowItemInFolder(const FilePath& full_path) { | 32 void ShowItemInFolder(const FilePath& full_path) { |
33 FilePath dir = full_path.DirName(); | 33 FilePath dir = full_path.DirName(); |
34 // ParseDisplayName will fail if the directory is "C:", it must be "C:\\". | 34 // ParseDisplayName will fail if the directory is "C:", it must be "C:\\". |
35 if (dir.value() == L"" || !file_util::EnsureEndsWithSeparator(&dir)) | 35 if (dir.value() == L"" || !file_util::EnsureEndsWithSeparator(&dir)) |
36 return; | 36 return; |
37 | 37 |
(...skipping 25 matching lines...) Expand all Loading... |
63 if (!open_folder_and_select_itemsPtr) { | 63 if (!open_folder_and_select_itemsPtr) { |
64 ShellExecute(NULL, L"open", dir.value().c_str(), NULL, NULL, SW_SHOW); | 64 ShellExecute(NULL, L"open", dir.value().c_str(), NULL, NULL, SW_SHOW); |
65 return; | 65 return; |
66 } | 66 } |
67 | 67 |
68 base::win::ScopedComPtr<IShellFolder> desktop; | 68 base::win::ScopedComPtr<IShellFolder> desktop; |
69 HRESULT hr = SHGetDesktopFolder(desktop.Receive()); | 69 HRESULT hr = SHGetDesktopFolder(desktop.Receive()); |
70 if (FAILED(hr)) | 70 if (FAILED(hr)) |
71 return; | 71 return; |
72 | 72 |
73 app::win::ScopedCoMem<ITEMIDLIST> dir_item; | 73 chrome::common::ScopedCoMem<ITEMIDLIST> dir_item; |
74 hr = desktop->ParseDisplayName(NULL, NULL, | 74 hr = desktop->ParseDisplayName(NULL, NULL, |
75 const_cast<wchar_t *>(dir.value().c_str()), | 75 const_cast<wchar_t *>(dir.value().c_str()), |
76 NULL, &dir_item, NULL); | 76 NULL, &dir_item, NULL); |
77 if (FAILED(hr)) | 77 if (FAILED(hr)) |
78 return; | 78 return; |
79 | 79 |
80 app::win::ScopedCoMem<ITEMIDLIST> file_item; | 80 chrome::common::ScopedCoMem<ITEMIDLIST> file_item; |
81 hr = desktop->ParseDisplayName(NULL, NULL, | 81 hr = desktop->ParseDisplayName(NULL, NULL, |
82 const_cast<wchar_t *>(full_path.value().c_str()), | 82 const_cast<wchar_t *>(full_path.value().c_str()), |
83 NULL, &file_item, NULL); | 83 NULL, &file_item, NULL); |
84 if (FAILED(hr)) | 84 if (FAILED(hr)) |
85 return; | 85 return; |
86 | 86 |
87 const ITEMIDLIST* highlight[] = { | 87 const ITEMIDLIST* highlight[] = { |
88 {file_item}, | 88 {file_item}, |
89 }; | 89 }; |
90 | 90 |
(...skipping 16 matching lines...) Expand all Loading... |
107 << full_path.value() << "\"" | 107 << full_path.value() << "\"" |
108 << " hr = " << hr | 108 << " hr = " << hr |
109 << " " << reinterpret_cast<LPTSTR>(&message); | 109 << " " << reinterpret_cast<LPTSTR>(&message); |
110 if (message) | 110 if (message) |
111 LocalFree(message); | 111 LocalFree(message); |
112 } | 112 } |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 void OpenItem(const FilePath& full_path) { | 116 void OpenItem(const FilePath& full_path) { |
117 app::win::OpenItemViaShell(full_path); | 117 ui::win::OpenItemViaShell(full_path); |
118 } | 118 } |
119 | 119 |
120 void OpenExternal(const GURL& url) { | 120 void OpenExternal(const GURL& url) { |
121 // Quote the input scheme to be sure that the command does not have | 121 // Quote the input scheme to be sure that the command does not have |
122 // parameters unexpected by the external program. This url should already | 122 // parameters unexpected by the external program. This url should already |
123 // have been escaped. | 123 // have been escaped. |
124 std::string escaped_url = url.spec(); | 124 std::string escaped_url = url.spec(); |
125 escaped_url.insert(0, "\""); | 125 escaped_url.insert(0, "\""); |
126 escaped_url += "\""; | 126 escaped_url += "\""; |
127 | 127 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 240 |
241 bool CanSetAsDefaultBrowser() { | 241 bool CanSetAsDefaultBrowser() { |
242 return BrowserDistribution::GetDistribution()->CanSetAsDefault(); | 242 return BrowserDistribution::GetDistribution()->CanSetAsDefault(); |
243 } | 243 } |
244 | 244 |
245 bool CanSetAsDefaultProtocolClient(const std::string& protocol) { | 245 bool CanSetAsDefaultProtocolClient(const std::string& protocol) { |
246 return CanSetAsDefaultBrowser(); | 246 return CanSetAsDefaultBrowser(); |
247 } | 247 } |
248 | 248 |
249 } // namespace platform_util | 249 } // namespace platform_util |
OLD | NEW |