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

Side by Side Diff: chrome/renderer/render_view.cc

Issue 437077: Remember zoom on a per-host basis.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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
« no previous file with comments | « chrome/renderer/render_view.h ('k') | chrome/test/testing_profile.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if defined(ENABLE_PEPPER) 5 #if defined(ENABLE_PEPPER)
6 #define PEPPER_APIS_ENABLED 6 #define PEPPER_APIS_ENABLED
7 #endif 7 #endif
8 8
9 #include "chrome/renderer/render_view.h" 9 #include "chrome/renderer/render_view.h"
10 10
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 IPC_MESSAGE_HANDLER(ViewMsg_AdvanceToNextMisspelling, 429 IPC_MESSAGE_HANDLER(ViewMsg_AdvanceToNextMisspelling,
430 OnAdvanceToNextMisspelling) 430 OnAdvanceToNextMisspelling)
431 IPC_MESSAGE_HANDLER(ViewMsg_ToggleSpellCheck, OnToggleSpellCheck) 431 IPC_MESSAGE_HANDLER(ViewMsg_ToggleSpellCheck, OnToggleSpellCheck)
432 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) 432 IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete)
433 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) 433 IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll)
434 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) 434 IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt)
435 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) 435 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand)
436 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) 436 IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind)
437 IPC_MESSAGE_HANDLER(ViewMsg_DeterminePageText, OnDeterminePageText) 437 IPC_MESSAGE_HANDLER(ViewMsg_DeterminePageText, OnDeterminePageText)
438 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) 438 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
439 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingHost,
440 OnSetZoomLevelForLoadingHost)
439 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) 441 IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding)
440 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, 442 IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault,
441 OnResetPageEncodingToDefault) 443 OnResetPageEncodingToDefault)
442 IPC_MESSAGE_HANDLER(ViewMsg_SetupDevToolsClient, OnSetupDevToolsClient) 444 IPC_MESSAGE_HANDLER(ViewMsg_SetupDevToolsClient, OnSetupDevToolsClient)
443 IPC_MESSAGE_HANDLER(ViewMsg_DownloadFavIcon, OnDownloadFavIcon) 445 IPC_MESSAGE_HANDLER(ViewMsg_DownloadFavIcon, OnDownloadFavIcon)
444 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) 446 IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest)
445 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) 447 IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest)
446 IPC_MESSAGE_HANDLER(ViewMsg_AddMessageToConsole, OnAddMessageToConsole) 448 IPC_MESSAGE_HANDLER(ViewMsg_AddMessageToConsole, OnAddMessageToConsole)
447 IPC_MESSAGE_HANDLER(ViewMsg_ReservePageIDRange, OnReservePageIDRange) 449 IPC_MESSAGE_HANDLER(ViewMsg_ReservePageIDRange, OnReservePageIDRange)
448 IPC_MESSAGE_HANDLER(ViewMsg_FormFill, OnFormFill) 450 IPC_MESSAGE_HANDLER(ViewMsg_FormFill, OnFormFill)
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 navigation_state->password_form_data(); 1038 navigation_state->password_form_data();
1037 if (password_form_data) 1039 if (password_form_data)
1038 params.password_form = *password_form_data; 1040 params.password_form = *password_form_data;
1039 1041
1040 params.gesture = navigation_gesture_; 1042 params.gesture = navigation_gesture_;
1041 navigation_gesture_ = NavigationGestureUnknown; 1043 navigation_gesture_ = NavigationGestureUnknown;
1042 1044
1043 if (!frame->parent()) { 1045 if (!frame->parent()) {
1044 // Top-level navigation. 1046 // Top-level navigation.
1045 1047
1048 // Set zoom level.
1049 HostZoomLevels::iterator host =
1050 host_zoom_levels_.find(GURL(request.url()).host());
1051 if (host != host_zoom_levels_.end()) {
1052 webview()->setZoomLevel(false, host->second);
1053 // This zoom level was merely recorded transiently for this load. We can
1054 // erase it now. If at some point we reload this page, the browser will
1055 // send us a new, up-to-date zoom level.
1056 host_zoom_levels_.erase(host);
1057 }
1058
1046 // Update contents MIME type for main frame. 1059 // Update contents MIME type for main frame.
1047 params.contents_mime_type = ds->response().mimeType().utf8(); 1060 params.contents_mime_type = ds->response().mimeType().utf8();
1048 1061
1049 params.transition = navigation_state->transition_type(); 1062 params.transition = navigation_state->transition_type();
1050 if (!PageTransition::IsMainFrame(params.transition)) { 1063 if (!PageTransition::IsMainFrame(params.transition)) {
1051 // If the main frame does a load, it should not be reported as a subframe 1064 // If the main frame does a load, it should not be reported as a subframe
1052 // navigation. This can occur in the following case: 1065 // navigation. This can occur in the following case:
1053 // 1. You're on a site with frames. 1066 // 1. You're on a site with frames.
1054 // 2. You do a subframe navigation. This is stored with transition type 1067 // 2. You do a subframe navigation. This is stored with transition type
1055 // MANUAL_SUBFRAME. 1068 // MANUAL_SUBFRAME.
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 // Received a redirect on the main frame. 2138 // Received a redirect on the main frame.
2126 WebDataSource* data_source = frame->provisionalDataSource(); 2139 WebDataSource* data_source = frame->provisionalDataSource();
2127 if (!data_source) { 2140 if (!data_source) {
2128 // Should only be invoked when we have a data source. 2141 // Should only be invoked when we have a data source.
2129 NOTREACHED(); 2142 NOTREACHED();
2130 return; 2143 return;
2131 } 2144 }
2132 std::vector<GURL> redirects; 2145 std::vector<GURL> redirects;
2133 GetRedirectChain(data_source, &redirects); 2146 GetRedirectChain(data_source, &redirects);
2134 if (redirects.size() >= 2) { 2147 if (redirects.size() >= 2) {
2135 Send(new ViewHostMsg_DidRedirectProvisionalLoad( 2148 Send(new ViewHostMsg_DidRedirectProvisionalLoad(routing_id_, page_id_,
2136 routing_id_, page_id_, redirects[redirects.size() - 2], 2149 redirects[redirects.size() - 2], redirects.back()));
2137 redirects[redirects.size() - 1]));
2138 } 2150 }
2139 } 2151 }
2140 2152
2141 void RenderView::didFailProvisionalLoad( 2153 void RenderView::didFailProvisionalLoad(WebFrame* frame,
2142 WebFrame* frame, const WebURLError& error) { 2154 const WebURLError& error) {
2143 // Notify the browser that we failed a provisional load with an error. 2155 // Notify the browser that we failed a provisional load with an error.
2144 // 2156 //
2145 // Note: It is important this notification occur before DidStopLoading so the 2157 // Note: It is important this notification occur before DidStopLoading so the
2146 // SSL manager can react to the provisional load failure before being 2158 // SSL manager can react to the provisional load failure before being
2147 // notified the load stopped. 2159 // notified the load stopped.
2148 // 2160 //
2149 WebDataSource* ds = frame->provisionalDataSource(); 2161 WebDataSource* ds = frame->provisionalDataSource();
2150 DCHECK(ds); 2162 DCHECK(ds);
2151 2163
2152 const WebURLRequest& failed_request = ds->request(); 2164 const WebURLRequest& failed_request = ds->request();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 // grows too large, then we'll just let it through. 2225 // grows too large, then we'll just let it through.
2214 navigation_state->append_postponed_data(data, data_len); 2226 navigation_state->append_postponed_data(data, data_len);
2215 if (navigation_state->postponed_data().size() >= 512) { 2227 if (navigation_state->postponed_data().size() >= 512) {
2216 navigation_state->set_postpone_loading_data(false); 2228 navigation_state->set_postpone_loading_data(false);
2217 frame->commitDocumentData(navigation_state->postponed_data().data(), 2229 frame->commitDocumentData(navigation_state->postponed_data().data(),
2218 navigation_state->postponed_data().size()); 2230 navigation_state->postponed_data().size());
2219 navigation_state->clear_postponed_data(); 2231 navigation_state->clear_postponed_data();
2220 } 2232 }
2221 } 2233 }
2222 2234
2223 void RenderView::didCommitProvisionalLoad( 2235 void RenderView::didCommitProvisionalLoad(WebFrame* frame,
2224 WebFrame* frame, bool is_new_navigation) { 2236 bool is_new_navigation) {
2225 NavigationState* navigation_state = 2237 NavigationState* navigation_state =
2226 NavigationState::FromDataSource(frame->dataSource()); 2238 NavigationState::FromDataSource(frame->dataSource());
2227 2239
2228 navigation_state->set_commit_load_time(Time::Now()); 2240 navigation_state->set_commit_load_time(Time::Now());
2229 if (is_new_navigation) { 2241 if (is_new_navigation) {
2230 // When we perform a new navigation, we need to update the previous session 2242 // When we perform a new navigation, we need to update the previous session
2231 // history entry with state for the page we are leaving. 2243 // history entry with state for the page we are leaving.
2232 UpdateSessionHistory(frame); 2244 UpdateSessionHistory(frame);
2233 2245
2234 // We bump our Page ID to correspond with the new session history entry. 2246 // We bump our Page ID to correspond with the new session history entry.
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
2956 2968
2957 // We set |determine_page_text_after_loading_stops_| true here so that, 2969 // We set |determine_page_text_after_loading_stops_| true here so that,
2958 // after page has been loaded completely, the text in the page is captured. 2970 // after page has been loaded completely, the text in the page is captured.
2959 determine_page_text_after_loading_stops_ = true; 2971 determine_page_text_after_loading_stops_ = true;
2960 } 2972 }
2961 2973
2962 void RenderView::DnsPrefetch(const std::vector<std::string>& host_names) { 2974 void RenderView::DnsPrefetch(const std::vector<std::string>& host_names) {
2963 Send(new ViewHostMsg_DnsPrefetch(host_names)); 2975 Send(new ViewHostMsg_DnsPrefetch(host_names));
2964 } 2976 }
2965 2977
2966 void RenderView::OnZoom(int function) { 2978 void RenderView::OnZoom(PageZoom::Function function) {
2967 static const bool kZoomIsTextOnly = false; 2979 if (!webview()) // Not sure if this can happen, but no harm in being safe.
2968 switch (function) { 2980 return;
2969 case PageZoom::SMALLER: 2981
2970 webview()->zoomOut(kZoomIsTextOnly); 2982 int zoom_level = webview()->zoomLevel();
2971 break; 2983 int new_zoom_level = webview()->setZoomLevel(false,
2972 case PageZoom::STANDARD: 2984 (function == PageZoom::RESET) ? 0 : (zoom_level + function));
2973 webview()->zoomDefault(); 2985
2974 break; 2986 // Tell the browser which host got zoomed so it can update the saved values.
2975 case PageZoom::LARGER: 2987 // Pages like the safe browsing interstitial can have empty hosts; don't
2976 webview()->zoomIn(kZoomIsTextOnly); 2988 // record those.
2977 break; 2989 std::string host(GURL(webview()->mainFrame()->url()).host());
2978 default: 2990 if (!host.empty())
2979 NOTREACHED(); 2991 Send(new ViewHostMsg_DidZoomHost(host, new_zoom_level));
2980 } 2992 }
2993
2994 void RenderView::OnSetZoomLevelForLoadingHost(std::string host,
2995 int zoom_level) {
2996 host_zoom_levels_[host] = zoom_level;
2981 } 2997 }
2982 2998
2983 void RenderView::OnSetPageEncoding(const std::string& encoding_name) { 2999 void RenderView::OnSetPageEncoding(const std::string& encoding_name) {
2984 webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); 3000 webview()->setPageEncoding(WebString::fromUTF8(encoding_name));
2985 } 3001 }
2986 3002
2987 void RenderView::OnResetPageEncodingToDefault() { 3003 void RenderView::OnResetPageEncodingToDefault() {
2988 WebString no_encoding; 3004 WebString no_encoding;
2989 webview()->setPageEncoding(no_encoding); 3005 webview()->setPageEncoding(no_encoding);
2990 } 3006 }
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
3862 new PluginMsg_SignalModalDialogEvent(host_window_)); 3878 new PluginMsg_SignalModalDialogEvent(host_window_));
3863 3879
3864 message->EnableMessagePumping(); // Runs a nested message loop. 3880 message->EnableMessagePumping(); // Runs a nested message loop.
3865 bool rv = Send(message); 3881 bool rv = Send(message);
3866 3882
3867 PluginChannelHost::Broadcast( 3883 PluginChannelHost::Broadcast(
3868 new PluginMsg_ResetModalDialogEvent(host_window_)); 3884 new PluginMsg_ResetModalDialogEvent(host_window_));
3869 3885
3870 return rv; 3886 return rv;
3871 } 3887 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.h ('k') | chrome/test/testing_profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698