| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/resource_message_filter.h" | 5 #include "chrome/browser/resource_message_filter.h" |
| 6 | 6 |
| 7 #include "base/clipboard.h" | 7 #include "base/clipboard.h" |
| 8 #include "base/gfx/native_widget_types.h" |
| 8 #include "base/histogram.h" | 9 #include "base/histogram.h" |
| 9 #include "base/thread.h" | 10 #include "base/thread.h" |
| 10 #include "chrome/browser/chrome_plugin_browsing_context.h" | 11 #include "chrome/browser/chrome_plugin_browsing_context.h" |
| 11 #include "chrome/browser/chrome_thread.h" | 12 #include "chrome/browser/chrome_thread.h" |
| 12 #include "chrome/browser/net/dns_global.h" | 13 #include "chrome/browser/net/dns_global.h" |
| 13 #include "chrome/browser/printing/print_job_manager.h" | 14 #include "chrome/browser/printing/print_job_manager.h" |
| 14 #include "chrome/browser/printing/printer_query.h" | 15 #include "chrome/browser/printing/printer_query.h" |
| 15 #include "chrome/browser/profile.h" | 16 #include "chrome/browser/profile.h" |
| 16 #include "chrome/browser/plugin_service.h" | 17 #include "chrome/browser/plugin_service.h" |
| 17 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 18 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // Called on the IPC thread: | 238 // Called on the IPC thread: |
| 238 bool ResourceMessageFilter::Send(IPC::Message* message) { | 239 bool ResourceMessageFilter::Send(IPC::Message* message) { |
| 239 if (!channel_) { | 240 if (!channel_) { |
| 240 delete message; | 241 delete message; |
| 241 return false; | 242 return false; |
| 242 } | 243 } |
| 243 | 244 |
| 244 return channel_->Send(message); | 245 return channel_->Send(message); |
| 245 } | 246 } |
| 246 | 247 |
| 247 void ResourceMessageFilter::OnMsgCreateWindow(int opener_id, | 248 void ResourceMessageFilter::OnMsgCreateWindow( |
| 248 bool user_gesture, | 249 int opener_id, bool user_gesture, int* route_id, |
| 249 int* route_id, | 250 ModalDialogEvent* modal_dialog_event) { |
| 250 HANDLE* modal_dialog_event) { | |
| 251 render_widget_helper_->CreateNewWindow(opener_id, | 251 render_widget_helper_->CreateNewWindow(opener_id, |
| 252 user_gesture, | 252 user_gesture, |
| 253 render_handle_, | 253 render_handle_, |
| 254 route_id, | 254 route_id, |
| 255 modal_dialog_event); | 255 modal_dialog_event); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void ResourceMessageFilter::OnMsgCreateWidget(int opener_id, | 258 void ResourceMessageFilter::OnMsgCreateWidget(int opener_id, |
| 259 bool activatable, | 259 bool activatable, |
| 260 int* route_id) { | 260 int* route_id) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 DeleteObject(fonts[font_index]); | 399 DeleteObject(fonts[font_index]); |
| 400 ReleaseDC(NULL, hdcs[font_index]); | 400 ReleaseDC(NULL, hdcs[font_index]); |
| 401 } | 401 } |
| 402 | 402 |
| 403 fonts[font_index] = font_handle; | 403 fonts[font_index] = font_handle; |
| 404 hdcs[font_index] = hdc; | 404 hdcs[font_index] = hdc; |
| 405 font_index = (font_index + 1) % kFontCacheSize; | 405 font_index = (font_index + 1) % kFontCacheSize; |
| 406 } | 406 } |
| 407 | 407 |
| 408 void ResourceMessageFilter::OnGetScreenInfo( | 408 void ResourceMessageFilter::OnGetScreenInfo( |
| 409 » gfx::NativeView window, webkit_glue::ScreenInfo* results) { | 409 gfx::NativeViewId window, webkit_glue::ScreenInfo* results) { |
| 410 *results = webkit_glue::GetScreenInfoHelper(window); | 410 *results = webkit_glue::GetScreenInfoHelper(gfx::NativeViewFromId(window)); |
| 411 } | 411 } |
| 412 | 412 |
| 413 void ResourceMessageFilter::OnGetPlugins(bool refresh, | 413 void ResourceMessageFilter::OnGetPlugins(bool refresh, |
| 414 std::vector<WebPluginInfo>* plugins) { | 414 std::vector<WebPluginInfo>* plugins) { |
| 415 plugin_service_->GetPlugins(refresh, plugins); | 415 plugin_service_->GetPlugins(refresh, plugins); |
| 416 } | 416 } |
| 417 | 417 |
| 418 void ResourceMessageFilter::OnGetPluginPath(const GURL& url, | 418 void ResourceMessageFilter::OnGetPluginPath(const GURL& url, |
| 419 const std::string& mime_type, | 419 const std::string& mime_type, |
| 420 const std::string& clsid, | 420 const std::string& clsid, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 | 467 |
| 468 void ResourceMessageFilter::OnClipboardReadHTML(std::wstring* markup, | 468 void ResourceMessageFilter::OnClipboardReadHTML(std::wstring* markup, |
| 469 GURL* src_url) { | 469 GURL* src_url) { |
| 470 std::string src_url_str; | 470 std::string src_url_str; |
| 471 GetClipboardService()->ReadHTML(markup, &src_url_str); | 471 GetClipboardService()->ReadHTML(markup, &src_url_str); |
| 472 *src_url = GURL(src_url_str); | 472 *src_url = GURL(src_url_str); |
| 473 } | 473 } |
| 474 | 474 |
| 475 #if defined(OS_WIN) | 475 #if defined(OS_WIN) |
| 476 | 476 |
| 477 void ResourceMessageFilter::OnGetWindowRect(HWND window, gfx::Rect *rect) { | 477 void ResourceMessageFilter::OnGetWindowRect(gfx::NativeViewId window_id, |
| 478 gfx::Rect* rect) { |
| 479 HWND window = gfx::NativeViewFromId(window_id); |
| 478 RECT window_rect = {0}; | 480 RECT window_rect = {0}; |
| 479 GetWindowRect(window, &window_rect); | 481 GetWindowRect(window, &window_rect); |
| 480 *rect = window_rect; | 482 *rect = window_rect; |
| 481 } | 483 } |
| 482 | 484 |
| 483 void ResourceMessageFilter::OnGetRootWindowRect(HWND window, gfx::Rect *rect) { | 485 void ResourceMessageFilter::OnGetRootWindowRect(gfx::NativeViewId window_id, |
| 486 gfx::Rect* rect) { |
| 487 HWND window = gfx::NativeViewFromId(window_id); |
| 484 RECT window_rect = {0}; | 488 RECT window_rect = {0}; |
| 485 HWND root_window = ::GetAncestor(window, GA_ROOT); | 489 HWND root_window = ::GetAncestor(window, GA_ROOT); |
| 486 GetWindowRect(root_window, &window_rect); | 490 GetWindowRect(root_window, &window_rect); |
| 487 *rect = window_rect; | 491 *rect = window_rect; |
| 488 } | 492 } |
| 489 | 493 |
| 490 void ResourceMessageFilter::OnGetRootWindowResizerRect(HWND window, gfx::Rect *r
ect) { | 494 void ResourceMessageFilter::OnGetRootWindowResizerRect(gfx::NativeViewId window, |
| 495 gfx::Rect* rect) { |
| 491 RECT window_rect = {0}; | 496 RECT window_rect = {0}; |
| 492 *rect = window_rect; | 497 *rect = window_rect; |
| 493 } | 498 } |
| 494 | 499 |
| 495 #endif // OS_WIN | 500 #endif // OS_WIN |
| 496 | 501 |
| 497 void ResourceMessageFilter::OnGetMimeTypeFromExtension( | 502 void ResourceMessageFilter::OnGetMimeTypeFromExtension( |
| 498 const std::wstring& ext, std::string* mime_type) { | 503 const std::wstring& ext, std::string* mime_type) { |
| 499 net::GetMimeTypeFromExtension(ext, mime_type); | 504 net::GetMimeTypeFromExtension(ext, mime_type); |
| 500 } | 505 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 // If user hasn't cancelled. | 579 // If user hasn't cancelled. |
| 575 if (printer_query->cookie() && printer_query->settings().dpi()) { | 580 if (printer_query->cookie() && printer_query->settings().dpi()) { |
| 576 print_job_manager_->QueuePrinterQuery(printer_query.get()); | 581 print_job_manager_->QueuePrinterQuery(printer_query.get()); |
| 577 } else { | 582 } else { |
| 578 printer_query->StopWorker(); | 583 printer_query->StopWorker(); |
| 579 } | 584 } |
| 580 } | 585 } |
| 581 | 586 |
| 582 #if defined(OS_WIN) | 587 #if defined(OS_WIN) |
| 583 | 588 |
| 584 void ResourceMessageFilter::OnScriptedPrint(HWND host_window, | 589 void ResourceMessageFilter::OnScriptedPrint(gfx::NativeViewId host_window_id, |
| 585 int cookie, | 590 int cookie, |
| 586 int expected_pages_count, | 591 int expected_pages_count, |
| 587 IPC::Message* reply_msg) { | 592 IPC::Message* reply_msg) { |
| 593 HWND host_window = gfx::NativeViewFromId(host_window_id); |
| 594 |
| 588 scoped_refptr<printing::PrinterQuery> printer_query; | 595 scoped_refptr<printing::PrinterQuery> printer_query; |
| 589 print_job_manager_->PopPrinterQuery(cookie, &printer_query); | 596 print_job_manager_->PopPrinterQuery(cookie, &printer_query); |
| 590 if (!printer_query.get()) { | 597 if (!printer_query.get()) { |
| 591 printer_query = new printing::PrinterQuery; | 598 printer_query = new printing::PrinterQuery; |
| 592 } | 599 } |
| 593 | 600 |
| 594 CancelableTask* task = NewRunnableMethod( | 601 CancelableTask* task = NewRunnableMethod( |
| 595 this, | 602 this, |
| 596 &ResourceMessageFilter::OnScriptedPrintReply, | 603 &ResourceMessageFilter::OnScriptedPrintReply, |
| 597 printer_query, | 604 printer_query, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 if (type == NOTIFY_SPELLCHECKER_REINITIALIZED) { | 686 if (type == NOTIFY_SPELLCHECKER_REINITIALIZED) { |
| 680 spellchecker_ = Details<SpellcheckerReinitializedDetails> | 687 spellchecker_ = Details<SpellcheckerReinitializedDetails> |
| 681 (details).ptr()->spellchecker; | 688 (details).ptr()->spellchecker; |
| 682 } | 689 } |
| 683 } | 690 } |
| 684 | 691 |
| 685 void ResourceMessageFilter::OnDnsPrefetch( | 692 void ResourceMessageFilter::OnDnsPrefetch( |
| 686 const std::vector<std::string>& hostnames) { | 693 const std::vector<std::string>& hostnames) { |
| 687 chrome_browser_net::DnsPrefetchList(hostnames); | 694 chrome_browser_net::DnsPrefetchList(hostnames); |
| 688 } | 695 } |
| OLD | NEW |