OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "components/pdf/browser/pdf_web_contents_helper.h" | 5 #include "components/pdf/browser/pdf_web_contents_helper.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "components/pdf/browser/open_pdf_in_reader_prompt_client.h" | 11 #include "components/pdf/browser/open_pdf_in_reader_prompt_client.h" |
12 #include "components/pdf/browser/pdf_web_contents_helper_client.h" | 12 #include "components/pdf/browser/pdf_web_contents_helper_client.h" |
13 #include "components/pdf/common/pdf_messages.h" | 13 #include "components/pdf/common/pdf_messages.h" |
14 #include "content/public/browser/navigation_details.h" | 14 #include "content/public/browser/navigation_details.h" |
15 | 15 |
16 DEFINE_WEB_CONTENTS_USER_DATA_KEY(pdf::PDFWebContentsHelper); | 16 DEFINE_WEB_CONTENTS_USER_DATA_KEY(pdf::PDFWebContentsHelper); |
17 | 17 |
18 namespace pdf { | 18 namespace pdf { |
19 | 19 |
20 // static | 20 // static |
21 void PDFWebContentsHelper::CreateForWebContentsWithClient( | 21 void PDFWebContentsHelper::CreateForWebContentsWithClient( |
22 content::WebContents* contents, | 22 content::WebContents* contents, |
23 scoped_ptr<PDFWebContentsHelperClient> client) { | 23 std::unique_ptr<PDFWebContentsHelperClient> client) { |
24 if (FromWebContents(contents)) | 24 if (FromWebContents(contents)) |
25 return; | 25 return; |
26 contents->SetUserData(UserDataKey(), | 26 contents->SetUserData(UserDataKey(), |
27 new PDFWebContentsHelper(contents, std::move(client))); | 27 new PDFWebContentsHelper(contents, std::move(client))); |
28 } | 28 } |
29 | 29 |
30 PDFWebContentsHelper::PDFWebContentsHelper( | 30 PDFWebContentsHelper::PDFWebContentsHelper( |
31 content::WebContents* web_contents, | 31 content::WebContents* web_contents, |
32 scoped_ptr<PDFWebContentsHelperClient> client) | 32 std::unique_ptr<PDFWebContentsHelperClient> client) |
33 : content::WebContentsObserver(web_contents), client_(std::move(client)) {} | 33 : content::WebContentsObserver(web_contents), client_(std::move(client)) {} |
34 | 34 |
35 PDFWebContentsHelper::~PDFWebContentsHelper() { | 35 PDFWebContentsHelper::~PDFWebContentsHelper() { |
36 } | 36 } |
37 | 37 |
38 void PDFWebContentsHelper::ShowOpenInReaderPrompt( | 38 void PDFWebContentsHelper::ShowOpenInReaderPrompt( |
39 scoped_ptr<OpenPDFInReaderPromptClient> prompt) { | 39 std::unique_ptr<OpenPDFInReaderPromptClient> prompt) { |
40 open_in_reader_prompt_ = std::move(prompt); | 40 open_in_reader_prompt_ = std::move(prompt); |
41 UpdateLocationBar(); | 41 UpdateLocationBar(); |
42 } | 42 } |
43 | 43 |
44 bool PDFWebContentsHelper::OnMessageReceived(const IPC::Message& message) { | 44 bool PDFWebContentsHelper::OnMessageReceived(const IPC::Message& message) { |
45 bool handled = true; | 45 bool handled = true; |
46 IPC_BEGIN_MESSAGE_MAP(PDFWebContentsHelper, message) | 46 IPC_BEGIN_MESSAGE_MAP(PDFWebContentsHelper, message) |
47 IPC_MESSAGE_HANDLER(PDFHostMsg_PDFHasUnsupportedFeature, | 47 IPC_MESSAGE_HANDLER(PDFHostMsg_PDFHasUnsupportedFeature, |
48 OnHasUnsupportedFeature) | 48 OnHasUnsupportedFeature) |
49 IPC_MESSAGE_HANDLER(PDFHostMsg_PDFSaveURLAs, OnSaveURLAs) | 49 IPC_MESSAGE_HANDLER(PDFHostMsg_PDFSaveURLAs, OnSaveURLAs) |
(...skipping 27 matching lines...) Expand all Loading... |
77 client_->OnSaveURL(web_contents()); | 77 client_->OnSaveURL(web_contents()); |
78 web_contents()->SaveFrame(url, referrer); | 78 web_contents()->SaveFrame(url, referrer); |
79 } | 79 } |
80 | 80 |
81 void PDFWebContentsHelper::OnUpdateContentRestrictions( | 81 void PDFWebContentsHelper::OnUpdateContentRestrictions( |
82 int content_restrictions) { | 82 int content_restrictions) { |
83 client_->UpdateContentRestrictions(web_contents(), content_restrictions); | 83 client_->UpdateContentRestrictions(web_contents(), content_restrictions); |
84 } | 84 } |
85 | 85 |
86 } // namespace pdf | 86 } // namespace pdf |
OLD | NEW |