| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 174 |
| 175 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access | 175 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access |
| 176 // incorrectly from the wrong thread. | 176 // incorrectly from the wrong thread. |
| 177 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > | 177 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > |
| 178 lazy_tls = LAZY_INSTANCE_INITIALIZER; | 178 lazy_tls = LAZY_INSTANCE_INITIALIZER; |
| 179 | 179 |
| 180 class RenderViewZoomer : public RenderViewVisitor { | 180 class RenderViewZoomer : public RenderViewVisitor { |
| 181 public: | 181 public: |
| 182 RenderViewZoomer(const std::string& scheme, | 182 RenderViewZoomer(const std::string& scheme, |
| 183 const std::string& host, | 183 const std::string& host, |
| 184 double zoom_level) : scheme_(scheme), | 184 double zoom_level) |
| 185 host_(host), | 185 : scheme_(scheme), |
| 186 zoom_level_(zoom_level) { | 186 host_(host), |
| 187 } | 187 zoom_level_(zoom_level) {} |
| 188 | 188 |
| 189 virtual bool Visit(RenderView* render_view) OVERRIDE { | 189 virtual bool Visit(RenderView* render_view) OVERRIDE { |
| 190 WebView* webview = render_view->GetWebView(); | 190 WebView* webview = render_view->GetWebView(); |
| 191 WebDocument document = webview->mainFrame()->document(); | 191 WebDocument document = webview->mainFrame()->document(); |
| 192 | 192 |
| 193 // Don't set zoom level for full-page plugin since they don't use the same | 193 // Don't set zoom level for full-page plugin since they don't use the same |
| 194 // zoom settings. | 194 // zoom settings. |
| 195 if (document.isPluginDocument()) | 195 if (document.isPluginDocument()) |
| 196 return true; | 196 return true; |
| 197 GURL url(document.url()); | 197 GURL url(document.url()); |
| 198 // Empty scheme works as wildcard that matches any scheme, | 198 // Empty scheme works as wildcard that matches any scheme, |
| 199 if ((net::GetHostOrSpecFromURL(url) == host_) && | 199 if ((net::GetHostOrSpecFromURL(url) == host_) && |
| 200 (scheme_.empty() || scheme_ == url.scheme())) { | 200 (scheme_.empty() || scheme_ == url.scheme()) && |
| 201 !render_view->UsesTemporaryZoomLevel()) { |
| 201 webview->hidePopups(); | 202 webview->hidePopups(); |
| 202 webview->setZoomLevel(zoom_level_); | 203 webview->setZoomLevel(zoom_level_); |
| 203 } | 204 } |
| 204 return true; | 205 return true; |
| 205 } | 206 } |
| 206 | 207 |
| 207 private: | 208 private: |
| 208 const std::string scheme_; | 209 const std::string scheme_; |
| 209 const std::string host_; | 210 const std::string host_; |
| 210 const double zoom_level_; | 211 const double zoom_level_; |
| (...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 } | 1188 } |
| 1188 | 1189 |
| 1189 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { | 1190 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { |
| 1190 suspend_webkit_shared_timer_ = false; | 1191 suspend_webkit_shared_timer_ = false; |
| 1191 } | 1192 } |
| 1192 | 1193 |
| 1193 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { | 1194 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { |
| 1194 notify_webkit_of_modal_loop_ = false; | 1195 notify_webkit_of_modal_loop_ = false; |
| 1195 } | 1196 } |
| 1196 | 1197 |
| 1197 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme, | 1198 void RenderThreadImpl::OnSetZoomLevelForCurrentURL( |
| 1198 const std::string& host, | 1199 const std::string& scheme, |
| 1199 double zoom_level) { | 1200 const std::string& host, |
| 1201 double zoom_level) { |
| 1200 RenderViewZoomer zoomer(scheme, host, zoom_level); | 1202 RenderViewZoomer zoomer(scheme, host, zoom_level); |
| 1201 RenderView::ForEach(&zoomer); | 1203 RenderView::ForEach(&zoomer); |
| 1202 } | 1204 } |
| 1203 | 1205 |
| 1204 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 1206 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
| 1205 ObserverListBase<RenderProcessObserver>::Iterator it(observers_); | 1207 ObserverListBase<RenderProcessObserver>::Iterator it(observers_); |
| 1206 RenderProcessObserver* observer; | 1208 RenderProcessObserver* observer; |
| 1207 while ((observer = it.GetNext()) != NULL) { | 1209 while ((observer = it.GetNext()) != NULL) { |
| 1208 if (observer->OnControlMessageReceived(msg)) | 1210 if (observer->OnControlMessageReceived(msg)) |
| 1209 return true; | 1211 return true; |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 hidden_widget_count_--; | 1516 hidden_widget_count_--; |
| 1515 | 1517 |
| 1516 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1518 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
| 1517 return; | 1519 return; |
| 1518 } | 1520 } |
| 1519 | 1521 |
| 1520 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1522 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
| 1521 } | 1523 } |
| 1522 | 1524 |
| 1523 } // namespace content | 1525 } // namespace content |
| OLD | NEW |