Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Unified Diff: extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h

Issue 1056533002: Implement <webview>.addContentScript/removeContentScript API [2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webview_addremove_contentscripts_2
Patch Set: Revert the callback.reset() and etc. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c774cdcda67dfa6b6c81f7b7b1a242344fae3daf
--- /dev/null
+++ b/extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h
@@ -0,0 +1,49 @@
+// 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"
Devlin 2015/04/22 21:15:33 Forward declaration?
Xi Han 2015/04/22 22:34:00 We use scoped_ptr<net::URLFetcher> fetcher_, so we
Devlin 2015/04/22 23:20:50 scoped_ptr needs only a forward declaration.
Xi Han 2015/04/23 15:01:55 It seems yes, I got a wrong understanding for a lo
+#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,
+ int render_process_id,
+ int render_view_id,
+ const GURL& url,
+ const WebUILoadFileCallback& callback);
+ ~WebUIURLFetcher() override;
+
+ void Start();
+
+ private:
+ // net::URLFetcherDelegate:
+ void OnURLFetchComplete(const net::URLFetcher* source) override;
+
+ content::BrowserContext* context_;
+ int render_process_id_;
+ int render_view_id_;
+ GURL url_;
+ WebUILoadFileCallback callback_;
+ scoped_ptr<net::URLFetcher> fetcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebUIURLFetcher);
+};
+
+#endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_UI_URL_FETCHER_H

Powered by Google App Engine
This is Rietveld 408576698