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

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: Addressed comments. 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
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> > lazy_tls =
177 lazy_tls = LAZY_INSTANCE_INITIALIZER; 177 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. RenderViews associated with tabs in special zoom
194 if (document.isPluginDocument()) 196 // modes (listed in |exceptions_|) should also not be zoomed.
197 if (document.isPluginDocument() ||
198 exceptions_.count(render_view->GetRoutingID()))
195 return true; 199 return true;
196 GURL url(document.url()); 200 GURL url(document.url());
197 // Empty scheme works as wildcard that matches any scheme, 201 // Empty scheme works as wildcard that matches any scheme,
198 if ((net::GetHostOrSpecFromURL(url) == host_) && 202 if ((net::GetHostOrSpecFromURL(url) == host_) &&
199 (scheme_.empty() || scheme_ == url.scheme())) { 203 (scheme_.empty() || scheme_ == url.scheme())) {
200 webview->setZoomLevel(zoom_level_); 204 webview->setZoomLevel(zoom_level_);
201 } 205 }
202 return true; 206 return true;
203 } 207 }
204 208
205 private: 209 private:
206 const std::string scheme_; 210 const std::string scheme_;
207 const std::string host_; 211 const std::string host_;
208 const double zoom_level_; 212 const double zoom_level_;
213 const std::set<int> exceptions_;
209 214
210 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); 215 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer);
211 }; 216 };
212 217
213 std::string HostToCustomHistogramSuffix(const std::string& host) { 218 std::string HostToCustomHistogramSuffix(const std::string& host) {
214 if (host == "mail.google.com") 219 if (host == "mail.google.com")
215 return ".gmail"; 220 return ".gmail";
216 if (host == "docs.google.com" || host == "drive.google.com") 221 if (host == "docs.google.com" || host == "drive.google.com")
217 return ".docs"; 222 return ".docs";
218 if (host == "plus.google.com") 223 if (host == "plus.google.com")
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 } 1210 }
1206 1211
1207 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() { 1212 void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() {
1208 suspend_webkit_shared_timer_ = false; 1213 suspend_webkit_shared_timer_ = false;
1209 } 1214 }
1210 1215
1211 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() { 1216 void RenderThreadImpl::DoNotNotifyWebKitOfModalLoop() {
1212 notify_webkit_of_modal_loop_ = false; 1217 notify_webkit_of_modal_loop_ = false;
1213 } 1218 }
1214 1219
1215 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(const std::string& scheme, 1220 void RenderThreadImpl::OnSetZoomLevelForCurrentURL(
1216 const std::string& host, 1221 const std::string& scheme,
1217 double zoom_level) { 1222 const std::string& host,
1218 RenderViewZoomer zoomer(scheme, host, zoom_level); 1223 double zoom_level,
1224 const std::set<int>& exceptions) {
1225 RenderViewZoomer zoomer(scheme, host, zoom_level, exceptions);
1219 RenderView::ForEach(&zoomer); 1226 RenderView::ForEach(&zoomer);
1220 } 1227 }
1221 1228
1222 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { 1229 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) {
1223 ObserverListBase<RenderProcessObserver>::Iterator it(observers_); 1230 ObserverListBase<RenderProcessObserver>::Iterator it(observers_);
1224 RenderProcessObserver* observer; 1231 RenderProcessObserver* observer;
1225 while ((observer = it.GetNext()) != NULL) { 1232 while ((observer = it.GetNext()) != NULL) {
1226 if (observer->OnControlMessageReceived(msg)) 1233 if (observer->OnControlMessageReceived(msg))
1227 return true; 1234 return true;
1228 } 1235 }
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 hidden_widget_count_--; 1526 hidden_widget_count_--;
1520 1527
1521 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { 1528 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) {
1522 return; 1529 return;
1523 } 1530 }
1524 1531
1525 ScheduleIdleHandler(kLongIdleHandlerDelayMs); 1532 ScheduleIdleHandler(kLongIdleHandlerDelayMs);
1526 } 1533 }
1527 1534
1528 } // namespace content 1535 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698