OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/renderer/render_thread.h" | 5 #include "chrome/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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 #include "chrome/renderer/net/render_dns_master.h" | 54 #include "chrome/renderer/net/render_dns_master.h" |
55 #include "chrome/renderer/plugin_channel_host.h" | 55 #include "chrome/renderer/plugin_channel_host.h" |
56 #include "chrome/renderer/render_process_impl.h" | 56 #include "chrome/renderer/render_process_impl.h" |
57 #include "chrome/renderer/render_view.h" | 57 #include "chrome/renderer/render_view.h" |
58 #include "chrome/renderer/render_view_visitor.h" | 58 #include "chrome/renderer/render_view_visitor.h" |
59 #include "chrome/renderer/renderer_webkitclient_impl.h" | 59 #include "chrome/renderer/renderer_webkitclient_impl.h" |
60 #include "chrome/renderer/spellchecker/spellcheck.h" | 60 #include "chrome/renderer/spellchecker/spellcheck.h" |
61 #include "chrome/renderer/user_script_slave.h" | 61 #include "chrome/renderer/user_script_slave.h" |
62 #include "ipc/ipc_message.h" | 62 #include "ipc/ipc_message.h" |
63 #include "ipc/ipc_platform_file.h" | 63 #include "ipc/ipc_platform_file.h" |
| 64 #include "net/base/net_util.h" |
64 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" | 65 #include "third_party/tcmalloc/chromium/src/google/malloc_extension.h" |
65 #include "third_party/WebKit/WebKit/chromium/public/WebCache.h" | 66 #include "third_party/WebKit/WebKit/chromium/public/WebCache.h" |
66 #include "third_party/WebKit/WebKit/chromium/public/WebColor.h" | 67 #include "third_party/WebKit/WebKit/chromium/public/WebColor.h" |
67 #include "third_party/WebKit/WebKit/chromium/public/WebCrossOriginPreflightResul
tCache.h" | 68 #include "third_party/WebKit/WebKit/chromium/public/WebCrossOriginPreflightResul
tCache.h" |
68 #include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h" | 69 #include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h" |
69 #include "third_party/WebKit/WebKit/chromium/public/WebFontCache.h" | 70 #include "third_party/WebKit/WebKit/chromium/public/WebFontCache.h" |
70 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 71 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
71 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" | 72 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" |
72 #include "third_party/WebKit/WebKit/chromium/public/WebRuntimeFeatures.h" | 73 #include "third_party/WebKit/WebKit/chromium/public/WebRuntimeFeatures.h" |
73 #include "third_party/WebKit/WebKit/chromium/public/WebScriptController.h" | 74 #include "third_party/WebKit/WebKit/chromium/public/WebScriptController.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 165 |
165 private: | 166 private: |
166 GURL url_; | 167 GURL url_; |
167 ContentSettings content_settings_; | 168 ContentSettings content_settings_; |
168 | 169 |
169 DISALLOW_COPY_AND_ASSIGN(RenderViewContentSettingsSetter); | 170 DISALLOW_COPY_AND_ASSIGN(RenderViewContentSettingsSetter); |
170 }; | 171 }; |
171 | 172 |
172 class RenderViewZoomer : public RenderViewVisitor { | 173 class RenderViewZoomer : public RenderViewVisitor { |
173 public: | 174 public: |
174 RenderViewZoomer(const std::string& host, int zoom_level) | 175 RenderViewZoomer(const GURL& url, int zoom_level) |
175 : host_(host), | 176 : zoom_level_(zoom_level) { |
176 zoom_level_(zoom_level) { | 177 host_ = net::GetHostOrSpecFromURL(url); |
177 } | 178 } |
178 | 179 |
179 virtual bool Visit(RenderView* render_view) { | 180 virtual bool Visit(RenderView* render_view) { |
180 WebView* webview = render_view->webview(); // Guaranteed non-NULL. | 181 WebView* webview = render_view->webview(); // Guaranteed non-NULL. |
181 if (GURL(webview->mainFrame()->url()).host() == host_) | 182 if (net::GetHostOrSpecFromURL(GURL(webview->mainFrame()->url())) == host_) |
182 webview->setZoomLevel(false, zoom_level_); | 183 webview->setZoomLevel(false, zoom_level_); |
183 return true; | 184 return true; |
184 } | 185 } |
185 | 186 |
186 private: | 187 private: |
187 std::string host_; | 188 std::string host_; |
188 int zoom_level_; | 189 int zoom_level_; |
189 | 190 |
190 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); | 191 DISALLOW_COPY_AND_ASSIGN(RenderViewZoomer); |
191 }; | 192 }; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 WebView::resetVisitedLinkState(); | 451 WebView::resetVisitedLinkState(); |
451 } | 452 } |
452 | 453 |
453 void RenderThread::OnSetContentSettingsForCurrentURL( | 454 void RenderThread::OnSetContentSettingsForCurrentURL( |
454 const GURL& url, | 455 const GURL& url, |
455 const ContentSettings& content_settings) { | 456 const ContentSettings& content_settings) { |
456 RenderViewContentSettingsSetter setter(url, content_settings); | 457 RenderViewContentSettingsSetter setter(url, content_settings); |
457 RenderView::ForEach(&setter); | 458 RenderView::ForEach(&setter); |
458 } | 459 } |
459 | 460 |
460 void RenderThread::OnSetZoomLevelForCurrentHost(const std::string& host, | 461 void RenderThread::OnSetZoomLevelForCurrentURL(const GURL& url, |
461 int zoom_level) { | 462 int zoom_level) { |
462 RenderViewZoomer zoomer(host, zoom_level); | 463 RenderViewZoomer zoomer(url, zoom_level); |
463 RenderView::ForEach(&zoomer); | 464 RenderView::ForEach(&zoomer); |
464 } | 465 } |
465 | 466 |
466 void RenderThread::OnUpdateUserScripts(base::SharedMemoryHandle scripts) { | 467 void RenderThread::OnUpdateUserScripts(base::SharedMemoryHandle scripts) { |
467 DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle"; | 468 DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle"; |
468 user_script_slave_->UpdateScripts(scripts); | 469 user_script_slave_->UpdateScripts(scripts); |
469 UpdateActiveExtensions(); | 470 UpdateActiveExtensions(); |
470 } | 471 } |
471 | 472 |
472 void RenderThread::OnSetExtensionFunctionNames( | 473 void RenderThread::OnSetExtensionFunctionNames( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 // App cache messages are handled by a delegate. | 525 // App cache messages are handled by a delegate. |
525 if (appcache_dispatcher_->OnMessageReceived(msg)) | 526 if (appcache_dispatcher_->OnMessageReceived(msg)) |
526 return; | 527 return; |
527 | 528 |
528 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) | 529 IPC_BEGIN_MESSAGE_MAP(RenderThread, msg) |
529 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks) | 530 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_NewTable, OnUpdateVisitedLinks) |
530 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Add, OnAddVisitedLinks) | 531 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Add, OnAddVisitedLinks) |
531 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Reset, OnResetVisitedLinks) | 532 IPC_MESSAGE_HANDLER(ViewMsg_VisitedLink_Reset, OnResetVisitedLinks) |
532 IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForCurrentURL, | 533 IPC_MESSAGE_HANDLER(ViewMsg_SetContentSettingsForCurrentURL, |
533 OnSetContentSettingsForCurrentURL) | 534 OnSetContentSettingsForCurrentURL) |
534 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentHost, | 535 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL, |
535 OnSetZoomLevelForCurrentHost) | 536 OnSetZoomLevelForCurrentURL) |
536 IPC_MESSAGE_HANDLER(ViewMsg_SetIsIncognitoProcess, OnSetIsIncognitoProcess) | 537 IPC_MESSAGE_HANDLER(ViewMsg_SetIsIncognitoProcess, OnSetIsIncognitoProcess) |
537 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) | 538 IPC_MESSAGE_HANDLER(ViewMsg_SetNextPageID, OnSetNextPageID) |
538 IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors) | 539 IPC_MESSAGE_HANDLER(ViewMsg_SetCSSColors, OnSetCSSColors) |
539 // TODO(port): removed from render_messages_internal.h; | 540 // TODO(port): removed from render_messages_internal.h; |
540 // is there a new non-windows message I should add here? | 541 // is there a new non-windows message I should add here? |
541 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) | 542 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) |
542 IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities) | 543 IPC_MESSAGE_HANDLER(ViewMsg_SetCacheCapacities, OnSetCacheCapacities) |
543 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererHistograms, | 544 IPC_MESSAGE_HANDLER(ViewMsg_GetRendererHistograms, |
544 OnGetRendererHistograms) | 545 OnGetRendererHistograms) |
545 #if defined(USE_TCMALLOC) | 546 #if defined(USE_TCMALLOC) |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 if (url.SchemeIs(chrome::kExtensionScheme)) | 1029 if (url.SchemeIs(chrome::kExtensionScheme)) |
1029 return url.host(); | 1030 return url.host(); |
1030 | 1031 |
1031 for (size_t i = 0; i < extension_extents_.size(); ++i) { | 1032 for (size_t i = 0; i < extension_extents_.size(); ++i) { |
1032 if (extension_extents_[i].web_extent.ContainsURL(url)) | 1033 if (extension_extents_[i].web_extent.ContainsURL(url)) |
1033 return extension_extents_[i].extension_id; | 1034 return extension_extents_[i].extension_id; |
1034 } | 1035 } |
1035 | 1036 |
1036 return std::string(); | 1037 return std::string(); |
1037 } | 1038 } |
OLD | NEW |