Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_OFFLINE_PAGES_CONTENT_BACKGROUND_LOADER_BACKGROUND_LOADER_CON TENTS_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_CONTENT_BACKGROUND_LOADER_BACKGROUND_LOADER_CON TENTS_H_ |
| 6 #define COMPONENTS_OFFLINE_PAGES_CONTENT_BACKGROUND_LOADER_BACKGROUND_LOADER_CON TENTS_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_CONTENT_BACKGROUND_LOADER_BACKGROUND_LOADER_CON TENTS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "content/public/browser/web_contents_delegate.h" | 11 #include "content/public/browser/web_contents_delegate.h" |
| 12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 class WebContentsObserver; | |
| 16 class WebContents; | 15 class WebContents; |
| 17 } | 16 } |
| 18 | 17 |
| 19 namespace background_loader { | 18 namespace background_loader { |
| 20 | 19 |
| 21 // This class maintains a WebContents used in the background. It can host | 20 // This class maintains a WebContents used in the background. It can host |
| 22 // a renderer but does not have any visible display. | 21 // a renderer but does not have any visible display. |
| 23 class BackgroundLoaderContents : public content::WebContentsDelegate { | 22 class BackgroundLoaderContents : public content::WebContentsDelegate { |
| 24 public: | 23 public: |
| 25 // Creates BackgroundLoaderContents with specified |browser_context| and | |
| 26 // |session_storage_namespace|. This ctor should only be used if a different | |
| 27 // session storage (e.g. non-persistent/incognito) should be used. | |
| 28 // |session_storage_namespace| should not be null. | |
| 29 BackgroundLoaderContents( | |
| 30 content::BrowserContext* browser_context, | |
| 31 content::SessionStorageNamespace* session_storage_namespace); | |
| 32 | |
| 33 // Creates BackgroundLoaderContents with specified |browser_context|. Uses | 24 // Creates BackgroundLoaderContents with specified |browser_context|. Uses |
| 34 // default session storage space. | 25 // default session storage space. |
| 35 explicit BackgroundLoaderContents(content::BrowserContext* browser_context); | 26 explicit BackgroundLoaderContents(content::BrowserContext* browser_context); |
| 36 ~BackgroundLoaderContents() override; | 27 ~BackgroundLoaderContents() override; |
| 37 | 28 |
| 38 // Loads the URL in a WebContents. Will call observe on all current observers | 29 // Loads the URL in a WebContents. Will call observe on all current observers |
| 39 // with the created WebContents. | 30 // with the created WebContents. |
| 40 void LoadPage(const GURL& url); | 31 void LoadPage(const GURL& url); |
| 41 // Cancels loading of the current page. Calls Close() on internal WebContents. | 32 // Cancels loading of the current page. Calls Close() on internal WebContents. |
| 42 void Cancel(); | 33 void Cancel(); |
| 43 | 34 // Returns the inner web contents. |
| 44 void AddObserver(content::WebContentsObserver* observer); | 35 WebContents* getWebContents(); |
|
Pete Williamson
2016/11/02 20:46:43
Just curious, how come we have content::WebContent
fgorski
2016/11/02 22:07:39
Likely, it is not compiled yet.
GetWebContents()
Dmitry Titov
2016/11/03 00:07:32
This looks like a trivial accessor to the member v
chili
2016/11/03 18:57:20
It was compiled right before I added this -.- Of
| |
| 45 void RemoveObserver(content::WebContentsObserver* observer); | |
| 46 | 36 |
| 47 // content::WebContentsDelegate implementation: | 37 // content::WebContentsDelegate implementation: |
| 48 bool IsNeverVisible(content::WebContents* web_contents) override; | 38 bool IsNeverVisible(content::WebContents* web_contents) override; |
| 49 void CloseContents(content::WebContents* source) override; | 39 void CloseContents(content::WebContents* source) override; |
| 50 bool ShouldSuppressDialogs(content::WebContents* source) override; | 40 bool ShouldSuppressDialogs(content::WebContents* source) override; |
| 51 bool ShouldFocusPageAfterCrash() override; | 41 bool ShouldFocusPageAfterCrash() override; |
| 52 void CanDownload(const GURL& url, | 42 void CanDownload(const GURL& url, |
| 53 const std::string& request_method, | 43 const std::string& request_method, |
| 54 const base::Callback<void(bool)>& callback) override; | 44 const base::Callback<void(bool)>& callback) override; |
| 55 | 45 |
| 56 bool ShouldCreateWebContents( | 46 bool ShouldCreateWebContents( |
| 57 content::WebContents* contents, | 47 content::WebContents* contents, |
| 58 int32_t route_id, | 48 int32_t route_id, |
| 59 int32_t main_frame_route_id, | 49 int32_t main_frame_route_id, |
| 60 int32_t main_frame_widget_route_id, | 50 int32_t main_frame_widget_route_id, |
| 61 WindowContainerType window_container_type, | 51 WindowContainerType window_container_type, |
| 62 const std::string& frame_name, | 52 const std::string& frame_name, |
| 63 const GURL& target_url, | 53 const GURL& target_url, |
| 64 const std::string& partition_id, | 54 const std::string& partition_id, |
| 65 content::SessionStorageNamespace* session_storage_namespace) override; | 55 content::SessionStorageNamespace* session_storage_namespace) override; |
| 66 | 56 |
| 67 void AddNewContents(WebContents* source, | 57 void AddNewContents(content::WebContents* source, |
| 68 WebContents* new_contents, | 58 content::WebContents* new_contents, |
| 69 WindowOpenDisposition disposition, | 59 WindowOpenDisposition disposition, |
| 70 const gfx::Rect& initial_rect, | 60 const gfx::Rect& initial_rect, |
| 71 bool user_gesture, | 61 bool user_gesture, |
| 72 bool* was_blocked) override; | 62 bool* was_blocked) override; |
| 73 | 63 |
| 74 #if defined(OS_ANDROID) | 64 #if defined(OS_ANDROID) |
| 75 bool ShouldBlockMediaRequest(const GURL& url) override; | 65 bool ShouldBlockMediaRequest(const GURL& url) override; |
| 76 #endif | 66 #endif |
| 77 | 67 |
| 78 void RequestMediaAccessPermission( | 68 void RequestMediaAccessPermission( |
| 79 content::WebContents* contents, | 69 content::WebContents* contents, |
| 80 const content::MediaStreamRequest& request, | 70 const content::MediaStreamRequest& request, |
| 81 const content::MediaResponseCallback& callback) override; | 71 const content::MediaResponseCallback& callback) override; |
| 82 bool CheckMediaAccessPermission(content::WebContents* contents, | 72 bool CheckMediaAccessPermission(content::WebContents* contents, |
| 83 const GURL& security_origin, | 73 const GURL& security_origin, |
| 84 content::MediaStreamType type) override; | 74 content::MediaStreamType type) override; |
| 85 | 75 |
| 86 private: | 76 private: |
| 87 std::unique_ptr<content::WebContents> web_contents_; | 77 std::unique_ptr<content::WebContents> web_contents_; |
| 88 content::SessionStorageNamespaceMap session_storage_namespace_map_; | |
| 89 content::BrowserContext* browser_context_; | 78 content::BrowserContext* browser_context_; |
| 90 base::ObserverList<WebContentsObserver> observers_; | |
| 91 | 79 |
| 92 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderContents); | 80 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderContents); |
| 93 }; | 81 }; |
| 94 | 82 |
| 95 } // namespace background_loader | 83 } // namespace background_loader |
| 96 #endif // COMPONENTS_OFFLINE_PAGES_CONTENT_BACKGROUND_LOADER_BACKGROUND_LOADER_ CONTENTS_H_ | 84 #endif // COMPONENTS_OFFLINE_PAGES_CONTENT_BACKGROUND_LOADER_BACKGROUND_LOADER_ CONTENTS_H_ |
| OLD | NEW |