Chromium Code Reviews| Index: components/offline_pages/content/background_loader/background_loader_contents.h |
| diff --git a/components/offline_pages/content/background_loader/background_loader_contents.h b/components/offline_pages/content/background_loader/background_loader_contents.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8f2aeb11c086ff43c27947b3052bee3b9d2d43fb |
| --- /dev/null |
| +++ b/components/offline_pages/content/background_loader/background_loader_contents.h |
| @@ -0,0 +1,91 @@ |
| +// Copyright 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_OFFLINE_PAGES_CONTENT_BACKGROUND_LOADER_BACKGROUND_LOADER_CONTENTS_H_ |
| +#define COMPONENTS_OFFLINE_PAGES_CONTENT_BACKGROUND_LOADER_BACKGROUND_LOADER_CONTENTS_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/callback.h" |
| +#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.
|
| +#include "content/public/browser/web_contents_delegate.h" |
| +#include "content/public/browser/web_contents_observer.h" |
| +#include "url/gurl.h" |
| + |
| +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
|
| + |
| +// 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: |
| + // Creates BackgroundLoaderContents with specified |browser_context| and |
| + // |session_storage_namespace|. This ctor should only be used if a different |
| + // 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
|
| + BackgroundLoaderContents( |
| + content::BrowserContext* browser_context, |
| + content::SessionStorageNamespace* session_storage_namespace); |
| + |
| + // Creates BackgroundLoaderContents with specified |browser_context|. Uses |
| + // default session storage space. |
| + 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.
|
| + ~BackgroundLoaderContents() override; |
| + |
| + // 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
|
| + void LoadPage(const GURL& url); |
| + // 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.
|
| + void Cancel(); |
| + |
| + void AddObserver(content::WebContentsObserver* observer); |
| + void RemoveObserver(content::WebContentsObserver* observer); |
| + |
| + // content::WebContentsDelegate Implementation: |
|
fgorski
2016/10/25 12:15:36
s/I/i/
chili
2016/10/25 18:48:00
Done.
|
| + bool IsNeverVisible(content::WebContents* web_contents) override; |
| + void CloseContents(content::WebContents* source) override; |
| + bool ShouldSuppressDialogs(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 AddNewContents(WebContents* source, |
| + WebContents* new_contents, |
| + WindowOpenDisposition disposition, |
| + const gfx::Rect& initial_rect, |
| + bool user_gesture, |
| + bool* was_blocked) override; |
| + |
| +#if defined(OS_ANDROID) |
| + bool ShouldBlockMediaRequest(const GURL& url) override; |
| +#endif |
| + |
| + 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; |
| + |
| + private: |
| + std::unique_ptr<content::WebContents> web_contents_; |
| + content::SessionStorageNamespaceMap session_storage_namespace_map_; |
| + content::BrowserContext* browser_context_; |
| + 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 :)
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(BackgroundLoaderContents); |
| +}; |
| + |
| +} // namespace background |
| +#endif // COMPONENTS_OFFLINE_PAGES_CONTENT_BACKGROUND_LOADER_BACKGROUND_LOADER_CONTENTS_H_ |