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, |
sky
2013/02/11 17:13:26
align with '(' on previous line (same comment for
Denis Kuznetsov (DE-MUC)
2013/02/12 13:10:45
Done.
| |
146 double zoom_level) | |
147 : scheme_(scheme), host_(host), zoom_level_(zoom_level) { | |
sky
2013/02/11 17:13:26
since the constructor doesn't fit on one line each
Denis Kuznetsov (DE-MUC)
2013/02/12 13:10:45
Done.
| |
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())) { | |
sky
2013/02/11 17:13:26
Why the empty() check?
Denis Kuznetsov (DE-MUC)
2013/02/12 13:10:45
We use same message for SetForHost and SetForHostA
| |
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_; | |
sky
2013/02/11 17:13:26
const on these.
Denis Kuznetsov (DE-MUC)
2013/02/12 13:10:45
Done.
| |
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 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1017 } | 1022 } |
1018 | 1023 |
1019 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { | 1024 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { |
1020 suspend_webkit_shared_timer_ = false; | 1025 suspend_webkit_shared_timer_ = false; |
1021 } | 1026 } |
1022 | 1027 |
1023 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { | 1028 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { |
1024 notify_webkit_of_modal_loop_ = false; | 1029 notify_webkit_of_modal_loop_ = false; |
1025 } | 1030 } |
1026 | 1031 |
1027 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& host, | 1032 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme, |
1033 const std::string& host, | |
1028 double zoom_level) { | 1034 double zoom_level) { |
1029 RenderViewZoomer zoomer(host, zoom_level); | 1035 RenderViewZoomer zoomer(scheme, host, zoom_level); |
1030 RenderView::ForEach(&zoomer); | 1036 RenderView::ForEach(&zoomer); |
1031 } | 1037 } |
1032 | 1038 |
1033 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 1039 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
1034 ObserverListBase<RenderProcessObserver>::Iterator it(observers_); | 1040 ObserverListBase<RenderProcessObserver>::Iterator it(observers_); |
1035 RenderProcessObserver* observer; | 1041 RenderProcessObserver* observer; |
1036 while ((observer = it.GetNext()) != NULL) { | 1042 while ((observer = it.GetNext()) != NULL) { |
1037 if (observer->OnControlMessageReceived(msg)) | 1043 if (observer->OnControlMessageReceived(msg)) |
1038 return true; | 1044 return true; |
1039 } | 1045 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1184 RenderThreadImpl::GetFileThreadMessageLoopProxy() { | 1190 RenderThreadImpl::GetFileThreadMessageLoopProxy() { |
1185 DCHECK(message_loop() == MessageLoop::current()); | 1191 DCHECK(message_loop() == MessageLoop::current()); |
1186 if (!file_thread_.get()) { | 1192 if (!file_thread_.get()) { |
1187 file_thread_.reset(new base::Thread("Renderer::FILE")); | 1193 file_thread_.reset(new base::Thread("Renderer::FILE")); |
1188 file_thread_->Start(); | 1194 file_thread_->Start(); |
1189 } | 1195 } |
1190 return file_thread_->message_loop_proxy(); | 1196 return file_thread_->message_loop_proxy(); |
1191 } | 1197 } |
1192 | 1198 |
1193 } // namespace content | 1199 } // namespace content |
OLD | NEW |