OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/printing/print_dialog_cloud.h" | 5 #include "chrome/browser/printing/print_dialog_cloud.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
25 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 25 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
27 #include "components/cloud_devices/common/cloud_devices_urls.h" | 27 #include "components/cloud_devices/common/cloud_devices_urls.h" |
28 #include "components/google/core/browser/google_util.h" | 28 #include "components/google/core/browser/google_util.h" |
29 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/message_port_provider.h" | 31 #include "content/public/browser/message_port_provider.h" |
32 #include "content/public/browser/render_frame_host.h" | 32 #include "content/public/browser/render_frame_host.h" |
33 #include "content/public/common/message_port_types.h" | |
34 | 33 |
35 namespace print_dialog_cloud { | 34 namespace print_dialog_cloud { |
36 | 35 |
37 namespace { | 36 namespace { |
38 | 37 |
39 // Limit is used only to allocate memory. Cloud has own small limit. | 38 // Limit is used only to allocate memory. Cloud has own small limit. |
40 const int kMaxFileSize = 1024 * 1024 * 1024; | 39 const int kMaxFileSize = 1024 * 1024 * 1024; |
41 | 40 |
42 // Sets print data into Cloud Print widget. | 41 // Sets print data into Cloud Print widget. |
43 class PrintDataSetter : public content::WebContentsObserver { | 42 class PrintDataSetter : public content::WebContentsObserver { |
(...skipping 25 matching lines...) Expand all Loading... |
69 | 68 |
70 private: | 69 private: |
71 // Overridden from content::WebContentsObserver: | 70 // Overridden from content::WebContentsObserver: |
72 void DocumentLoadedInFrame( | 71 void DocumentLoadedInFrame( |
73 content::RenderFrameHost* render_frame_host) override { | 72 content::RenderFrameHost* render_frame_host) override { |
74 GURL url = web_contents()->GetURL(); | 73 GURL url = web_contents()->GetURL(); |
75 if (cloud_devices::IsCloudPrintURL(url)) { | 74 if (cloud_devices::IsCloudPrintURL(url)) { |
76 base::string16 origin = base::UTF8ToUTF16(url.GetOrigin().spec()); | 75 base::string16 origin = base::UTF8ToUTF16(url.GetOrigin().spec()); |
77 content::MessagePortProvider::PostMessageToFrame( | 76 content::MessagePortProvider::PostMessageToFrame( |
78 web_contents(), origin, origin, message_data_, | 77 web_contents(), origin, origin, message_data_, |
79 std::vector<content::TransferredMessagePort>()); | 78 std::vector<int>()); |
80 } | 79 } |
81 } | 80 } |
82 | 81 |
83 void WebContentsDestroyed() override { delete this; } | 82 void WebContentsDestroyed() override { delete this; } |
84 | 83 |
85 base::string16 message_data_; | 84 base::string16 message_data_; |
86 DISALLOW_COPY_AND_ASSIGN(PrintDataSetter); | 85 DISALLOW_COPY_AND_ASSIGN(PrintDataSetter); |
87 }; | 86 }; |
88 | 87 |
89 void CreatePrintDialog(content::BrowserContext* browser_context, | 88 void CreatePrintDialog(content::BrowserContext* browser_context, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 std::string file_type = | 154 std::string file_type = |
156 command_line.GetSwitchValueASCII(switches::kCloudPrintFileType); | 155 command_line.GetSwitchValueASCII(switches::kCloudPrintFileType); |
157 if (file_type.empty()) | 156 if (file_type.empty()) |
158 file_type = "application/pdf"; | 157 file_type = "application/pdf"; |
159 CreatePrintDialogForFile(profile, cloud_print_file, print_job_title, | 158 CreatePrintDialogForFile(profile, cloud_print_file, print_job_title, |
160 print_job_print_ticket, file_type); | 159 print_job_print_ticket, file_type); |
161 return true; | 160 return true; |
162 } | 161 } |
163 | 162 |
164 } // namespace print_dialog_cloud | 163 } // namespace print_dialog_cloud |
OLD | NEW |