Adds a FaviconService class tied to the profile.

Original issue: http://codereview.chromium.org/115212/show

The favicons service is the entry point to getting favicons.

Make the DOMUIFactory handle the favicons of DOMUI pages so since DOMUI pages
are never added to the history.

BUG=5840

TEST=Open a new window and open history and downloads (Ctrl+H and Ctrl+J) in
this window. Then close the window and open the NTP. The recently closed
windows/tabs should show the favicons for the hsitroy and downloads page.

Review URL: http://codereview.chromium.org/178001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24806 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index 77d4ff1..66891d74 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -19,6 +19,7 @@
 #include "chrome/browser/extensions/extension_process_manager.h"
 #include "chrome/browser/extensions/extensions_service.h"
 #include "chrome/browser/extensions/user_script_master.h"
+#include "chrome/browser/favicon_service.h"
 #include "chrome/browser/history/history.h"
 #include "chrome/browser/in_process_webkit/webkit_context.h"
 #include "chrome/browser/net/chrome_url_request_context.h"
@@ -257,6 +258,15 @@
     }
   }
 
+  virtual FaviconService* GetFaviconService(ServiceAccessType sat) {
+    if (sat == EXPLICIT_ACCESS) {
+      return profile_->GetFaviconService(sat);
+    } else {
+      NOTREACHED() << "This profile is OffTheRecord";
+      return NULL;
+    }
+  }
+
   virtual WebDataService* GetWebDataService(ServiceAccessType sat) {
     if (sat == EXPLICIT_ACCESS) {
       return profile_->GetWebDataService(sat);
@@ -505,6 +515,7 @@
       extensions_request_context_(NULL),
       blacklist_(NULL),
       history_service_created_(false),
+      favicon_service_created_(false),
       created_web_data_service_(false),
       created_password_store_(false),
       created_download_manager_(false),
@@ -702,6 +713,10 @@
   history_service_ = NULL;
   bookmark_bar_model_.reset();
 
+  // FaviconService depends on HistoryServce so make sure we delete
+  // HistoryService first.
+  favicon_service_ = NULL;
+
   extension_message_service_->ProfileDestroyed();
 
   if (extensions_service_)
@@ -861,6 +876,15 @@
   return media_request_context_;
 }
 
+FaviconService* ProfileImpl::GetFaviconService(ServiceAccessType sat) {
+  if (!favicon_service_created_) {
+    favicon_service_created_ = true;
+    scoped_refptr<FaviconService> service(new FaviconService(this));
+    favicon_service_.swap(service);
+  }
+  return favicon_service_.get();
+}
+
 URLRequestContext* ProfileImpl::GetRequestContextForExtensions() {
   if (!extensions_request_context_) {
     FilePath cookie_path = GetPath();