Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/renderer_host/render_view_host.h" | 5 #include "chrome/browser/renderer_host/render_view_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
| 14 #include "base/metrics/stats_counters.h" | 14 #include "base/metrics/stats_counters.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/browser/browser_list.h" | 18 #include "chrome/browser/browser_list.h" |
| 19 #include "chrome/browser/child_process_security_policy.h" | 19 #include "chrome/browser/child_process_security_policy.h" |
| 20 #include "chrome/browser/cross_site_request_manager.h" | 20 #include "chrome/browser/cross_site_request_manager.h" |
| 21 #include "chrome/browser/debugger/devtools_manager.h" | 21 #include "chrome/browser/debugger/devtools_manager.h" |
| 22 #include "chrome/browser/dom_operation_notification_details.h" | 22 #include "chrome/browser/dom_operation_notification_details.h" |
| 23 #include "chrome/browser/extensions/extension_message_service.h" | 23 #include "chrome/browser/extensions/extension_message_service.h" |
| 24 #include "chrome/browser/in_process_webkit/session_storage_namespace.h" | 24 #include "chrome/browser/in_process_webkit/session_storage_namespace.h" |
| 25 #include "chrome/browser/net/predictor_api.h" | 25 #include "chrome/browser/net/predictor_api.h" |
| 26 #include "chrome/browser/notifications/desktop_notification_service.h" | 26 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 27 #include "chrome/browser/printing/print_preview_tab_controller.h" | |
| 27 #include "chrome/browser/profile.h" | 28 #include "chrome/browser/profile.h" |
| 28 #include "chrome/browser/renderer_host/render_process_host.h" | 29 #include "chrome/browser/renderer_host/render_process_host.h" |
| 29 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 30 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
| 30 #include "chrome/browser/renderer_host/render_widget_host.h" | 31 #include "chrome/browser/renderer_host/render_widget_host.h" |
| 31 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 32 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| 32 #include "chrome/browser/renderer_host/site_instance.h" | 33 #include "chrome/browser/renderer_host/site_instance.h" |
| 33 #include "chrome/common/bindings_policy.h" | 34 #include "chrome/common/bindings_policy.h" |
| 34 #include "chrome/common/chrome_constants.h" | 35 #include "chrome/common/chrome_constants.h" |
| 35 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
| 36 #include "chrome/common/native_web_keyboard_event.h" | 37 #include "chrome/common/native_web_keyboard_event.h" |
| (...skipping 2169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2206 view->ShowPopupMenu(params.bounds, | 2207 view->ShowPopupMenu(params.bounds, |
| 2207 params.item_height, | 2208 params.item_height, |
| 2208 params.item_font_size, | 2209 params.item_font_size, |
| 2209 params.selected_item, | 2210 params.selected_item, |
| 2210 params.popup_items, | 2211 params.popup_items, |
| 2211 params.right_aligned); | 2212 params.right_aligned); |
| 2212 } | 2213 } |
| 2213 } | 2214 } |
| 2214 #endif | 2215 #endif |
| 2215 | 2216 |
| 2217 TabContents* RenderViewHost::GetPrintPreviewTab() { | |
| 2218 // |current_tab| is initiator tab. | |
|
James Hawkins
2010/11/16 02:15:42
s/current/initiator/
kmadhusu
2010/11/16 18:16:09
Done.
| |
| 2219 TabContents* current_tab = delegate_ ? delegate_->GetAsTabContents() : NULL; | |
| 2220 if (current_tab) { | |
| 2221 // Get/Create preview tab for initiator tab. | |
| 2222 printing::PrintPreviewTabController* tab_controller = | |
| 2223 printing::PrintPreviewTabController::GetInstance(); | |
| 2224 if (tab_controller) | |
| 2225 return tab_controller->GetOrCreatePreviewTab( | |
| 2226 current_tab, delegate_->GetBrowserWindowID()); | |
| 2227 } | |
| 2228 return NULL; | |
| 2229 } | |
| 2230 | |
| 2216 #if defined(OS_MACOSX) || defined(OS_WIN) | 2231 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 2217 void RenderViewHost::OnPageReadyForPreview( | 2232 void RenderViewHost::OnPageReadyForPreview( |
| 2218 const ViewHostMsg_DidPrintPage_Params& params) { | 2233 const ViewHostMsg_DidPrintPage_Params& params) { |
| 2234 // Get the print preview tab. | |
| 2235 TabContents* preview_tab = GetPrintPreviewTab(); | |
|
James Hawkins
2010/11/16 02:15:42
print_preview_tab
James Hawkins
2010/11/16 02:15:42
Does GetPrintPreviewTab() open/activate a tab?
kmadhusu
2010/11/16 18:16:09
Done.
kmadhusu
2010/11/16 18:16:09
Yes. I renamed the function to "GetOrCreatePrintPr
| |
| 2236 DCHECK(preview_tab); | |
| 2237 | |
| 2219 // TODO(kmadhusu): Function definition needs to be changed. | 2238 // TODO(kmadhusu): Function definition needs to be changed. |
| 2220 // 'params' contains the metafile handle for preview. | 2239 // 'params' contains the metafile handle for preview. |
| 2221 | 2240 |
| 2222 // Send the printingDone msg for now. | 2241 // Send the printingDone msg for now. |
| 2223 Send(new ViewMsg_PrintingDone(routing_id(), -1, true)); | 2242 Send(new ViewMsg_PrintingDone(routing_id(), -1, true)); |
| 2224 } | 2243 } |
| 2225 #else | 2244 #else |
| 2226 void RenderViewHost::OnPagesReadyForPreview(int fd_in_browser) { | 2245 void RenderViewHost::OnPagesReadyForPreview(int fd_in_browser) { |
| 2246 // Get the print preview tab. | |
| 2247 TabContents* preview_tab = GetPrintPreviewTab(); | |
| 2248 DCHECK(preview_tab); | |
| 2249 | |
| 2227 // TODO(kmadhusu): Function definition needs to be changed. | 2250 // TODO(kmadhusu): Function definition needs to be changed. |
| 2228 // fd_in_browser should be the file descriptor of the metafile. | 2251 // fd_in_browser should be the file descriptor of the metafile. |
| 2229 | 2252 |
| 2230 // Send the printingDone msg for now. | 2253 // Send the printingDone msg for now. |
| 2231 Send(new ViewMsg_PrintingDone(routing_id(), -1, true)); | 2254 Send(new ViewMsg_PrintingDone(routing_id(), -1, true)); |
| 2232 } | 2255 } |
| 2233 #endif | 2256 #endif |
| OLD | NEW |