| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "chrome/common/thumbnail_score.h" | 34 #include "chrome/common/thumbnail_score.h" |
| 35 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
| 36 #include "net/base/net_util.h" | 36 #include "net/base/net_util.h" |
| 37 #include "third_party/skia/include/core/SkBitmap.h" | 37 #include "third_party/skia/include/core/SkBitmap.h" |
| 38 #include "webkit/api/public/WebFindOptions.h" | 38 #include "webkit/api/public/WebFindOptions.h" |
| 39 #include "webkit/glue/autofill_form.h" | 39 #include "webkit/glue/autofill_form.h" |
| 40 | 40 |
| 41 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
| 42 // TODO(port): accessibility not yet implemented. See http://crbug.com/8288. | 42 // TODO(port): accessibility not yet implemented. See http://crbug.com/8288. |
| 43 #include "chrome/browser/browser_accessibility_manager.h" | 43 #include "chrome/browser/browser_accessibility_manager.h" |
| 44 // TODO(port): The compact language detection library works only for Windows. |
| 45 #include "third_party/cld/bar/toolbar/cld/i18n/encodings/compact_lang_det/win/cl
d_unicodetext.h" |
| 44 #endif | 46 #endif |
| 45 | 47 |
| 46 using base::TimeDelta; | 48 using base::TimeDelta; |
| 47 using webkit_glue::PasswordFormDomManager; | 49 using webkit_glue::PasswordFormDomManager; |
| 48 using WebKit::WebConsoleMessage; | 50 using WebKit::WebConsoleMessage; |
| 49 using WebKit::WebFindOptions; | 51 using WebKit::WebFindOptions; |
| 50 using WebKit::WebInputEvent; | 52 using WebKit::WebInputEvent; |
| 51 | 53 |
| 52 namespace { | 54 namespace { |
| 53 | 55 |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 Send(new ViewMsg_Find(routing_id(), request_id, search_text, options)); | 405 Send(new ViewMsg_Find(routing_id(), request_id, search_text, options)); |
| 404 | 406 |
| 405 // This call is asynchronous and returns immediately. | 407 // This call is asynchronous and returns immediately. |
| 406 // The result of the search is sent as a notification message by the renderer. | 408 // The result of the search is sent as a notification message by the renderer. |
| 407 } | 409 } |
| 408 | 410 |
| 409 void RenderViewHost::StopFinding(bool clear_selection) { | 411 void RenderViewHost::StopFinding(bool clear_selection) { |
| 410 Send(new ViewMsg_StopFinding(routing_id(), clear_selection)); | 412 Send(new ViewMsg_StopFinding(routing_id(), clear_selection)); |
| 411 } | 413 } |
| 412 | 414 |
| 415 void RenderViewHost::GetPageLanguage() { |
| 416 Send(new ViewMsg_DeterminePageText(routing_id())); |
| 417 } |
| 418 |
| 413 void RenderViewHost::Zoom(PageZoom::Function function) { | 419 void RenderViewHost::Zoom(PageZoom::Function function) { |
| 414 Send(new ViewMsg_Zoom(routing_id(), function)); | 420 Send(new ViewMsg_Zoom(routing_id(), function)); |
| 415 } | 421 } |
| 416 | 422 |
| 417 void RenderViewHost::SetPageEncoding(const std::wstring& encoding_name) { | 423 void RenderViewHost::SetPageEncoding(const std::wstring& encoding_name) { |
| 418 Send(new ViewMsg_SetPageEncoding(routing_id(), encoding_name)); | 424 Send(new ViewMsg_SetPageEncoding(routing_id(), encoding_name)); |
| 419 } | 425 } |
| 420 | 426 |
| 421 void RenderViewHost::SetAlternateErrorPageURL(const GURL& url) { | 427 void RenderViewHost::SetAlternateErrorPageURL(const GURL& url) { |
| 422 Send(new ViewMsg_SetAltErrorPageURL(routing_id(), url)); | 428 Send(new ViewMsg_SetAltErrorPageURL(routing_id(), url)); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStopLoading, OnMsgDidStopLoading) | 725 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStopLoading, OnMsgDidStopLoading) |
| 720 IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, | 726 IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, |
| 721 OnMsgDidLoadResourceFromMemoryCache) | 727 OnMsgDidLoadResourceFromMemoryCache) |
| 722 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRedirectProvisionalLoad, | 728 IPC_MESSAGE_HANDLER(ViewHostMsg_DidRedirectProvisionalLoad, |
| 723 OnMsgDidRedirectProvisionalLoad) | 729 OnMsgDidRedirectProvisionalLoad) |
| 724 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame, | 730 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame, |
| 725 OnMsgDidStartProvisionalLoadForFrame) | 731 OnMsgDidStartProvisionalLoadForFrame) |
| 726 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFailProvisionalLoadWithError, | 732 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFailProvisionalLoadWithError, |
| 727 OnMsgDidFailProvisionalLoadWithError) | 733 OnMsgDidFailProvisionalLoadWithError) |
| 728 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnMsgFindReply) | 734 IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnMsgFindReply) |
| 735 IPC_MESSAGE_HANDLER(ViewMsg_DeterminePageText_Reply, |
| 736 OnDeterminePageTextReply) |
| 729 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFavIconURL, OnMsgUpdateFavIconURL) | 737 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFavIconURL, OnMsgUpdateFavIconURL) |
| 730 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDownloadFavIcon, OnMsgDidDownloadFavIcon) | 738 IPC_MESSAGE_HANDLER(ViewHostMsg_DidDownloadFavIcon, OnMsgDidDownloadFavIcon) |
| 731 IPC_MESSAGE_HANDLER(ViewHostMsg_ContextMenu, OnMsgContextMenu) | 739 IPC_MESSAGE_HANDLER(ViewHostMsg_ContextMenu, OnMsgContextMenu) |
| 732 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenURL, OnMsgOpenURL) | 740 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenURL, OnMsgOpenURL) |
| 733 IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredWidthChange, | 741 IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredWidthChange, |
| 734 OnMsgDidContentsPreferredWidthChange) | 742 OnMsgDidContentsPreferredWidthChange) |
| 735 IPC_MESSAGE_HANDLER(ViewHostMsg_DomOperationResponse, | 743 IPC_MESSAGE_HANDLER(ViewHostMsg_DomOperationResponse, |
| 736 OnMsgDomOperationResponse) | 744 OnMsgDomOperationResponse) |
| 737 IPC_MESSAGE_HANDLER(ViewHostMsg_DOMUISend, | 745 IPC_MESSAGE_HANDLER(ViewHostMsg_DOMUISend, |
| 738 OnMsgDOMUISend) | 746 OnMsgDOMUISend) |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 | 1059 |
| 1052 // Send a notification to the renderer that we are ready to receive more | 1060 // Send a notification to the renderer that we are ready to receive more |
| 1053 // results from the scoping effort of the Find operation. The FindInPage | 1061 // results from the scoping effort of the Find operation. The FindInPage |
| 1054 // scoping is asynchronous and periodically sends results back up to the | 1062 // scoping is asynchronous and periodically sends results back up to the |
| 1055 // browser using IPC. In an effort to not spam the browser we have the | 1063 // browser using IPC. In an effort to not spam the browser we have the |
| 1056 // browser send an ACK for each FindReply message and have the renderer | 1064 // browser send an ACK for each FindReply message and have the renderer |
| 1057 // queue up the latest status message while waiting for this ACK. | 1065 // queue up the latest status message while waiting for this ACK. |
| 1058 Send(new ViewMsg_FindReplyACK(routing_id())); | 1066 Send(new ViewMsg_FindReplyACK(routing_id())); |
| 1059 } | 1067 } |
| 1060 | 1068 |
| 1069 void RenderViewHost::OnDeterminePageTextReply( |
| 1070 const std::wstring& page_text) { |
| 1071 #if defined(OS_WIN) // Only for windows. |
| 1072 int num_languages = 0; |
| 1073 bool is_reliable = false; |
| 1074 const char* language_char = LanguageName(DetectLanguageOfUnicodeText( |
| 1075 page_text.c_str(), true, &is_reliable, &num_languages, NULL)); |
| 1076 std::string language(language_char); |
| 1077 NotificationService::current()->Notify( |
| 1078 NotificationType::TAB_LANGUAGE_DETERMINED, |
| 1079 Source<RenderViewHost>(this), |
| 1080 Details<std::string>(&language)); |
| 1081 #endif |
| 1082 } |
| 1083 |
| 1061 void RenderViewHost::OnMsgUpdateFavIconURL(int32 page_id, | 1084 void RenderViewHost::OnMsgUpdateFavIconURL(int32 page_id, |
| 1062 const GURL& icon_url) { | 1085 const GURL& icon_url) { |
| 1063 RenderViewHostDelegate::FavIcon* favicon_delegate = | 1086 RenderViewHostDelegate::FavIcon* favicon_delegate = |
| 1064 delegate_->GetFavIconDelegate(); | 1087 delegate_->GetFavIconDelegate(); |
| 1065 if (favicon_delegate) | 1088 if (favicon_delegate) |
| 1066 favicon_delegate->UpdateFavIconURL(this, page_id, icon_url); | 1089 favicon_delegate->UpdateFavIconURL(this, page_id, icon_url); |
| 1067 } | 1090 } |
| 1068 | 1091 |
| 1069 void RenderViewHost::OnMsgDidDownloadFavIcon(int id, | 1092 void RenderViewHost::OnMsgDidDownloadFavIcon(int id, |
| 1070 const GURL& image_url, | 1093 const GURL& image_url, |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 | 1556 |
| 1534 void RenderViewHost::SignalModalDialogEvent() { | 1557 void RenderViewHost::SignalModalDialogEvent() { |
| 1535 if (modal_dialog_count_++ == 0) | 1558 if (modal_dialog_count_++ == 0) |
| 1536 modal_dialog_event_->Signal(); | 1559 modal_dialog_event_->Signal(); |
| 1537 } | 1560 } |
| 1538 | 1561 |
| 1539 void RenderViewHost::ResetModalDialogEvent() { | 1562 void RenderViewHost::ResetModalDialogEvent() { |
| 1540 if (--modal_dialog_count_ == 0) | 1563 if (--modal_dialog_count_ == 0) |
| 1541 modal_dialog_event_->Reset(); | 1564 modal_dialog_event_->Reset(); |
| 1542 } | 1565 } |
| OLD | NEW |