Index: chrome/browser/search_engines/template_url_fetcher.cc |
=================================================================== |
--- chrome/browser/search_engines/template_url_fetcher.cc (revision 9942) |
+++ chrome/browser/search_engines/template_url_fetcher.cc (working copy) |
@@ -4,6 +4,7 @@ |
#include "chrome/browser/search_engines/template_url_fetcher.h" |
+#include "chrome/browser/net/url_fetcher.h" |
#include "chrome/browser/profile.h" |
#include "chrome/browser/search_engines/template_url.h" |
#include "chrome/browser/search_engines/template_url_model.h" |
@@ -11,7 +12,57 @@ |
#include "chrome/browser/views/edit_keyword_controller.h" |
// RequestDelegate ------------------------------------------------------------ |
+class TemplateURLFetcher::RequestDelegate : public URLFetcher::Delegate { |
+ public: |
+ RequestDelegate(TemplateURLFetcher* fetcher, |
+ const std::wstring& keyword, |
+ const GURL& osdd_url, |
+ const GURL& favicon_url, |
+ gfx::NativeView parent_window, |
+ bool autodetected) |
+#pragma warning(disable:4355) |
+ : url_fetcher_(osdd_url, URLFetcher::GET, this), |
+ fetcher_(fetcher), |
+ keyword_(keyword), |
+ osdd_url_(osdd_url), |
+ favicon_url_(favicon_url), |
+ parent_window_(parent_window), |
+ autodetected_(autodetected) { |
+ url_fetcher_.set_request_context(fetcher->profile()->GetRequestContext()); |
+ url_fetcher_.Start(); |
+ } |
+ // If data contains a valid OSDD, a TemplateURL is created and added to |
+ // the TemplateURLModel. |
+ virtual void OnURLFetchComplete(const URLFetcher* source, |
+ const GURL& url, |
+ const URLRequestStatus& status, |
+ int response_code, |
+ const ResponseCookies& cookies, |
+ const std::string& data); |
+ |
+ // URL of the OSDD. |
+ const GURL& url() const { return osdd_url_; } |
+ |
+ // Keyword to use. |
+ const std::wstring keyword() const { return keyword_; } |
+ |
+ private: |
+ URLFetcher url_fetcher_; |
+ TemplateURLFetcher* fetcher_; |
+ const std::wstring keyword_; |
+ const GURL osdd_url_; |
+ const GURL favicon_url_; |
+ bool autodetected_; |
+ |
+ // Used to determine where to place a confirmation dialog. May be NULL, |
+ // in which case the confirmation will be centered in the screen if needed. |
+ gfx::NativeView parent_window_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(RequestDelegate); |
+}; |
+ |
+ |
void TemplateURLFetcher::RequestDelegate::OnURLFetchComplete( |
const URLFetcher* source, |
const GURL& url, |
@@ -89,6 +140,9 @@ |
DCHECK(profile_); |
} |
+TemplateURLFetcher::~TemplateURLFetcher() { |
+} |
+ |
void TemplateURLFetcher::ScheduleDownload(const std::wstring& keyword, |
const GURL& osdd_url, |
const GURL& favicon_url, |