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_HISTORY_HISTORY_PUBLISHER_H_ 6 #define CHROME_BROWSER_HISTORY_HISTORY_PUBLISHER_H_ 7 #pragma once 8 9 #include <vector> 10 11 #include "base/basictypes.h" 12 #include "base/string16.h" 13 14 #if defined(OS_WIN) 15 #include "base/win/scoped_comptr.h" 16 #include "history_indexer.h" 17 #endif 18 19 class GURL; 20 21 namespace base { 22 class Time; 23 } 24 25 namespace history { 26 27 class HistoryPublisher { 28 public: 29 HistoryPublisher(); 30 ~HistoryPublisher(); 31 32 // Must call this function to complete initialization. Returns true if we 33 // need to publish data to any indexers registered with us. Returns false if 34 // there are none registered. On false, no other function should be called. 35 bool Init(); 36 37 void PublishPageThumbnail(const std::vector<unsigned char>& thumbnail, 38 const GURL& url, const base::Time& time) const; 39 void PublishPageContent(const base::Time& time, const GURL& url, 40 const string16& title, 41 const string16& contents) const; 42 void DeleteUserHistoryBetween(const base::Time& begin_time, 43 const base::Time& end_time) const; 44 45 private: 46 struct PageData { 47 const base::Time& time; 48 const GURL& url; 49 const char16* html; 50 const char16* title; 51 const char* thumbnail_format; 52 const std::vector<unsigned char>* thumbnail; 53 }; 54 55 void PublishDataToIndexers(const PageData& page_data) const; 56 57 #if defined(OS_WIN) 58 // Initializes the indexer_list_ with the list of indexers that registered 59 // with us to index history. Returns true if there are any registered. 60 bool ReadRegisteredIndexersFromRegistry(); 61 62 // Converts time represented by the Time class object to variant time in UTC. 63 // Returns '0' if the time object is NULL. 64 static double TimeToUTCVariantTime(const base::Time& time); 65 66 typedef std::vector< base::win::ScopedComPtr< 67 IChromeHistoryIndexer> > IndexerList; 68 69 // The list of indexers registered to receive history data from us. 70 IndexerList indexers_; 71 72 // The Registry key under HKCU where the indexers need to register their 73 // CLSID. 74 static const wchar_t* const kRegKeyRegisteredIndexersInfo; 75 #endif 76 77 // The format of the thumbnail we pass to indexers. 78 static const char* const kThumbnailImageFormat; 79 80 DISALLOW_COPY_AND_ASSIGN(HistoryPublisher); 81 }; 82 83 } // namespace history 84 85 #endif // CHROME_BROWSER_HISTORY_HISTORY_PUBLISHER_H_ 86