Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_BACKGROUND_LOADER_BACKGROUND_LOADER_CONTENTS_H_ | |
| 6 #define COMPONENTS_BACKGROUND_LOADER_BACKGROUND_LOADER_CONTENTS_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "content/public/browser/web_contents.h" | |
| 12 #include "content/public/browser/web_contents_delegate.h" | |
| 13 #include "content/public/browser/web_contents_observer.h" | |
| 14 #include "url/gurl.h" | |
| 15 | |
| 16 namespace background { | |
| 17 | |
| 18 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
| |
| 19 | |
| 20 // This class maintains a WebContents used in the background. It can host | |
| 21 // a renderer but does not have any visible display. | |
| 22 class BackgroundLoaderContents : public content::WebContentsDelegate, | |
| 23 public content::WebContentsObserver { | |
| 24 public: | |
| 25 BackgroundLoaderContents( | |
| 26 content::BrowserContext* browser_context, | |
| 27 content::SessionStorageNamespace* session_storage_namespace); | |
| 28 BackgroundLoaderContents(content::BrowserContext* browser_context); | |
| 29 ~BackgroundLoaderContents() override; | |
| 30 | |
| 31 content::WebContents* web_contents() const { return web_contents_.get(); } | |
| 32 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
| |
| 33 void StopLoading(); | |
| 34 | |
| 35 // content::WebContentsDelegate Implementation: | |
| 36 void CloseContents(content::WebContents* source) override; | |
| 37 bool ShouldSuppressDialogs(content::WebContents* source) override; | |
| 38 bool IsNeverVisible(content::WebContents* web_contents) override; | |
| 39 bool ShouldFocusLocationBarByDefault(content::WebContents* source) override; | |
| 40 bool ShouldFocusPageAfterCrash() override; | |
| 41 void CanDownload(const GURL& url, | |
| 42 const std::string& request_method, | |
| 43 const base::Callback<void(bool)>& callback) override; | |
| 44 bool ShouldCreateWebContents( | |
| 45 content::WebContents* contents, | |
| 46 int32_t route_id, | |
| 47 int32_t main_frame_route_id, | |
| 48 int32_t main_frame_widget_route_id, | |
| 49 WindowContainerType window_container_type, | |
| 50 const std::string& frame_name, | |
| 51 const GURL& target_url, | |
| 52 const std::string& partition_id, | |
| 53 content::SessionStorageNamespace* session_storage_namespace) override; | |
| 54 void RequestMediaAccessPermission( | |
| 55 content::WebContents* contents, | |
| 56 const content::MediaStreamRequest& request, | |
| 57 const content::MediaResponseCallback& callback) override; | |
| 58 bool CheckMediaAccessPermission(content::WebContents* contents, | |
| 59 const GURL& security_origin, | |
| 60 content::MediaStreamType type) override; | |
| 61 | |
| 62 // content::WebContentsObserver Implementation: | |
| 63 void RenderProcessGone(base::TerminationStatus status) override; | |
| 64 void DidStartLoading() override; | |
| 65 void DidStopLoading() override; | |
| 66 | |
| 67 protected: | |
| 68 BackgroundLoaderContents(); | |
| 69 | |
| 70 private: | |
| 71 Profile* profile_; | |
| 72 std::unique_ptr<content::WebContents> web_contents_; | |
| 73 content::SessionStorageNamespaceMap session_storage_namespace_map_; | |
| 74 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.
| |
| 75 WebContentsCallback callback_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderContents); | |
| 78 }; | |
| 79 | |
| 80 } // namespace background | |
| 81 #endif // COMPONENTS_BACKGROUND_LOADER_BACKGROUND_LOADER_CONTENTS_H_ | |
| OLD | NEW |