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

Unified Diff: components/background_loader/background_loader_contents.h

Issue 2393353002: [Background loader] .h file draft outline of background loader (Closed)
Patch Set: Created 4 years, 2 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
« components/background_loader/DEPS ('K') | « components/background_loader/DEPS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/background_loader/background_loader_contents.h
diff --git a/components/background_loader/background_loader_contents.h b/components/background_loader/background_loader_contents.h
new file mode 100644
index 0000000000000000000000000000000000000000..02aaaa63575d1625448a420b0724003c5dd3c5b3
--- /dev/null
+++ b/components/background_loader/background_loader_contents.h
@@ -0,0 +1,81 @@
+// Copyright (c) 2016 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 COMPONENTS_BACKGROUND_LOADER_BACKGROUND_LOADER_CONTENTS_H_
+#define COMPONENTS_BACKGROUND_LOADER_BACKGROUND_LOADER_CONTENTS_H_
+
+#include <string>
+
+#include "base/callback.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_delegate.h"
+#include "content/public/browser/web_contents_observer.h"
+#include "url/gurl.h"
+
+namespace background {
+
+typedef base::Callback<void(content::WebContents*)> WebContentsCallback;
Dmitry Titov 2016/10/06 04:36:02 I wonder why you need to give the WebContents out
chili 2016/10/12 20:57:30 I was playing around with different ways to offer
+
+// This class maintains a WebContents used in the background. It can host
+// a renderer but does not have any visible display.
+class BackgroundLoaderContents : public content::WebContentsDelegate,
+ public content::WebContentsObserver {
+ public:
+ BackgroundLoaderContents(
+ content::BrowserContext* browser_context,
+ content::SessionStorageNamespace* session_storage_namespace);
+ BackgroundLoaderContents(content::BrowserContext* browser_context);
+ ~BackgroundLoaderContents() override;
+
+ content::WebContents* web_contents() const { return web_contents_.get(); }
+ void LoadPage(const GURL& url, const WebContentsCallback& callback);
Dmitry Titov 2016/10/06 04:36:02 How do you plan to communicate the progress of th
chili 2016/10/12 20:57:30 Added an observer class for this. I originally fo
+ void StopLoading();
+
+ // content::WebContentsDelegate Implementation:
+ void CloseContents(content::WebContents* source) override;
+ bool ShouldSuppressDialogs(content::WebContents* source) override;
+ bool IsNeverVisible(content::WebContents* web_contents) override;
+ bool ShouldFocusLocationBarByDefault(content::WebContents* source) override;
+ bool ShouldFocusPageAfterCrash() override;
+ void CanDownload(const GURL& url,
+ const std::string& request_method,
+ const base::Callback<void(bool)>& callback) override;
+ bool ShouldCreateWebContents(
+ content::WebContents* contents,
+ int32_t route_id,
+ int32_t main_frame_route_id,
+ int32_t main_frame_widget_route_id,
+ WindowContainerType window_container_type,
+ const std::string& frame_name,
+ const GURL& target_url,
+ const std::string& partition_id,
+ content::SessionStorageNamespace* session_storage_namespace) override;
+ void RequestMediaAccessPermission(
+ content::WebContents* contents,
+ const content::MediaStreamRequest& request,
+ const content::MediaResponseCallback& callback) override;
+ bool CheckMediaAccessPermission(content::WebContents* contents,
+ const GURL& security_origin,
+ content::MediaStreamType type) override;
+
+ // content::WebContentsObserver Implementation:
+ void RenderProcessGone(base::TerminationStatus status) override;
+ void DidStartLoading() override;
+ void DidStopLoading() override;
+
+ protected:
+ BackgroundLoaderContents();
+
+ private:
+ Profile* profile_;
+ std::unique_ptr<content::WebContents> web_contents_;
+ content::SessionStorageNamespaceMap session_storage_namespace_map_;
+ content::BrowserContext* browser_context_;
Dmitry Titov 2016/10/06 04:36:02 BrowserContext and Profiel are practically the sam
chili 2016/10/12 20:57:30 removed.
+ WebContentsCallback callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderContents);
+};
+
+} // namespace background
+#endif // COMPONENTS_BACKGROUND_LOADER_BACKGROUND_LOADER_CONTENTS_H_
« components/background_loader/DEPS ('K') | « components/background_loader/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698