Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 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_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "content/public/browser/web_contents.h" | |
|
fgorski
2016/10/25 12:15:36
This file has a lot of dependencies included only
chili
2016/10/25 18:48:00
Removed a few where we only need the definition.
| |
| 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 { | |
|
Dmitry Titov
2016/10/25 00:31:09
As a global namespace, this may easily overlap wit
fgorski
2016/10/25 12:15:36
Is there a reason to put it in a different namespa
chili
2016/10/25 18:48:00
It's in a different namespace mainly because at on
| |
| 17 | |
| 18 // This class maintains a WebContents used in the background. It can host | |
| 19 // a renderer but does not have any visible display. | |
| 20 class BackgroundLoaderContents : public content::WebContentsDelegate { | |
| 21 public: | |
| 22 // Creates BackgroundLoaderContents with specified |browser_context| and | |
| 23 // |session_storage_namespace|. This ctor should only be used if a different | |
| 24 // session storage should be used. | |
|
fgorski
2016/10/25 12:15:36
Could you add an example of such case?
What if nul
chili
2016/10/25 18:48:00
Not sure what you mean by example. session storag
| |
| 25 BackgroundLoaderContents( | |
| 26 content::BrowserContext* browser_context, | |
| 27 content::SessionStorageNamespace* session_storage_namespace); | |
| 28 | |
| 29 // Creates BackgroundLoaderContents with specified |browser_context|. Uses | |
| 30 // default session storage space. | |
| 31 BackgroundLoaderContents(content::BrowserContext* browser_context); | |
|
Dmitry Titov
2016/10/25 00:31:09
should be 'explicit' contructor: https://google.gi
fgorski
2016/10/25 12:15:36
Rule applies to all constructors with a single par
chili
2016/10/25 18:48:00
Done.
| |
| 32 ~BackgroundLoaderContents() override; | |
| 33 | |
| 34 // Loads the URL in a WebContents. Will call observers to observe | |
|
Dmitry Titov
2016/10/25 00:31:09
Is there incomplete sentence?
chili
2016/10/25 18:48:00
not really, but expanded the sentence to be more c
| |
| 35 void LoadPage(const GURL& url); | |
| 36 // Cancels loading on the current page. Calls Close() on internal WebContents. | |
|
Dmitry Titov
2016/10/25 00:31:09
"loading on" -> "loading of"?
chili
2016/10/25 18:48:00
Done.
| |
| 37 void Cancel(); | |
| 38 | |
| 39 void AddObserver(content::WebContentsObserver* observer); | |
| 40 void RemoveObserver(content::WebContentsObserver* observer); | |
| 41 | |
| 42 // content::WebContentsDelegate Implementation: | |
|
fgorski
2016/10/25 12:15:36
s/I/i/
chili
2016/10/25 18:48:00
Done.
| |
| 43 bool IsNeverVisible(content::WebContents* web_contents) override; | |
| 44 void CloseContents(content::WebContents* source) override; | |
| 45 bool ShouldSuppressDialogs(content::WebContents* source) override; | |
| 46 bool ShouldFocusPageAfterCrash() override; | |
| 47 void CanDownload(const GURL& url, | |
| 48 const std::string& request_method, | |
| 49 const base::Callback<void(bool)>& callback) override; | |
| 50 | |
| 51 bool ShouldCreateWebContents( | |
| 52 content::WebContents* contents, | |
| 53 int32_t route_id, | |
| 54 int32_t main_frame_route_id, | |
| 55 int32_t main_frame_widget_route_id, | |
| 56 WindowContainerType window_container_type, | |
| 57 const std::string& frame_name, | |
| 58 const GURL& target_url, | |
| 59 const std::string& partition_id, | |
| 60 content::SessionStorageNamespace* session_storage_namespace) override; | |
| 61 | |
| 62 void AddNewContents(WebContents* source, | |
| 63 WebContents* new_contents, | |
| 64 WindowOpenDisposition disposition, | |
| 65 const gfx::Rect& initial_rect, | |
| 66 bool user_gesture, | |
| 67 bool* was_blocked) override; | |
| 68 | |
| 69 #if defined(OS_ANDROID) | |
| 70 bool ShouldBlockMediaRequest(const GURL& url) override; | |
| 71 #endif | |
| 72 | |
| 73 void RequestMediaAccessPermission( | |
| 74 content::WebContents* contents, | |
| 75 const content::MediaStreamRequest& request, | |
| 76 const content::MediaResponseCallback& callback) override; | |
| 77 bool CheckMediaAccessPermission(content::WebContents* contents, | |
| 78 const GURL& security_origin, | |
| 79 content::MediaStreamType type) override; | |
| 80 | |
| 81 private: | |
| 82 std::unique_ptr<content::WebContents> web_contents_; | |
| 83 content::SessionStorageNamespaceMap session_storage_namespace_map_; | |
| 84 content::BrowserContext* browser_context_; | |
| 85 std::vector<WebContentsObserver*> observers_; | |
|
fgorski
2016/10/25 12:15:36
Is there a reason why this cannot be a base::Obser
chili
2016/10/25 18:48:00
did not know it existed :)
| |
| 86 | |
| 87 DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderContents); | |
| 88 }; | |
| 89 | |
| 90 } // namespace background | |
| 91 #endif // COMPONENTS_OFFLINE_PAGES_CONTENT_BACKGROUND_LOADER_BACKGROUND_LOADER_ CONTENTS_H_ | |
| OLD | NEW |