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

Side by Side Diff: components/offline_pages/content/background_loader/background_loader_contents.cc

Issue 2481443002: Implementation (cc file) for background loader contents. (Closed)
Patch Set: Format and build Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
(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 #include "components/offline_pages/content/background_loader/background_loader_c ontents.h"
6
7 #include "content/public/browser/web_contents.h"
8
9 namespace background_loader {
10
11 BackgroundLoaderContents::BackgroundLoaderContents(
12 content::BrowserContext* browser_context)
13 : browser_context_(browser_context) {
14 web_contents_.reset(content::WebContents::Create(
15 content::WebContents::CreateParams(browser_context_)));
16 web_contents_->SetDelegate(this);
17 }
18
19 BackgroundLoaderContents::~BackgroundLoaderContents() {}
20
21 void BackgroundLoaderContents::LoadPage(const GURL& url) {
22 web_contents_->GetController().LoadURL(
23 url, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
Dmitry Titov 2016/11/08 00:07:18 Could you add comment on the choice of parameter v
chili 2016/11/10 22:05:08 Done.
24 }
25
26 void BackgroundLoaderContents::CloseContents(content::WebContents* source) {
Pete Williamson 2016/11/08 01:33:43 Why have two methods that do the same thing? Are
chili 2016/11/10 22:05:08 Cancel() is our own - for when we want to fail ear
27 web_contents_->Close();
28 }
29
30 void BackgroundLoaderContents::Cancel() {
Dmitry Titov 2016/11/08 00:07:18 The methods in cc file should be in the same order
chili 2016/11/10 22:05:08 Done.
31 web_contents_->Close();
32 }
33
34 bool BackgroundLoaderContents::ShouldSuppressDialogs(
35 content::WebContents* source) {
36 return true;
dougarnett 2016/11/08 17:09:41 I wonder if it would be helpful to add a comment o
chili 2016/11/10 22:05:08 Done.
dougarnett 2016/11/14 20:12:16 Thanks, I find those really helpful
37 }
38
39 bool BackgroundLoaderContents::IsNeverVisible(
40 content::WebContents* web_contents) {
41 return true;
42 }
43
44 bool BackgroundLoaderContents::ShouldFocusPageAfterCrash() {
45 return false;
46 }
47
48 void BackgroundLoaderContents::CanDownload(
49 const GURL& url,
50 const std::string& request_method,
51 const base::Callback<void(bool)>& callback) {
52 callback.Run(false);
Dmitry Titov 2016/11/08 00:07:18 It'd be nice to look at callers of CanDownload and
dewittj 2016/11/08 00:16:39 aside: this could be a cool signal in our page qua
chili 2016/11/10 22:05:08 The WebContentsDelegate method comments say that t
chili 2016/11/10 22:05:08 That's interesting. Perhaps not now, but we can a
53 }
54
55 bool BackgroundLoaderContents::ShouldCreateWebContents(
56 content::WebContents* contents,
57 int32_t route_id,
58 int32_t main_frame_route_id,
59 int32_t main_frame_widget_route_id,
60 WindowContainerType window_container_type,
61 const std::string& frame_name,
62 const GURL& target_url,
63 const std::string& partition_id,
64 content::SessionStorageNamespace* session_storage_namespace) {
65 return false;
66 }
67
68 void BackgroundLoaderContents::AddNewContents(
69 content::WebContents* source,
70 content::WebContents* new_contents,
71 WindowOpenDisposition disposition,
72 const gfx::Rect& initial_rect,
73 bool user_gesture,
74 bool* was_blocked) {
75 if (was_blocked != nullptr)
76 *was_blocked = true;
77 }
78
79 void BackgroundLoaderContents::RequestMediaAccessPermission(
80 content::WebContents* contents,
81 const content::MediaStreamRequest& request,
82 const content::MediaResponseCallback& callback) {
83 // No permissions granted, act as if dismissed.
84 callback.Run(
85 content::MediaStreamDevices(),
86 content::MediaStreamRequestResult::MEDIA_DEVICE_PERMISSION_DISMISSED,
87 std::unique_ptr<content::MediaStreamUI>());
88 }
89
90 bool BackgroundLoaderContents::CheckMediaAccessPermission(
91 content::WebContents* contents,
92 const GURL& security_origin,
93 content::MediaStreamType type) {
94 return false; // No permissions granted.
95 }
96
97 #if defined(OS_ANDROID)
98 bool BackgroundLoaderContents::ShouldBlockMediaRequest(const GURL& url) {
99 return true;
100 }
101 #endif
102
103 } // namespace background_loader
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698