| 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/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 OnAdvanceToNextMisspelling) | 587 OnAdvanceToNextMisspelling) |
| 588 IPC_MESSAGE_HANDLER(ViewMsg_ToggleSpellCheck, OnToggleSpellCheck) | 588 IPC_MESSAGE_HANDLER(ViewMsg_ToggleSpellCheck, OnToggleSpellCheck) |
| 589 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) | 589 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) |
| 590 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) | 590 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) |
| 591 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) | 591 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
| 592 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) | 592 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) |
| 593 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) | 593 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) |
| 594 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) | 594 IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
| 595 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) | 595 IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) |
| 596 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) | 596 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
| 597 IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForLoadingHost, | 597 IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForLoadingURL, |
| 598 OnSetContentSettingsForLoadingHost) | 598 OnSetContentSettingsForLoadingURL) |
| 599 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingHost, | 599 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
| 600 OnSetZoomLevelForLoadingHost) | 600 OnSetZoomLevelForLoadingURL) |
| 601 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) | 601 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) |
| 602 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, | 602 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, |
| 603 OnResetPageEncodingToDefault) | 603 OnResetPageEncodingToDefault) |
| 604 IPC_MESSAGE_HANDLER(ViewMsg_SetupDevToolsClient, OnSetupDevToolsClient) | 604 IPC_MESSAGE_HANDLER(ViewMsg_SetupDevToolsClient, OnSetupDevToolsClient) |
| 605 IPC_MESSAGE_HANDLER(ViewMsg_DownloadFavIcon, OnDownloadFavIcon) | 605 IPC_MESSAGE_HANDLER(ViewMsg_DownloadFavIcon, OnDownloadFavIcon) |
| 606 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) | 606 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) |
| 607 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) | 607 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) |
| 608 IPC_MESSAGE_HANDLER(ViewMsg_AddMessageToConsole, OnAddMessageToConsole) | 608 IPC_MESSAGE_HANDLER(ViewMsg_AddMessageToConsole, OnAddMessageToConsole) |
| 609 IPC_MESSAGE_HANDLER(ViewMsg_ReservePageIDRange, OnReservePageIDRange) | 609 IPC_MESSAGE_HANDLER(ViewMsg_ReservePageIDRange, OnReservePageIDRange) |
| 610 IPC_MESSAGE_HANDLER(ViewMsg_FillPasswordForm, OnFillPasswordForm) | 610 IPC_MESSAGE_HANDLER(ViewMsg_FillPasswordForm, OnFillPasswordForm) |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 | 1228 |
| 1229 // Clear "block" flags for the new page. This needs to happen before any of | 1229 // Clear "block" flags for the new page. This needs to happen before any of |
| 1230 // allowScripts(), allowImages(), allowPlugins() is called for the new page | 1230 // allowScripts(), allowImages(), allowPlugins() is called for the new page |
| 1231 // so that these functions can correctly detect that a piece of content | 1231 // so that these functions can correctly detect that a piece of content |
| 1232 // flipped from "not blocked" to "blocked". | 1232 // flipped from "not blocked" to "blocked". |
| 1233 ClearBlockedContentSettings(); | 1233 ClearBlockedContentSettings(); |
| 1234 | 1234 |
| 1235 // Set content settings. Default them from the parent window if one exists. | 1235 // Set content settings. Default them from the parent window if one exists. |
| 1236 // This makes sure about:blank windows work as expected. | 1236 // This makes sure about:blank windows work as expected. |
| 1237 HostContentSettings::iterator host_content_settings = | 1237 HostContentSettings::iterator host_content_settings = |
| 1238 host_content_settings_.find(GURL(request.url()).host()); | 1238 host_content_settings_.find(GURL(request.url())); |
| 1239 if (host_content_settings != host_content_settings_.end()) { | 1239 if (host_content_settings != host_content_settings_.end()) { |
| 1240 SetContentSettings(host_content_settings->second); | 1240 SetContentSettings(host_content_settings->second); |
| 1241 | 1241 |
| 1242 // These content settings were merely recorded transiently for this load. | 1242 // These content settings were merely recorded transiently for this load. |
| 1243 // We can erase them now. If at some point we reload this page, the | 1243 // We can erase them now. If at some point we reload this page, the |
| 1244 // browser will send us new, up-to-date content settings. | 1244 // browser will send us new, up-to-date content settings. |
| 1245 host_content_settings_.erase(host_content_settings); | 1245 host_content_settings_.erase(host_content_settings); |
| 1246 } else if (frame->opener()) { | 1246 } else if (frame->opener()) { |
| 1247 WebView* opener_view = frame->opener()->view(); | 1247 WebView* opener_view = frame->opener()->view(); |
| 1248 RenderView* opener = FromWebView(opener_view); | 1248 RenderView* opener = FromWebView(opener_view); |
| 1249 SetContentSettings(opener->current_content_settings_); | 1249 SetContentSettings(opener->current_content_settings_); |
| 1250 } | 1250 } |
| 1251 | 1251 |
| 1252 // Set zoom level. | 1252 // Set zoom level. |
| 1253 HostZoomLevels::iterator host_zoom = | 1253 HostZoomLevels::iterator host_zoom = |
| 1254 host_zoom_levels_.find(GURL(request.url()).host()); | 1254 host_zoom_levels_.find(GURL(request.url())); |
| 1255 if (host_zoom != host_zoom_levels_.end()) { | 1255 if (host_zoom != host_zoom_levels_.end()) { |
| 1256 webview()->setZoomLevel(false, host_zoom->second); | 1256 webview()->setZoomLevel(false, host_zoom->second); |
| 1257 // This zoom level was merely recorded transiently for this load. We can | 1257 // This zoom level was merely recorded transiently for this load. We can |
| 1258 // erase it now. If at some point we reload this page, the browser will | 1258 // erase it now. If at some point we reload this page, the browser will |
| 1259 // send us a new, up-to-date zoom level. | 1259 // send us a new, up-to-date zoom level. |
| 1260 host_zoom_levels_.erase(host_zoom); | 1260 host_zoom_levels_.erase(host_zoom); |
| 1261 } | 1261 } |
| 1262 | 1262 |
| 1263 // Update contents MIME type for main frame. | 1263 // Update contents MIME type for main frame. |
| 1264 params.contents_mime_type = ds->response().mimeType().utf8(); | 1264 params.contents_mime_type = ds->response().mimeType().utf8(); |
| (...skipping 2324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3589 return; | 3589 return; |
| 3590 } | 3590 } |
| 3591 delegate->Zoom(zoom); | 3591 delegate->Zoom(zoom); |
| 3592 return; | 3592 return; |
| 3593 } | 3593 } |
| 3594 | 3594 |
| 3595 int zoom_level = webview()->zoomLevel(); | 3595 int zoom_level = webview()->zoomLevel(); |
| 3596 int new_zoom_level = webview()->setZoomLevel(false, | 3596 int new_zoom_level = webview()->setZoomLevel(false, |
| 3597 (function == PageZoom::RESET) ? 0 : (zoom_level + function)); | 3597 (function == PageZoom::RESET) ? 0 : (zoom_level + function)); |
| 3598 | 3598 |
| 3599 // Tell the browser which host got zoomed so it can update the saved values. | 3599 // Tell the browser which url got zoomed so it can update the saved values. |
| 3600 // Pages like the safe browsing interstitial can have empty hosts; don't | 3600 Send(new ViewHostMsg_DidZoomURL( |
| 3601 // record those. | 3601 GURL(webview()->mainFrame()->url()), new_zoom_level)); |
| 3602 std::string host(GURL(webview()->mainFrame()->url()).host()); | |
| 3603 if (!host.empty()) | |
| 3604 Send(new ViewHostMsg_DidZoomHost(host, new_zoom_level)); | |
| 3605 } | 3602 } |
| 3606 | 3603 |
| 3607 void RenderView::OnSetContentSettingsForLoadingHost( | 3604 void RenderView::OnSetContentSettingsForLoadingURL( |
| 3608 std::string host, | 3605 const GURL& url, |
| 3609 const ContentSettings& content_settings) { | 3606 const ContentSettings& content_settings) { |
| 3610 host_content_settings_[host] = content_settings; | 3607 host_content_settings_[url] = content_settings; |
| 3611 } | 3608 } |
| 3612 | 3609 |
| 3613 void RenderView::OnSetZoomLevelForLoadingHost(std::string host, | 3610 void RenderView::OnSetZoomLevelForLoadingURL(const GURL& url, |
| 3614 int zoom_level) { | 3611 int zoom_level) { |
| 3615 host_zoom_levels_[host] = zoom_level; | 3612 host_zoom_levels_[url] = zoom_level; |
| 3616 } | 3613 } |
| 3617 | 3614 |
| 3618 void RenderView::OnSetPageEncoding(const std::string& encoding_name) { | 3615 void RenderView::OnSetPageEncoding(const std::string& encoding_name) { |
| 3619 webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); | 3616 webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); |
| 3620 } | 3617 } |
| 3621 | 3618 |
| 3622 void RenderView::OnResetPageEncodingToDefault() { | 3619 void RenderView::OnResetPageEncodingToDefault() { |
| 3623 WebString no_encoding; | 3620 WebString no_encoding; |
| 3624 webview()->setPageEncoding(no_encoding); | 3621 webview()->setPageEncoding(no_encoding); |
| 3625 } | 3622 } |
| (...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4966 | 4963 |
| 4967 if (last_top_level_navigation_page_id_ != page_id_ && | 4964 if (last_top_level_navigation_page_id_ != page_id_ && |
| 4968 // Not interested in reloads. | 4965 // Not interested in reloads. |
| 4969 type != WebKit::WebNavigationTypeReload && | 4966 type != WebKit::WebNavigationTypeReload && |
| 4970 type != WebKit::WebNavigationTypeFormSubmitted) { | 4967 type != WebKit::WebNavigationTypeFormSubmitted) { |
| 4971 return true; | 4968 return true; |
| 4972 } | 4969 } |
| 4973 } | 4970 } |
| 4974 return false; | 4971 return false; |
| 4975 } | 4972 } |
| OLD | NEW |