| 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/browser/tab_contents/render_view_host_manager.h" | 5 #include "chrome/browser/tab_contents/render_view_host_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/dom_ui/dom_ui.h" | 9 #include "chrome/browser/dom_ui/dom_ui.h" |
| 10 #include "chrome/browser/dom_ui/dom_ui_factory.h" | 10 #include "chrome/browser/dom_ui/dom_ui_factory.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 302 |
| 303 // We can't switch a RenderView between view source and non-view source mode | 303 // We can't switch a RenderView between view source and non-view source mode |
| 304 // without screwing up the session history sometimes (when navigating between | 304 // without screwing up the session history sometimes (when navigating between |
| 305 // "view-source:http://foo.com/" and "http://foo.com/", WebKit doesn't treat | 305 // "view-source:http://foo.com/" and "http://foo.com/", WebKit doesn't treat |
| 306 // it as a new navigation). So require a view switch. | 306 // it as a new navigation). So require a view switch. |
| 307 if (cur_entry->IsViewSourceMode() != new_entry->IsViewSourceMode()) | 307 if (cur_entry->IsViewSourceMode() != new_entry->IsViewSourceMode()) |
| 308 return true; | 308 return true; |
| 309 | 309 |
| 310 // For security, we should transition between processes when one is a DOM UI | 310 // For security, we should transition between processes when one is a DOM UI |
| 311 // page and one isn't. | 311 // page and one isn't. |
| 312 if (DOMUIFactory::UseDOMUIForURL(cur_entry->url()) != | 312 Profile* profile = delegate_->GetControllerForRenderManager().profile(); |
| 313 DOMUIFactory::UseDOMUIForURL(new_entry->url())) | 313 if (DOMUIFactory::UseDOMUIForURL(profile, cur_entry->url()) != |
| 314 DOMUIFactory::UseDOMUIForURL(profile, new_entry->url())) |
| 314 return true; | 315 return true; |
| 315 | 316 |
| 316 // Also, we must switch if one is an extension and the other is not the exact | 317 // Also, we must switch if one is an extension and the other is not the exact |
| 317 // same extension. | 318 // same extension. |
| 318 if (cur_entry->url().SchemeIs(chrome::kExtensionScheme) || | 319 if (cur_entry->url().SchemeIs(chrome::kExtensionScheme) || |
| 319 new_entry->url().SchemeIs(chrome::kExtensionScheme)) { | 320 new_entry->url().SchemeIs(chrome::kExtensionScheme)) { |
| 320 if (cur_entry->url().GetOrigin() != new_entry->url().GetOrigin()) | 321 if (cur_entry->url().GetOrigin() != new_entry->url().GetOrigin()) |
| 321 return true; | 322 return true; |
| 322 } | 323 } |
| 323 | 324 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 466 |
| 466 bool RenderViewHostManager::InitRenderView(RenderViewHost* render_view_host, | 467 bool RenderViewHostManager::InitRenderView(RenderViewHost* render_view_host, |
| 467 const NavigationEntry& entry) { | 468 const NavigationEntry& entry) { |
| 468 // If the pending navigation is to a DOMUI, tell the RenderView about any | 469 // If the pending navigation is to a DOMUI, tell the RenderView about any |
| 469 // bindings it will need enabled. | 470 // bindings it will need enabled. |
| 470 if (pending_dom_ui_.get()) | 471 if (pending_dom_ui_.get()) |
| 471 render_view_host->AllowBindings(pending_dom_ui_->bindings()); | 472 render_view_host->AllowBindings(pending_dom_ui_->bindings()); |
| 472 | 473 |
| 473 // Tell the RenderView whether it will be used for an extension process. | 474 // Tell the RenderView whether it will be used for an extension process. |
| 474 Profile* profile = delegate_->GetControllerForRenderManager().profile(); | 475 Profile* profile = delegate_->GetControllerForRenderManager().profile(); |
| 475 bool is_extension_process = false; | 476 bool is_extension_process = profile->GetExtensionsService() && |
| 476 if (entry.url().SchemeIs(chrome::kExtensionScheme)) { | 477 profile->GetExtensionsService()->ExtensionBindingsAllowed(entry.url()); |
| 477 is_extension_process = true; | |
| 478 } else if (profile->GetExtensionsService() && | |
| 479 profile->GetExtensionsService()-> | |
| 480 GetExtensionByWebExtent(entry.url())) { | |
| 481 is_extension_process = true; | |
| 482 } | |
| 483 render_view_host->set_is_extension_process(is_extension_process); | 478 render_view_host->set_is_extension_process(is_extension_process); |
| 484 | 479 |
| 485 return delegate_->CreateRenderViewForRenderManager(render_view_host); | 480 return delegate_->CreateRenderViewForRenderManager(render_view_host); |
| 486 } | 481 } |
| 487 | 482 |
| 488 void RenderViewHostManager::CommitPending() { | 483 void RenderViewHostManager::CommitPending() { |
| 489 // First check whether we're going to want to focus the location bar after | 484 // First check whether we're going to want to focus the location bar after |
| 490 // this commit. We do this now because the navigation hasn't formally | 485 // this commit. We do this now because the navigation hasn't formally |
| 491 // committed yet, so if we've already cleared |pending_dom_ui_| the call chain | 486 // committed yet, so if we've already cleared |pending_dom_ui_| the call chain |
| 492 // this triggers won't be able to figure out what's going on. | 487 // this triggers won't be able to figure out what's going on. |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 // deleted (not sure from where) but not NULLed. | 662 // deleted (not sure from where) but not NULLed. |
| 668 if (rvh == pending_render_view_host_) { | 663 if (rvh == pending_render_view_host_) { |
| 669 // If you hit this NOTREACHED, please report it in the following bug | 664 // If you hit this NOTREACHED, please report it in the following bug |
| 670 // http://crbug.com/23411 Make sure to include what you were doing when it | 665 // http://crbug.com/23411 Make sure to include what you were doing when it |
| 671 // happened (navigating to a new page, closing a tab...) and if you can | 666 // happened (navigating to a new page, closing a tab...) and if you can |
| 672 // reproduce. | 667 // reproduce. |
| 673 NOTREACHED(); | 668 NOTREACHED(); |
| 674 pending_render_view_host_ = NULL; | 669 pending_render_view_host_ = NULL; |
| 675 } | 670 } |
| 676 } | 671 } |
| OLD | NEW |