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

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 224733018: Changes to content/ to facilitate new zoom extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months 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
OLDNEW
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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 const int64 kInitialIdleHandlerDelayMs = 1000; 167 const int64 kInitialIdleHandlerDelayMs = 1000;
168 const int64 kShortIdleHandlerDelayMs = 1000; 168 const int64 kShortIdleHandlerDelayMs = 1000;
169 const int64 kLongIdleHandlerDelayMs = 30*1000; 169 const int64 kLongIdleHandlerDelayMs = 30*1000;
170 const int kIdleCPUUsageThresholdInPercents = 3; 170 const int kIdleCPUUsageThresholdInPercents = 3;
171 const int kMinRasterThreads = 1; 171 const int kMinRasterThreads = 1;
172 const int kMaxRasterThreads = 64; 172 const int kMaxRasterThreads = 64;
173 173
174 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access 174 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access
175 // incorrectly from the wrong thread. 175 // incorrectly from the wrong thread.
176 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > 176 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> >
177 lazy_tls = LAZY_INSTANCE_INITIALIZER; 177 lazy_tls = LAZY_INSTANCE_INITIALIZER;
178 178
179 class RenderViewZoomer : public RenderViewVisitor { 179 class RenderViewZoomer : public RenderViewVisitor {
180 public: 180 public:
181 RenderViewZoomer(const std::string& scheme, 181 RenderViewZoomer(const std::string& scheme,
182 const std::string& host, 182 const std::string& host,
183 double zoom_level) : scheme_(scheme), 183 double zoom_level,
184 host_(host), 184 const std::set<int>& exceptions)
185 zoom_level_(zoom_level) { 185 : scheme_(scheme),
186 } 186 host_(host),
187 zoom_level_(zoom_level),
188 exceptions_(exceptions) {}
187 189
188 virtual bool Visit(RenderView* render_view) OVERRIDE { 190 virtual bool Visit(RenderView* render_view) OVERRIDE {
189 WebView* webview = render_view->GetWebView(); 191 WebView* webview = render_view->GetWebView();
190 WebDocument document = webview->mainFrame()->document(); 192 WebDocument document = webview->mainFrame()->document();
191 193
192 // Don't set zoom level for full-page plugin since they don't use the same 194 // Don't set zoom level for full-page plugin since they don't use the same
193 // zoom settings. 195 // zoom settings.
Fady Samuel 2014/04/07 21:27:24 Update this comment.
paulmeyer 2014/04/08 21:13:20 Done.
194 if (document.isPluginDocument()) 196 if (document.isPluginDocument() ||
197 exceptions_.count(render_view->GetRoutingID()))
195 return true; 198 return true;
196 GURL url(document.url()); 199 GURL url(document.url());
197 // Empty scheme works as wildcard that matches any scheme, 200 // Empty scheme works as wildcard that matches any scheme,
198 if ((net::GetHostOrSpecFromURL(url) == host_) && 201 if ((net::GetHostOrSpecFromURL(url) == host_) &&
199 (scheme_.empty() || scheme_ == url.scheme())) { 202 (scheme_.empty() || scheme_ == url.scheme())) {
200 webview->setZoomLevel(zoom_level_); 203 webview->setZoomLevel(zoom_level_);
201 } 204 }
202 return true; 205 return true;
203 } 206 }
204 207
205 private: 208 private:
206 const std::string scheme_; 209 const std::string scheme_;
207 const std::string host_; 210 const std::string host_;
208 const double zoom_level_; 211 const double zoom_level_;
212 const std::set<int> exceptions_;
209 213
210 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); 214 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer);
211 }; 215 };
212 216
213 std::string HostToCustomHistogramSuffix(const std::string& host) { 217 std::string HostToCustomHistogramSuffix(const std::string& host) {
214 if (host == "mail.google.com") 218 if (host == "mail.google.com")
215 return ".gmail"; 219 return ".gmail";
216 if (host == "docs.google.com" || host == "drive.google.com") 220 if (host == "docs.google.com" || host == "drive.google.com")
217 return ".docs"; 221 return ".docs";
218 if (host == "plus.google.com") 222 if (host == "plus.google.com")
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 } 1209 }
1206 1210
1207 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { 1211 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() {
1208 suspend_webkit_shared_timer_ = false; 1212 suspend_webkit_shared_timer_ = false;
1209 } 1213 }
1210 1214
1211 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { 1215 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() {
1212 notify_webkit_of_modal_loop_ = false; 1216 notify_webkit_of_modal_loop_ = false;
1213 } 1217 }
1214 1218
1215 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme, 1219 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(
1216 const std::string& host, 1220 const std::string& scheme,
1217 double zoom_level) { 1221 const std::string& host,
1218 RenderViewZoomer zoomer(scheme, host, zoom_level); 1222 double zoom_level,
1223 const std::set<int>& exceptions) {
1224 RenderViewZoomer zoomer(scheme, host, zoom_level, exceptions);
1219 RenderView::ForEach(&zoomer); 1225 RenderView::ForEach(&zoomer);
1220 } 1226 }
1221 1227
1222 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { 1228 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) {
1223 ObserverListBase<RenderProcessObserver>::Iterator it(observers_); 1229 ObserverListBase<RenderProcessObserver>::Iterator it(observers_);
1224 RenderProcessObserver* observer; 1230 RenderProcessObserver* observer;
1225 while ((observer = it.GetNext()) != NULL) { 1231 while ((observer = it.GetNext()) != NULL) {
1226 if (observer->OnControlMessageReceived(msg)) 1232 if (observer->OnControlMessageReceived(msg))
1227 return true; 1233 return true;
1228 } 1234 }
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 hidden_widget_count_--; 1525 hidden_widget_count_--;
1520 1526
1521 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { 1527 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) {
1522 return; 1528 return;
1523 } 1529 }
1524 1530
1525 ScheduleIdleHandler(kLongIdleHandlerDelayMs); 1531 ScheduleIdleHandler(kLongIdleHandlerDelayMs);
1526 } 1532 }
1527 1533
1528 } // namespace content 1534 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698