blob: 64b814bfe29419105ea9f0e53460cd7016b88c8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright (c) 2012 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.
#include "components/pdf/browser/pdf_web_contents_helper.h"
#include <utility>
#include "base/bind.h"
#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/pdf/browser/pdf_web_contents_helper_client.h"
DEFINE_WEB_CONTENTS_USER_DATA_KEY(pdf::PDFWebContentsHelper);
namespace pdf {
// static
void PDFWebContentsHelper::CreateForWebContentsWithClient(
content::WebContents* contents,
std::unique_ptr<PDFWebContentsHelperClient> client) {
if (FromWebContents(contents))
return;
contents->SetUserData(
UserDataKey(),
base::WrapUnique(new PDFWebContentsHelper(contents, std::move(client))));
}
PDFWebContentsHelper::PDFWebContentsHelper(
content::WebContents* web_contents,
std::unique_ptr<PDFWebContentsHelperClient> client)
: content::WebContentsObserver(web_contents),
pdf_service_bindings_(web_contents, this),
client_(std::move(client)) {}
PDFWebContentsHelper::~PDFWebContentsHelper() {
}
void PDFWebContentsHelper::HasUnsupportedFeature() {
client_->OnPDFHasUnsupportedFeature(web_contents());
}
void PDFWebContentsHelper::SaveUrlAs(const GURL& url,
const content::Referrer& referrer) {
client_->OnSaveURL(web_contents());
web_contents()->SaveFrame(url, referrer);
}
void PDFWebContentsHelper::UpdateContentRestrictions(
int32_t content_restrictions) {
client_->UpdateContentRestrictions(web_contents(), content_restrictions);
}
} // namespace pdf
|