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

Side by Side Diff: chrome/browser/importer/ie_importer.cc

Issue 31008: Coalesce more hardcoded schemes to using predefined constants. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | « chrome/browser/importer/firefox2_importer.cc ('k') | chrome/browser/net/url_fixer_upper.cc » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/importer/ie_importer.h" 5 #include "chrome/browser/importer/ie_importer.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 #include <intshcut.h> 8 #include <intshcut.h>
9 #include <pstore.h> 9 #include <pstore.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
11 #include <urlhist.h> 11 #include <urlhist.h>
12 12
13 #include <algorithm> 13 #include <algorithm>
14 14
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/registry.h" 16 #include "base/registry.h"
17 #include "base/string_util.h" 17 #include "base/string_util.h"
18 #include "base/time.h" 18 #include "base/time.h"
19 #include "base/win_util.h" 19 #include "base/win_util.h"
20 #include "chrome/browser/bookmarks/bookmark_model.h" 20 #include "chrome/browser/bookmarks/bookmark_model.h"
21 #include "chrome/browser/password_manager/ie7_password.h" 21 #include "chrome/browser/password_manager/ie7_password.h"
22 #include "chrome/browser/search_engines/template_url_model.h" 22 #include "chrome/browser/search_engines/template_url_model.h"
23 #include "chrome/common/l10n_util.h" 23 #include "chrome/common/l10n_util.h"
24 #include "chrome/common/time_format.h" 24 #include "chrome/common/time_format.h"
25 #include "chrome/common/url_constants.h"
25 #include "chrome/common/win_util.h" 26 #include "chrome/common/win_util.h"
26 #include "googleurl/src/gurl.h" 27 #include "googleurl/src/gurl.h"
27 #include "grit/generated_resources.h" 28 #include "grit/generated_resources.h"
28 29
29 using base::Time; 30 using base::Time;
30 31
31 namespace { 32 namespace {
32 33
33 // Gets the creation time of the given file or directory. 34 // Gets the creation time of the given file or directory.
34 static Time GetFileCreationTime(const std::wstring& file) { 35 static Time GetFileCreationTime(const std::wstring& file) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 item.Release(); 188 item.Release();
188 pstore.Release(); 189 pstore.Release();
189 FreeLibrary(pstorec_dll); 190 FreeLibrary(pstorec_dll);
190 191
191 size_t i; 192 size_t i;
192 for (i = 0; i < ac_list.size(); i++) { 193 for (i = 0; i < ac_list.size(); i++) {
193 if (!ac_list[i].is_url || ac_list[i].data.size() < 2) 194 if (!ac_list[i].is_url || ac_list[i].data.size() < 2)
194 continue; 195 continue;
195 196
196 GURL url(ac_list[i].key.c_str()); 197 GURL url(ac_list[i].key.c_str());
197 if (!(LowerCaseEqualsASCII(url.scheme(), "http") || 198 if (!(LowerCaseEqualsASCII(url.scheme(), chrome::kHttpScheme) ||
198 LowerCaseEqualsASCII(url.scheme(), "https"))) { 199 LowerCaseEqualsASCII(url.scheme(), chrome::kHttpsScheme))) {
199 continue; 200 continue;
200 } 201 }
201 202
202 PasswordForm form; 203 PasswordForm form;
203 GURL::Replacements rp; 204 GURL::Replacements rp;
204 rp.ClearUsername(); 205 rp.ClearUsername();
205 rp.ClearPassword(); 206 rp.ClearPassword();
206 rp.ClearQuery(); 207 rp.ClearQuery();
207 rp.ClearRef(); 208 rp.ClearRef();
208 form.origin = url.ReplaceComponents(rp); 209 form.origin = url.ReplaceComponents(rp);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 password_info)); 266 password_info));
266 } 267 }
267 } 268 }
268 269
269 ++reg_iterator; 270 ++reg_iterator;
270 } 271 }
271 } 272 }
272 273
273 // Reads history information from COM interface. 274 // Reads history information from COM interface.
274 void IEImporter::ImportHistory() { 275 void IEImporter::ImportHistory() {
275 const std::string kSchemes[] = {"http", "https", "ftp", "file"}; 276 const std::string kSchemes[] = {chrome::kHttpScheme,
277 chrome::kHttpsScheme,
278 chrome::kFtpScheme,
279 chrome::kFileScheme};
276 int total_schemes = arraysize(kSchemes); 280 int total_schemes = arraysize(kSchemes);
277 281
278 CComPtr<IUrlHistoryStg2> url_history_stg2; 282 CComPtr<IUrlHistoryStg2> url_history_stg2;
279 HRESULT result; 283 HRESULT result;
280 result = url_history_stg2.CoCreateInstance(CLSID_CUrlHistory, NULL, 284 result = url_history_stg2.CoCreateInstance(CLSID_CUrlHistory, NULL,
281 CLSCTX_INPROC_SERVER); 285 CLSCTX_INPROC_SERVER);
282 if (FAILED(result)) 286 if (FAILED(result))
283 return; 287 return;
284 CComPtr<IEnumSTATURL> enum_url; 288 CComPtr<IEnumSTATURL> enum_url;
285 if (SUCCEEDED(result = url_history_stg2->EnumUrls(&enum_url))) { 289 if (SUCCEEDED(result = url_history_stg2->EnumUrls(&enum_url))) {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 if (version < 0) { 559 if (version < 0) {
556 wchar_t buffer[128]; 560 wchar_t buffer[128];
557 DWORD buffer_length = sizeof(buffer); 561 DWORD buffer_length = sizeof(buffer);
558 bool result = ReadFromRegistry(HKEY_LOCAL_MACHINE, 562 bool result = ReadFromRegistry(HKEY_LOCAL_MACHINE,
559 L"Software\\Microsoft\\Internet Explorer", 563 L"Software\\Microsoft\\Internet Explorer",
560 L"Version", buffer, &buffer_length); 564 L"Version", buffer, &buffer_length);
561 version = (result ? _wtoi(buffer) : 0); 565 version = (result ? _wtoi(buffer) : 0);
562 } 566 }
563 return version; 567 return version;
564 } 568 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/firefox2_importer.cc ('k') | chrome/browser/net/url_fixer_upper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698