history_publisher.h revision 3345a6884c488ff3a535c2c9acdd33d74b37e311
1// Copyright (c) 2010 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/scoped_comptr_win.h" 16#include "history_indexer.h" 17#endif 18 19class GURL; 20 21namespace base { 22class Time; 23} 24 25namespace history { 26 27class 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 wchar_t* html; 50 const wchar_t* 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< ScopedComPtr<IChromeHistoryIndexer> > IndexerList; 67 68 // The list of indexers registered to receive history data from us. 69 IndexerList indexers_; 70 71 // The Registry key under HKCU where the indexers need to register their 72 // CLSID. 73 static const wchar_t* const kRegKeyRegisteredIndexersInfo; 74#endif 75 76 // The format of the thumbnail we pass to indexers. 77 static const char* const kThumbnailImageFormat; 78 79 DISALLOW_COPY_AND_ASSIGN(HistoryPublisher); 80}; 81 82} // namespace history 83 84#endif // CHROME_BROWSER_HISTORY_HISTORY_PUBLISHER_H_ 85