OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "content/renderer/render_thread.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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 #if defined(OS_WIN) | 77 #if defined(OS_WIN) |
78 #include <windows.h> | 78 #include <windows.h> |
79 #include <objbase.h> | 79 #include <objbase.h> |
80 #endif | 80 #endif |
81 | 81 |
82 #if defined(OS_POSIX) | 82 #if defined(OS_POSIX) |
83 #include "ipc/ipc_channel_posix.h" | 83 #include "ipc/ipc_channel_posix.h" |
84 #endif | 84 #endif |
85 | 85 |
| 86 using WebKit::WebDocument; |
86 using WebKit::WebFrame; | 87 using WebKit::WebFrame; |
87 using WebKit::WebRuntimeFeatures; | 88 using WebKit::WebRuntimeFeatures; |
88 using WebKit::WebScriptController; | 89 using WebKit::WebScriptController; |
89 using WebKit::WebString; | 90 using WebKit::WebString; |
90 using WebKit::WebStorageEventDispatcher; | 91 using WebKit::WebStorageEventDispatcher; |
91 using WebKit::WebView; | 92 using WebKit::WebView; |
92 | 93 |
93 namespace { | 94 namespace { |
94 static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */; | 95 static const double kInitialIdleHandlerDelayS = 1.0 /* seconds */; |
95 | 96 |
96 // Keep the global RenderThread in a TLS slot so it is impossible to access | 97 // Keep the global RenderThread in a TLS slot so it is impossible to access |
97 // incorrectly from the wrong thread. | 98 // incorrectly from the wrong thread. |
98 static base::LazyInstance<base::ThreadLocalPointer<RenderThread> > lazy_tls( | 99 static base::LazyInstance<base::ThreadLocalPointer<RenderThread> > lazy_tls( |
99 base::LINKER_INITIALIZED); | 100 base::LINKER_INITIALIZED); |
100 | 101 |
101 class RenderViewZoomer : public RenderViewVisitor { | 102 class RenderViewZoomer : public RenderViewVisitor { |
102 public: | 103 public: |
103 RenderViewZoomer(const GURL& url, double zoom_level) | 104 RenderViewZoomer(const GURL& url, double zoom_level) |
104 : zoom_level_(zoom_level) { | 105 : zoom_level_(zoom_level) { |
105 host_ = net::GetHostOrSpecFromURL(url); | 106 host_ = net::GetHostOrSpecFromURL(url); |
106 } | 107 } |
107 | 108 |
108 virtual bool Visit(RenderView* render_view) { | 109 virtual bool Visit(RenderView* render_view) { |
109 WebView* webview = render_view->webview(); // Guaranteed non-NULL. | 110 WebView* webview = render_view->webview(); |
| 111 WebDocument document = webview->mainFrame()->document(); |
110 | 112 |
111 // Don't set zoom level for full-page plugin since they don't use the same | 113 // Don't set zoom level for full-page plugin since they don't use the same |
112 // zoom settings. | 114 // zoom settings. |
113 if (webview->mainFrame()->document().isPluginDocument()) | 115 if (document.isPluginDocument()) |
114 return true; | 116 return true; |
115 | 117 |
116 if (net::GetHostOrSpecFromURL(GURL(webview->mainFrame()->url())) == host_) | 118 if (net::GetHostOrSpecFromURL(GURL(document.url())) == host_) |
117 webview->setZoomLevel(false, zoom_level_); | 119 webview->setZoomLevel(false, zoom_level_); |
118 return true; | 120 return true; |
119 } | 121 } |
120 | 122 |
121 private: | 123 private: |
122 std::string host_; | 124 std::string host_; |
123 double zoom_level_; | 125 double zoom_level_; |
124 | 126 |
125 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); | 127 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); |
126 }; | 128 }; |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 | 683 |
682 void RenderThread::RegisterExtension(v8::Extension* extension) { | 684 void RenderThread::RegisterExtension(v8::Extension* extension) { |
683 WebScriptController::registerExtension(extension); | 685 WebScriptController::registerExtension(extension); |
684 v8_extensions_.insert(extension->name()); | 686 v8_extensions_.insert(extension->name()); |
685 } | 687 } |
686 | 688 |
687 bool RenderThread::IsRegisteredExtension( | 689 bool RenderThread::IsRegisteredExtension( |
688 const std::string& v8_extension_name) const { | 690 const std::string& v8_extension_name) const { |
689 return v8_extensions_.find(v8_extension_name) != v8_extensions_.end(); | 691 return v8_extensions_.find(v8_extension_name) != v8_extensions_.end(); |
690 } | 692 } |
OLD | NEW |