| 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 const std::set<int>& exceptions) |
| 186 zoom_level_(zoom_level) { | 186 : scheme_(scheme), |
| 187 host_(host), |
| 188 zoom_level_(zoom_level), |
| 189 exceptions_(exceptions) {} |
| 190 |
| 191 bool IsExcepted(RenderView* render_view) { |
| 192 std::set<int>::const_iterator it = |
| 193 exceptions_.find(render_view->GetRoutingID()); |
| 194 return it != exceptions_.end(); |
| 187 } | 195 } |
| 188 | 196 |
| 189 virtual bool Visit(RenderView* render_view) OVERRIDE { | 197 virtual bool Visit(RenderView* render_view) OVERRIDE { |
| 190 WebView* webview = render_view->GetWebView(); | 198 WebView* webview = render_view->GetWebView(); |
| 191 WebDocument document = webview->mainFrame()->document(); | 199 WebDocument document = webview->mainFrame()->document(); |
| 192 | 200 |
| 193 // Don't set zoom level for full-page plugin since they don't use the same | 201 // Don't set zoom level for full-page plugin since they don't use the same |
| 194 // zoom settings. | 202 // zoom settings. |
| 195 if (document.isPluginDocument()) | 203 if (document.isPluginDocument()) |
| 196 return true; | 204 return true; |
| 197 GURL url(document.url()); | 205 GURL url(document.url()); |
| 198 // Empty scheme works as wildcard that matches any scheme, | 206 // Empty scheme works as wildcard that matches any scheme, |
| 199 if ((net::GetHostOrSpecFromURL(url) == host_) && | 207 if ((net::GetHostOrSpecFromURL(url) == host_) && |
| 200 (scheme_.empty() || scheme_ == url.scheme())) { | 208 (scheme_.empty() || scheme_ == url.scheme()) && |
| 209 !IsExcepted(render_view)) { |
| 201 webview->hidePopups(); | 210 webview->hidePopups(); |
| 202 webview->setZoomLevel(zoom_level_); | 211 webview->setZoomLevel(zoom_level_); |
| 203 } | 212 } |
| 204 return true; | 213 return true; |
| 205 } | 214 } |
| 206 | 215 |
| 207 private: | 216 private: |
| 208 const std::string scheme_; | 217 const std::string scheme_; |
| 209 const std::string host_; | 218 const std::string host_; |
| 210 const double zoom_level_; | 219 const double zoom_level_; |
| 220 const std::set<int>& exceptions_; |
| 211 | 221 |
| 212 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); | 222 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); |
| 213 }; | 223 }; |
| 214 | 224 |
| 215 std::string HostToCustomHistogramSuffix(const std::string& host) { | 225 std::string HostToCustomHistogramSuffix(const std::string& host) { |
| 216 if (host == "mail.google.com") | 226 if (host == "mail.google.com") |
| 217 return ".gmail"; | 227 return ".gmail"; |
| 218 if (host == "docs.google.com" || host == "drive.google.com") | 228 if (host == "docs.google.com" || host == "drive.google.com") |
| 219 return ".docs"; | 229 return ".docs"; |
| 220 if (host == "plus.google.com") | 230 if (host == "plus.google.com") |
| (...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 } | 1197 } |
| 1188 | 1198 |
| 1189 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { | 1199 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { |
| 1190 suspend_webkit_shared_timer_ = false; | 1200 suspend_webkit_shared_timer_ = false; |
| 1191 } | 1201 } |
| 1192 | 1202 |
| 1193 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { | 1203 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { |
| 1194 notify_webkit_of_modal_loop_ = false; | 1204 notify_webkit_of_modal_loop_ = false; |
| 1195 } | 1205 } |
| 1196 | 1206 |
| 1197 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme, | 1207 void RenderThreadImpl::OnSetZoomLevelForCurrentURL( |
| 1198 const std::string& host, | 1208 const std::string& scheme, |
| 1199 double zoom_level) { | 1209 const std::string& host, |
| 1200 RenderViewZoomer zoomer(scheme, host, zoom_level); | 1210 double zoom_level, |
| 1211 const std::set<int>& exceptions) { |
| 1212 RenderViewZoomer zoomer(scheme, host, zoom_level, exceptions); |
| 1201 RenderView::ForEach(&zoomer); | 1213 RenderView::ForEach(&zoomer); |
| 1202 } | 1214 } |
| 1203 | 1215 |
| 1204 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 1216 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
| 1205 ObserverListBase<RenderProcessObserver>::Iterator it(observers_); | 1217 ObserverListBase<RenderProcessObserver>::Iterator it(observers_); |
| 1206 RenderProcessObserver* observer; | 1218 RenderProcessObserver* observer; |
| 1207 while ((observer = it.GetNext()) != NULL) { | 1219 while ((observer = it.GetNext()) != NULL) { |
| 1208 if (observer->OnControlMessageReceived(msg)) | 1220 if (observer->OnControlMessageReceived(msg)) |
| 1209 return true; | 1221 return true; |
| 1210 } | 1222 } |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 hidden_widget_count_--; | 1526 hidden_widget_count_--; |
| 1515 | 1527 |
| 1516 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1528 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
| 1517 return; | 1529 return; |
| 1518 } | 1530 } |
| 1519 | 1531 |
| 1520 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1532 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
| 1521 } | 1533 } |
| 1522 | 1534 |
| 1523 } // namespace content | 1535 } // namespace content |
| OLD | NEW |