Index: extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h |
diff --git a/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h b/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8142da8048e55e06e0c9619facb495faafc99ae4 |
--- /dev/null |
+++ b/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h |
@@ -0,0 +1,43 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_UI_URL_FETCHER_H |
+#define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_UI_URL_FETCHER_H |
+ |
+#include "net/url_request/url_fetcher.h" |
+#include "net/url_request/url_fetcher_delegate.h" |
+ |
+namespace content { |
+class BrowserContext; |
+} |
+ |
+// WebUIURLFetcher downloads the content of a file by giving its |url| on WebUI. |
+// Each WebUIURLFetcher is associated with a given |render_process_id, |
+// render_view_id| pair. |
+class WebUIURLFetcher : public net::URLFetcherDelegate { |
+ public: |
+ // Called when a file URL request is complete. |
+ // Parameters: |
+ // - whether the request is success. |
+ // - If yes, the content of the file. |
+ using WebUILoadFileCallback = base::Callback<void(bool, const std::string&)>; |
+ |
+ WebUIURLFetcher(content::BrowserContext* context, |
+ const WebUILoadFileCallback& callback); |
+ ~WebUIURLFetcher() override; |
+ |
+ void Start(int render_process_id, int render_view_id, const GURL& url); |
+ |
+ private: |
+ // net::URLFetcherDelegate: |
+ void OnURLFetchComplete(const net::URLFetcher* source) override; |
+ |
+ content::BrowserContext* context_; |
+ WebUILoadFileCallback callback_; |
+ scoped_ptr<net::URLFetcher> fetcher_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WebUIURLFetcher); |
+}; |
+ |
+#endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_UI_URL_FETCHER_H |