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

Side by Side Diff: chrome/browser/renderer_host/render_view_host.cc

Issue 4338001: Implement print preview tab controller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed a style issue. Created 10 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 | Annotate | Revision Log
OLDNEW
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/blocked_plugin_manager.h" 18 #include "chrome/browser/blocked_plugin_manager.h"
19 #include "chrome/browser/browser_list.h" 19 #include "chrome/browser/browser_list.h"
20 #include "chrome/browser/child_process_security_policy.h" 20 #include "chrome/browser/child_process_security_policy.h"
21 #include "chrome/browser/cross_site_request_manager.h" 21 #include "chrome/browser/cross_site_request_manager.h"
22 #include "chrome/browser/debugger/devtools_manager.h" 22 #include "chrome/browser/debugger/devtools_manager.h"
23 #include "chrome/browser/dom_operation_notification_details.h" 23 #include "chrome/browser/dom_operation_notification_details.h"
24 #include "chrome/browser/extensions/extension_message_service.h" 24 #include "chrome/browser/extensions/extension_message_service.h"
25 #include "chrome/browser/in_process_webkit/session_storage_namespace.h" 25 #include "chrome/browser/in_process_webkit/session_storage_namespace.h"
26 #include "chrome/browser/net/predictor_api.h" 26 #include "chrome/browser/net/predictor_api.h"
27 #include "chrome/browser/notifications/desktop_notification_service.h" 27 #include "chrome/browser/notifications/desktop_notification_service.h"
28 #include "chrome/browser/printing/print_preview_tab_controller.h"
28 #include "chrome/browser/profile.h" 29 #include "chrome/browser/profile.h"
29 #include "chrome/browser/renderer_host/render_process_host.h" 30 #include "chrome/browser/renderer_host/render_process_host.h"
30 #include "chrome/browser/renderer_host/render_view_host_delegate.h" 31 #include "chrome/browser/renderer_host/render_view_host_delegate.h"
31 #include "chrome/browser/renderer_host/render_widget_host.h" 32 #include "chrome/browser/renderer_host/render_widget_host.h"
32 #include "chrome/browser/renderer_host/render_widget_host_view.h" 33 #include "chrome/browser/renderer_host/render_widget_host_view.h"
33 #include "chrome/browser/renderer_host/site_instance.h" 34 #include "chrome/browser/renderer_host/site_instance.h"
34 #include "chrome/common/bindings_policy.h" 35 #include "chrome/common/bindings_policy.h"
35 #include "chrome/common/chrome_constants.h" 36 #include "chrome/common/chrome_constants.h"
36 #include "chrome/common/chrome_switches.h" 37 #include "chrome/common/chrome_switches.h"
37 #include "chrome/common/native_web_keyboard_event.h" 38 #include "chrome/common/native_web_keyboard_event.h"
(...skipping 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 view->ShowPopupMenu(params.bounds, 2229 view->ShowPopupMenu(params.bounds,
2229 params.item_height, 2230 params.item_height,
2230 params.item_font_size, 2231 params.item_font_size,
2231 params.selected_item, 2232 params.selected_item,
2232 params.popup_items, 2233 params.popup_items,
2233 params.right_aligned); 2234 params.right_aligned);
2234 } 2235 }
2235 } 2236 }
2236 #endif 2237 #endif
2237 2238
2239 TabContents* RenderViewHost::GetPrintPreviewTab() {
2240 // current_tab is initiator_tab
2241 TabContents* current_tab = delegate_? delegate_->GetAsTabContents() : NULL;
2242 if (current_tab != NULL) {
2243 // Get/Create preview tab for initiator tab.
2244 printing::PrintPreviewTabController* tab_controller =
Lei Zhang 2010/11/12 02:10:55 What happens when GetInstance() returns NULL?
kmadhusu 2010/11/12 22:21:48 Made code change to check the return value.
2245 printing::PrintPreviewTabController::GetInstance();
2246 return tab_controller->get_print_preview_tab(
2247 current_tab, delegate_->GetBrowserWindowID());
2248 }
2249 return NULL;
2250 }
2251
2238 #if defined(OS_MACOSX) || defined(OS_WIN) 2252 #if defined(OS_MACOSX) || defined(OS_WIN)
2239 void RenderViewHost::OnPageReadyForPreview( 2253 void RenderViewHost::OnPageReadyForPreview(
2240 const ViewHostMsg_DidPrintPage_Params& params) { 2254 const ViewHostMsg_DidPrintPage_Params& params) {
2255 // Get the print preview tab.
2256 TabContents* preview_tab = GetPrintPreviewTab();
2257 DCHECK(preview_tab != NULL);
2258
2241 // TODO(kmadhusu): Function definition needs to be changed. 2259 // TODO(kmadhusu): Function definition needs to be changed.
2242 // 'params' contains the metafile handle for preview. 2260 // 'params' contains the metafile handle for preview.
2243 2261
2244 // Send the printingDone msg for now. 2262 // Send the printingDone msg for now.
2245 Send(new ViewMsg_PrintingDone(routing_id(), -1, true)); 2263 Send(new ViewMsg_PrintingDone(routing_id(), -1, true));
2246 } 2264 }
2247 #else 2265 #else
2248 void RenderViewHost::OnPagesReadyForPreview(int fd_in_browser) { 2266 void RenderViewHost::OnPagesReadyForPreview(int fd_in_browser) {
2267 // Get the print preview tab.
2268 TabContents* preview_tab = GetPrintPreviewTab();
2269 DCHECK(preview_tab != NULL);
2270
2249 // TODO(kmadhusu): Function definition needs to be changed. 2271 // TODO(kmadhusu): Function definition needs to be changed.
2250 // fd_in_browser should be the file descriptor of the metafile. 2272 // fd_in_browser should be the file descriptor of the metafile.
2251 2273
2252 // Send the printingDone msg for now. 2274 // Send the printingDone msg for now.
2253 Send(new ViewMsg_PrintingDone(routing_id(), -1, true)); 2275 Send(new ViewMsg_PrintingDone(routing_id(), -1, true));
2254 } 2276 }
2255 #endif 2277 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698