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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 const int64 kLongIdleHandlerDelayMs = 30*1000; | 134 const int64 kLongIdleHandlerDelayMs = 30*1000; |
135 const int kIdleCPUUsageThresholdInPercents = 3; | 135 const int kIdleCPUUsageThresholdInPercents = 3; |
136 | 136 |
137 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access | 137 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access |
138 // incorrectly from the wrong thread. | 138 // incorrectly from the wrong thread. |
139 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > | 139 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > |
140 lazy_tls = LAZY_INSTANCE_INITIALIZER; | 140 lazy_tls = LAZY_INSTANCE_INITIALIZER; |
141 | 141 |
142 class RenderViewZoomer : public RenderViewVisitor { | 142 class RenderViewZoomer : public RenderViewVisitor { |
143 public: | 143 public: |
144 RenderViewZoomer(const std::string& host, double zoom_level) | 144 RenderViewZoomer(const std::string& scheme, |
145 : host_(host), zoom_level_(zoom_level) { | 145 const std::string& host, |
| 146 double zoom_level) |
| 147 : scheme_(scheme), host_(host), zoom_level_(zoom_level) { |
146 } | 148 } |
147 | 149 |
148 virtual bool Visit(RenderView* render_view) { | 150 virtual bool Visit(RenderView* render_view) { |
149 WebView* webview = render_view->GetWebView(); | 151 WebView* webview = render_view->GetWebView(); |
150 WebDocument document = webview->mainFrame()->document(); | 152 WebDocument document = webview->mainFrame()->document(); |
151 | 153 |
152 // Don't set zoom level for full-page plugin since they don't use the same | 154 // Don't set zoom level for full-page plugin since they don't use the same |
153 // zoom settings. | 155 // zoom settings. |
154 if (document.isPluginDocument()) | 156 if (document.isPluginDocument()) |
155 return true; | 157 return true; |
156 | 158 GURL url(document.url()); |
157 if (net::GetHostOrSpecFromURL(GURL(document.url())) == host_) | 159 if ((net::GetHostOrSpecFromURL(url) == host_) && |
| 160 (scheme_.empty() || scheme_ == url.scheme())) { |
158 webview->setZoomLevel(false, zoom_level_); | 161 webview->setZoomLevel(false, zoom_level_); |
| 162 } |
159 return true; | 163 return true; |
160 } | 164 } |
161 | 165 |
162 private: | 166 private: |
| 167 std::string scheme_; |
163 std::string host_; | 168 std::string host_; |
164 double zoom_level_; | 169 double zoom_level_; |
165 | 170 |
166 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); | 171 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); |
167 }; | 172 }; |
168 | 173 |
169 std::string HostToCustomHistogramSuffix(const std::string& host) { | 174 std::string HostToCustomHistogramSuffix(const std::string& host) { |
170 if (host == "mail.google.com") | 175 if (host == "mail.google.com") |
171 return ".gmail"; | 176 return ".gmail"; |
172 if (host == "docs.google.com" || host == "drive.google.com") | 177 if (host == "docs.google.com" || host == "drive.google.com") |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 } | 1004 } |
1000 | 1005 |
1001 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { | 1006 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { |
1002 suspend_webkit_shared_timer_ = false; | 1007 suspend_webkit_shared_timer_ = false; |
1003 } | 1008 } |
1004 | 1009 |
1005 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { | 1010 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { |
1006 notify_webkit_of_modal_loop_ = false; | 1011 notify_webkit_of_modal_loop_ = false; |
1007 } | 1012 } |
1008 | 1013 |
1009 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& host, | 1014 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme, |
| 1015 const std::string& host, |
1010 double zoom_level) { | 1016 double zoom_level) { |
1011 RenderViewZoomer zoomer(host, zoom_level); | 1017 RenderViewZoomer zoomer(scheme, host, zoom_level); |
1012 RenderView::ForEach(&zoomer); | 1018 RenderView::ForEach(&zoomer); |
1013 } | 1019 } |
1014 | 1020 |
1015 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 1021 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
1016 ObserverListBase<RenderProcessObserver>::Iterator it(observers_); | 1022 ObserverListBase<RenderProcessObserver>::Iterator it(observers_); |
1017 RenderProcessObserver* observer; | 1023 RenderProcessObserver* observer; |
1018 while ((observer = it.GetNext()) != NULL) { | 1024 while ((observer = it.GetNext()) != NULL) { |
1019 if (observer->OnControlMessageReceived(msg)) | 1025 if (observer->OnControlMessageReceived(msg)) |
1020 return true; | 1026 return true; |
1021 } | 1027 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 RenderThreadImpl::GetFileThreadMessageLoopProxy() { | 1166 RenderThreadImpl::GetFileThreadMessageLoopProxy() { |
1161 DCHECK(message_loop() == MessageLoop::current()); | 1167 DCHECK(message_loop() == MessageLoop::current()); |
1162 if (!file_thread_.get()) { | 1168 if (!file_thread_.get()) { |
1163 file_thread_.reset(new base::Thread("Renderer::FILE")); | 1169 file_thread_.reset(new base::Thread("Renderer::FILE")); |
1164 file_thread_->Start(); | 1170 file_thread_->Start(); |
1165 } | 1171 } |
1166 return file_thread_->message_loop_proxy(); | 1172 return file_thread_->message_loop_proxy(); |
1167 } | 1173 } |
1168 | 1174 |
1169 } // namespace content | 1175 } // namespace content |
OLD | NEW |