Home | History | Annotate | Download | only in importer
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_IMPORTER_IE_IMPORTER_H_
      6 #define CHROME_BROWSER_IMPORTER_IE_IMPORTER_H_
      7 #pragma once
      8 
      9 #include <string>
     10 #include <vector>
     11 
     12 #include "base/basictypes.h"
     13 #include "base/compiler_specific.h"
     14 #include "base/gtest_prod_util.h"
     15 #include "base/file_path.h"
     16 #include "chrome/browser/importer/importer.h"
     17 #include "chrome/browser/importer/profile_writer.h"
     18 
     19 class IEImporter : public Importer {
     20  public:
     21   IEImporter();
     22 
     23   // Importer:
     24   virtual void StartImport(const importer::SourceProfile& source_profile,
     25                            uint16 items,
     26                            ImporterBridge* bridge) OVERRIDE;
     27 
     28  private:
     29   typedef std::vector<ProfileWriter::BookmarkEntry> BookmarkVector;
     30 
     31   // A struct that hosts the information of IE Favorite folder.
     32   struct FavoritesInfo {
     33     FilePath path;
     34     std::wstring links_folder;
     35   };
     36 
     37   // IE PStore subkey GUID: AutoComplete password & form data.
     38   static const GUID kPStoreAutocompleteGUID;
     39 
     40   // A fake GUID for unit test.
     41   static const GUID kUnittestGUID;
     42 
     43   FRIEND_TEST_ALL_PREFIXES(ImporterTest, IEImporter);
     44 
     45   virtual ~IEImporter();
     46 
     47   void ImportFavorites();
     48 
     49   // Reads history information from COM interface.
     50   void ImportHistory();
     51 
     52   // Import password for IE6 stored in protected storage.
     53   void ImportPasswordsIE6();
     54 
     55   // Import password for IE7 and IE8 stored in Storage2.
     56   void ImportPasswordsIE7();
     57 
     58   void ImportSearchEngines();
     59 
     60   // Import the homepage setting of IE. Note: IE supports multiple home pages,
     61   // whereas Chrome doesn't, so we import only the one defined under the
     62   // 'Start Page' registry key. We don't import if the homepage is set to the
     63   // machine default.
     64   void ImportHomepage();
     65 
     66   // Resolves what's the .url file actually targets.
     67   // Returns empty string if failed.
     68   std::wstring ResolveInternetShortcut(const std::wstring& file);
     69 
     70   // Gets the information of Favorites folder. Returns true if successful.
     71   bool GetFavoritesInfo(FavoritesInfo* info);
     72 
     73   // This function will read the files in the Favorite folder, and store
     74   // the bookmark items in |bookmarks|.
     75   void ParseFavoritesFolder(const FavoritesInfo& info,
     76                             BookmarkVector* bookmarks);
     77 
     78   // Determines which version of IE is in use.
     79   int CurrentIEVersion() const;
     80 
     81   // IE does not have source path. It's used in unit tests only for providing a
     82   // fake source.
     83   FilePath source_path_;
     84 
     85   DISALLOW_COPY_AND_ASSIGN(IEImporter);
     86 };
     87 
     88 #endif  // CHROME_BROWSER_IMPORTER_IE_IMPORTER_H_
     89