OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 // The order of these includes is important. | 5 // The order of these includes is important. |
6 #include <windows.h> | 6 #include <windows.h> |
7 #include <unknwn.h> | 7 #include <unknwn.h> |
8 #include <intshcut.h> | 8 #include <intshcut.h> |
| 9 #include <objbase.h> |
9 #include <propvarutil.h> | 10 #include <propvarutil.h> |
10 #include <shlguid.h> | 11 #include <shlguid.h> |
11 #include <shlobj.h> | 12 #include <shlobj.h> |
12 #include <stddef.h> | 13 #include <stddef.h> |
13 #include <stdint.h> | 14 #include <stdint.h> |
14 #include <urlhist.h> | 15 #include <urlhist.h> |
15 | 16 |
16 #include <algorithm> | 17 #include <algorithm> |
17 #include <vector> | 18 #include <vector> |
18 | 19 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 ERROR_SUCCESS) { | 164 ERROR_SUCCESS) { |
164 return false; | 165 return false; |
165 } | 166 } |
166 return true; | 167 return true; |
167 } | 168 } |
168 | 169 |
169 bool CreateUrlFileWithFavicon(const base::FilePath& file, | 170 bool CreateUrlFileWithFavicon(const base::FilePath& file, |
170 const base::string16& url, | 171 const base::string16& url, |
171 const base::string16& favicon_url) { | 172 const base::string16& favicon_url) { |
172 base::win::ScopedComPtr<IUniformResourceLocator> locator; | 173 base::win::ScopedComPtr<IUniformResourceLocator> locator; |
173 HRESULT result = locator.CreateInstance(CLSID_InternetShortcut, NULL, | 174 HRESULT result = |
174 CLSCTX_INPROC_SERVER); | 175 ::CoCreateInstance(CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER, |
| 176 IID_PPV_ARGS(&locator)); |
175 if (FAILED(result)) | 177 if (FAILED(result)) |
176 return false; | 178 return false; |
177 base::win::ScopedComPtr<IPersistFile> persist_file; | 179 base::win::ScopedComPtr<IPersistFile> persist_file; |
178 result = locator.CopyTo(persist_file.GetAddressOf()); | 180 result = locator.CopyTo(persist_file.GetAddressOf()); |
179 if (FAILED(result)) | 181 if (FAILED(result)) |
180 return false; | 182 return false; |
181 result = locator->SetURL(url.c_str(), 0); | 183 result = locator->SetURL(url.c_str(), 0); |
182 if (FAILED(result)) | 184 if (FAILED(result)) |
183 return false; | 185 return false; |
184 | 186 |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 L"a", | 483 L"a", |
482 L"SubFolder.url", | 484 L"SubFolder.url", |
483 }; | 485 }; |
484 ASSERT_TRUE(CreateOrderBlob( | 486 ASSERT_TRUE(CreateOrderBlob( |
485 base::FilePath(path), L"", | 487 base::FilePath(path), L"", |
486 std::vector<base::string16>(root_links, | 488 std::vector<base::string16>(root_links, |
487 root_links + arraysize(root_links)))); | 489 root_links + arraysize(root_links)))); |
488 | 490 |
489 // Sets up a special history link. | 491 // Sets up a special history link. |
490 base::win::ScopedComPtr<IUrlHistoryStg2> url_history_stg2; | 492 base::win::ScopedComPtr<IUrlHistoryStg2> url_history_stg2; |
491 ASSERT_EQ(S_OK, url_history_stg2.CreateInstance(CLSID_CUrlHistory, NULL, | 493 ASSERT_EQ(S_OK, |
492 CLSCTX_INPROC_SERVER)); | 494 ::CoCreateInstance(CLSID_CUrlHistory, NULL, CLSCTX_INPROC_SERVER, |
| 495 IID_PPV_ARGS(&url_history_stg2))); |
493 // Usage of ADDURL_ADDTOHISTORYANDCACHE and ADDURL_ADDTOCACHE flags | 496 // Usage of ADDURL_ADDTOHISTORYANDCACHE and ADDURL_ADDTOCACHE flags |
494 // is explained in the article: | 497 // is explained in the article: |
495 // http://msdn.microsoft.com/ru-ru/aa767730 | 498 // http://msdn.microsoft.com/ru-ru/aa767730 |
496 ASSERT_EQ(S_OK, url_history_stg2->AddUrl(kIEIdentifyUrl, kIEIdentifyTitle, | 499 ASSERT_EQ(S_OK, url_history_stg2->AddUrl(kIEIdentifyUrl, kIEIdentifyTitle, |
497 ADDURL_ADDTOHISTORYANDCACHE)); | 500 ADDURL_ADDTOHISTORYANDCACHE)); |
498 ASSERT_EQ(S_OK, url_history_stg2->AddUrl(kIECacheItemUrl, kIECacheItemTitle, | 501 ASSERT_EQ(S_OK, url_history_stg2->AddUrl(kIECacheItemUrl, kIECacheItemTitle, |
499 ADDURL_ADDTOCACHE)); | 502 ADDURL_ADDTOCACHE)); |
500 | 503 |
501 // Starts to import the above settings. | 504 // Starts to import the above settings. |
502 // Deletes itself. | 505 // Deletes itself. |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 source_profile.source_path = temp_dir_.GetPath(); | 645 source_profile.source_path = temp_dir_.GetPath(); |
643 | 646 |
644 host->StartImportSettings( | 647 host->StartImportSettings( |
645 source_profile, | 648 source_profile, |
646 browser()->profile(), | 649 browser()->profile(), |
647 importer::HOME_PAGE, | 650 importer::HOME_PAGE, |
648 observer); | 651 observer); |
649 base::RunLoop().Run(); | 652 base::RunLoop().Run(); |
650 } | 653 } |
651 | 654 |
OLD | NEW |