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

Side by Side Diff: chrome/renderer/render_thread.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_thread.h ('k') | chrome/renderer/render_view.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 #include "chrome/renderer/render_thread.h" 5 #include "chrome/renderer/render_thread.h"
6 6
7 #include <v8.h> 7 #include <v8.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "chrome/renderer/extension_groups.h" 43 #include "chrome/renderer/extension_groups.h"
44 #include "chrome/renderer/extensions/event_bindings.h" 44 #include "chrome/renderer/extensions/event_bindings.h"
45 #include "chrome/renderer/extensions/extension_process_bindings.h" 45 #include "chrome/renderer/extensions/extension_process_bindings.h"
46 #include "chrome/renderer/extensions/js_only_v8_extensions.h" 46 #include "chrome/renderer/extensions/js_only_v8_extensions.h"
47 #include "chrome/renderer/extensions/renderer_extension_bindings.h" 47 #include "chrome/renderer/extensions/renderer_extension_bindings.h"
48 #include "chrome/renderer/external_extension.h" 48 #include "chrome/renderer/external_extension.h"
49 #include "chrome/renderer/loadtimes_extension_bindings.h" 49 #include "chrome/renderer/loadtimes_extension_bindings.h"
50 #include "chrome/renderer/net/render_dns_master.h" 50 #include "chrome/renderer/net/render_dns_master.h"
51 #include "chrome/renderer/render_process.h" 51 #include "chrome/renderer/render_process.h"
52 #include "chrome/renderer/render_view.h" 52 #include "chrome/renderer/render_view.h"
53 #include "chrome/renderer/render_view_visitor.h"
53 #include "chrome/renderer/renderer_webkitclient_impl.h" 54 #include "chrome/renderer/renderer_webkitclient_impl.h"
54 #include "chrome/renderer/renderer_web_database_observer.h" 55 #include "chrome/renderer/renderer_web_database_observer.h"
55 #include "chrome/renderer/socket_stream_dispatcher.h" 56 #include "chrome/renderer/socket_stream_dispatcher.h"
56 #include "chrome/renderer/spellchecker/spellcheck.h" 57 #include "chrome/renderer/spellchecker/spellcheck.h"
57 #include "chrome/renderer/user_script_slave.h" 58 #include "chrome/renderer/user_script_slave.h"
58 #include "ipc/ipc_message.h" 59 #include "ipc/ipc_message.h"
59 #include "ipc/ipc_platform_file.h" 60 #include "ipc/ipc_platform_file.h"
60 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" 61 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h"
61 #include "third_party/WebKit/WebKit/chromium/public/WebCache.h" 62 #include "third_party/WebKit/WebKit/chromium/public/WebCache.h"
62 #include "third_party/WebKit/WebKit/chromium/public/WebColor.h" 63 #include "third_party/WebKit/WebKit/chromium/public/WebColor.h"
63 #include "third_party/WebKit/WebKit/chromium/public/WebCrossOriginPreflightResul tCache.h" 64 #include "third_party/WebKit/WebKit/chromium/public/WebCrossOriginPreflightResul tCache.h"
64 #include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h" 65 #include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h"
65 #include "third_party/WebKit/WebKit/chromium/public/WebFontCache.h" 66 #include "third_party/WebKit/WebKit/chromium/public/WebFontCache.h"
67 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
66 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" 68 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h"
67 #include "third_party/WebKit/WebKit/chromium/public/WebRuntimeFeatures.h" 69 #include "third_party/WebKit/WebKit/chromium/public/WebRuntimeFeatures.h"
68 #include "third_party/WebKit/WebKit/chromium/public/WebScriptController.h" 70 #include "third_party/WebKit/WebKit/chromium/public/WebScriptController.h"
69 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h" 71 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h"
70 #include "third_party/WebKit/WebKit/chromium/public/WebStorageEventDispatcher.h" 72 #include "third_party/WebKit/WebKit/chromium/public/WebStorageEventDispatcher.h"
71 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" 73 #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
72 #include "webkit/extensions/v8/benchmarking_extension.h" 74 #include "webkit/extensions/v8/benchmarking_extension.h"
73 #include "webkit/extensions/v8/gears_extension.h" 75 #include "webkit/extensions/v8/gears_extension.h"
74 #include "webkit/extensions/v8/interval_extension.h" 76 #include "webkit/extensions/v8/interval_extension.h"
75 #include "webkit/extensions/v8/playback_extension.h" 77 #include "webkit/extensions/v8/playback_extension.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // large window where a browser failure (or a user, manually terminating 112 // large window where a browser failure (or a user, manually terminating
111 // the browser because "it's stuck") will leave behind a process eating all 113 // the browser because "it's stuck") will leave behind a process eating all
112 // the CPU. 114 // the CPU.
113 // 115 //
114 // So, we install a filter on the channel so that we can process this event 116 // So, we install a filter on the channel so that we can process this event
115 // here and kill the process. 117 // here and kill the process.
116 _exit(0); 118 _exit(0);
117 } 119 }
118 }; 120 };
119 #endif 121 #endif
122
123 class RenderViewZoomer : public RenderViewVisitor {
124 public:
125 RenderViewZoomer(const std::string& host, int zoom_level)
126 : host_(host),
127 zoom_level_(zoom_level) {
128 }
129
130 virtual bool Visit(RenderView* render_view) {
131 WebView* webview = render_view->webview(); // Guaranteed non-NULL.
132 if (GURL(webview->mainFrame()->url()).host() == host_)
133 webview->setZoomLevel(false, zoom_level_);
134 return true;
135 }
136
137 private:
138 std::string host_;
139 int zoom_level_;
140
141 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer);
142 };
120 } // namespace 143 } // namespace
121 144
122 // When we run plugins in process, we actually run them on the render thread, 145 // When we run plugins in process, we actually run them on the render thread,
123 // which means that we need to make the render thread pump UI events. 146 // which means that we need to make the render thread pump UI events.
124 RenderThread::RenderThread() { 147 RenderThread::RenderThread() {
125 Init(); 148 Init();
126 } 149 }
127 150
128 RenderThread::RenderThread(const std::string& channel_name) 151 RenderThread::RenderThread(const std::string& channel_name)
129 : ChildThread(channel_name) { 152 : ChildThread(channel_name) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 void RenderThread::OnAddVisitedLinks( 259 void RenderThread::OnAddVisitedLinks(
237 const VisitedLinkSlave::Fingerprints& fingerprints) { 260 const VisitedLinkSlave::Fingerprints& fingerprints) {
238 for (size_t i = 0; i < fingerprints.size(); ++i) 261 for (size_t i = 0; i < fingerprints.size(); ++i)
239 WebView::updateVisitedLinkState(fingerprints[i]); 262 WebView::updateVisitedLinkState(fingerprints[i]);
240 } 263 }
241 264
242 void RenderThread::OnResetVisitedLinks() { 265 void RenderThread::OnResetVisitedLinks() {
243 WebView::resetVisitedLinkState(); 266 WebView::resetVisitedLinkState();
244 } 267 }
245 268
269 void RenderThread::OnSetZoomLevelForCurrentHost(const std::string& host,
270 int zoom_level) {
271 RenderViewZoomer zoomer(host, zoom_level);
272 RenderView::ForEach(&zoomer);
273 }
274
246 void RenderThread::OnUpdateUserScripts( 275 void RenderThread::OnUpdateUserScripts(
247 base::SharedMemoryHandle scripts) { 276 base::SharedMemoryHandle scripts) {
248 DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle"; 277 DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle";
249 user_script_slave_->UpdateScripts(scripts); 278 user_script_slave_->UpdateScripts(scripts);
250 } 279 }
251 280
252 void RenderThread::OnSetExtensionFunctionNames( 281 void RenderThread::OnSetExtensionFunctionNames(
253 const std::vector<std::string>& names) { 282 const std::vector<std::string>& names) {
254 ExtensionProcessBindings::SetFunctionNames(names); 283 ExtensionProcessBindings::SetFunctionNames(names);
255 } 284 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 // App cache messages are handled by a delegate. 319 // App cache messages are handled by a delegate.
291 if (appcache_dispatcher_->OnMessageReceived(msg)) 320 if (appcache_dispatcher_->OnMessageReceived(msg))
292 return; 321 return;
293 if (socket_stream_dispatcher_->OnMessageReceived(msg)) 322 if (socket_stream_dispatcher_->OnMessageReceived(msg))
294 return; 323 return;
295 324
296 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) 325 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg)
297 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks) 326 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks)
298 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Add, OnAddVisitedLinks) 327 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Add, OnAddVisitedLinks)
299 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Reset, OnResetVisitedLinks) 328 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Reset, OnResetVisitedLinks)
329 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentHost,
330 OnSetZoomLevelForCurrentHost)
300 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) 331 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID)
301 IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors) 332 IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors)
302 // TODO(port): removed from render_messages_internal.h; 333 // TODO(port): removed from render_messages_internal.h;
303 // is there a new non-windows message I should add here? 334 // is there a new non-windows message I should add here?
304 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) 335 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView)
305 IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities) 336 IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities)
306 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererHistograms, 337 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererHistograms,
307 OnGetRendererHistograms) 338 OnGetRendererHistograms)
308 #if defined(USE_TCMALLOC) 339 #if defined(USE_TCMALLOC)
309 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererTcmalloc, 340 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererTcmalloc,
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 spellchecker_->EnableAutoSpellCorrect(auto_spell_correct); 686 spellchecker_->EnableAutoSpellCorrect(auto_spell_correct);
656 } 687 }
657 688
658 void RenderThread::OnSpellCheckWordAdded(const std::string& word) { 689 void RenderThread::OnSpellCheckWordAdded(const std::string& word) {
659 spellchecker_->WordAdded(word); 690 spellchecker_->WordAdded(word);
660 } 691 }
661 692
662 void RenderThread::OnSpellCheckEnableAutoSpellCorrect(bool enable) { 693 void RenderThread::OnSpellCheckEnableAutoSpellCorrect(bool enable) {
663 spellchecker_->EnableAutoSpellCorrect(enable); 694 spellchecker_->EnableAutoSpellCorrect(enable);
664 } 695 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_thread.h ('k') | chrome/renderer/render_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698