Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / history_ui.h
index 6c4177a..d11dbc1 100644 (file)
@@ -7,13 +7,14 @@
 
 #include <string>
 
+#include "base/memory/weak_ptr.h"
 #include "base/strings/string16.h"
+#include "base/task/cancelable_task_tracker.h"
 #include "base/timer/timer.h"
 #include "base/values.h"
 #include "chrome/browser/common/cancelable_request.h"
 #include "chrome/browser/history/history_service.h"
 #include "chrome/browser/history/web_history_service.h"
-#include "chrome/common/cancelable_task_tracker.h"
 #include "content/public/browser/notification_registrar.h"
 #include "content/public/browser/web_ui_controller.h"
 #include "content/public/browser/web_ui_message_handler.h"
@@ -39,18 +40,18 @@ class BrowsingHistoryHandler : public content::WebUIMessageHandler,
       COMBINED_ENTRY
     };
 
-    HistoryEntry(EntryType type, const GURL& url, const string16& title,
+    HistoryEntry(EntryType type, const GURL& url, const base::string16& title,
                  base::Time time, const std::string& client_id,
-                 bool is_search_result, const string16& snippet,
+                 bool is_search_result, const base::string16& snippet,
                  bool blocked_visit, const std::string& accept_languages);
     HistoryEntry();
     virtual ~HistoryEntry();
 
     // Formats this entry's URL and title and adds them to |result|.
-    void SetUrlAndTitle(DictionaryValue* result) const;
+    void SetUrlAndTitle(base::DictionaryValue* result) const;
 
     // Converts the entry to a DictionaryValue to be owned by the caller.
-    scoped_ptr<DictionaryValue> ToValue(
+    scoped_ptr<base::DictionaryValue> ToValue(
         BookmarkModel* bookmark_model,
         ManagedUserService* managed_user_service,
         const ProfileSyncService* sync_service) const;
@@ -63,7 +64,7 @@ class BrowsingHistoryHandler : public content::WebUIMessageHandler,
     EntryType entry_type;
 
     GURL url;
-    string16 title;  // Title of the entry. May be empty.
+    base::string16 title;  // Title of the entry. May be empty.
 
     // The time of the entry. Usually this will be the time of the most recent
     // visit to |url| on a particular day as defined in the local timezone.
@@ -79,7 +80,7 @@ class BrowsingHistoryHandler : public content::WebUIMessageHandler,
     bool is_search_result;
 
     // The entry's search snippet, if this entry is a search result.
-    string16 snippet;
+    base::string16 snippet;
 
     // Whether this entry was blocked when it was attempted.
     bool blocked_visit;
@@ -129,7 +130,8 @@ class BrowsingHistoryHandler : public content::WebUIMessageHandler,
   };
 
   // Core implementation of history querying.
-  void QueryHistory(string16 search_text, const history::QueryOptions& options);
+  void QueryHistory(base::string16 search_text,
+                    const history::QueryOptions& options);
 
   // Combines the query results from the local history database and the history
   // server, and sends the combined results to the front end.
@@ -140,13 +142,13 @@ class BrowsingHistoryHandler : public content::WebUIMessageHandler,
   void WebHistoryTimeout();
 
   // Callback from the history system when a history query has completed.
-  void QueryComplete(const string16& search_text,
+  void QueryComplete(const base::string16& search_text,
                      const history::QueryOptions& options,
                      HistoryService::Handle request_handle,
                      history::QueryResults* results);
 
   // Callback from the WebHistoryService when a query has completed.
-  void WebHistoryQueryComplete(const string16& search_text,
+  void WebHistoryQueryComplete(const base::string16& search_text,
                                const history::QueryOptions& options,
                                base::TimeTicks start_time,
                                history::WebHistoryService::Request* request,
@@ -156,8 +158,7 @@ class BrowsingHistoryHandler : public content::WebUIMessageHandler,
   void RemoveComplete();
 
   // Callback from history server when visits were deleted.
-  void RemoveWebHistoryComplete(history::WebHistoryService::Request* request,
-                                bool success);
+  void RemoveWebHistoryComplete(bool success);
 
   bool ExtractIntegerValueAtIndex(
       const base::ListValue* value, int index, int* out_int);
@@ -180,12 +181,11 @@ class BrowsingHistoryHandler : public content::WebUIMessageHandler,
   // Deleting the request will cancel it.
   scoped_ptr<history::WebHistoryService::Request> web_history_request_;
 
-  // The currently-executing delete request for synced history.
-  // Deleting the request will cancel it.
-  scoped_ptr<history::WebHistoryService::Request> web_history_delete_request_;
+  // True if there is a pending delete requests to the history service.
+  bool has_pending_delete_request_;
 
   // Tracker for delete requests to the history service.
-  CancelableTaskTracker delete_task_tracker_;
+  base::CancelableTaskTracker delete_task_tracker_;
 
   // The list of URLs that are in the process of being deleted.
   std::set<GURL> urls_to_be_deleted_;
@@ -202,6 +202,8 @@ class BrowsingHistoryHandler : public content::WebUIMessageHandler,
   // Timer used to implement a timeout on a Web History response.
   base::OneShotTimer<BrowsingHistoryHandler> web_history_timer_;
 
+  base::WeakPtrFactory<BrowsingHistoryHandler> weak_factory_;
+
   DISALLOW_COPY_AND_ASSIGN(BrowsingHistoryHandler);
 };
 
@@ -209,9 +211,6 @@ class HistoryUI : public content::WebUIController {
  public:
   explicit HistoryUI(content::WebUI* web_ui);
 
-  // Return the URL for a given search term.
-  static const GURL GetHistoryURLWithSearchText(const string16& text);
-
   static base::RefCountedMemory* GetFaviconResourceBytes(
       ui::ScaleFactor scale_factor);