| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 SiteInstance* site_instance, | 51 SiteInstance* site_instance, |
| 52 int routing_id, | 52 int routing_id, |
| 53 base::WaitableEvent* modal_dialog_event) { | 53 base::WaitableEvent* modal_dialog_event) { |
| 54 // Create a RenderViewHost, once we have an instance. It is important to | 54 // Create a RenderViewHost, once we have an instance. It is important to |
| 55 // immediately give this SiteInstance to a RenderViewHost so that it is | 55 // immediately give this SiteInstance to a RenderViewHost so that it is |
| 56 // ref counted. | 56 // ref counted. |
| 57 if (!site_instance) | 57 if (!site_instance) |
| 58 site_instance = SiteInstance::CreateSiteInstance(profile); | 58 site_instance = SiteInstance::CreateSiteInstance(profile); |
| 59 render_view_host_ = RenderViewHostFactory::Create( | 59 render_view_host_ = RenderViewHostFactory::Create( |
| 60 site_instance, render_view_delegate_, routing_id, modal_dialog_event); | 60 site_instance, render_view_delegate_, routing_id, modal_dialog_event); |
| 61 NotificationService::current()->Notify( |
| 62 NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB, |
| 63 Source<RenderViewHostManager>(this), |
| 64 Details<RenderViewHost>(render_view_host_)); |
| 61 } | 65 } |
| 62 | 66 |
| 63 RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) { | 67 RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) { |
| 64 // This will possibly create (set to NULL) a DOM UI object for the pending | 68 // This will possibly create (set to NULL) a DOM UI object for the pending |
| 65 // page. We'll use this later to give the page special access. This must | 69 // page. We'll use this later to give the page special access. This must |
| 66 // happen before the new renderer is created below so it will get bindings. | 70 // happen before the new renderer is created below so it will get bindings. |
| 67 pending_dom_ui_.reset(delegate_->CreateDOMUIForRenderManager(entry.url())); | 71 pending_dom_ui_.reset(delegate_->CreateDOMUIForRenderManager(entry.url())); |
| 68 | 72 |
| 69 // Create a pending RenderViewHost. It will give us the one we should use | 73 // Create a pending RenderViewHost. It will give us the one we should use |
| 70 RenderViewHost* dest_render_view_host = UpdateRendererStateForNavigate(entry); | 74 RenderViewHost* dest_render_view_host = UpdateRendererStateForNavigate(entry); |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 NavigationEntry* curr_entry = | 404 NavigationEntry* curr_entry = |
| 401 delegate_->GetControllerForRenderManager().GetLastCommittedEntry(); | 405 delegate_->GetControllerForRenderManager().GetLastCommittedEntry(); |
| 402 if (curr_entry) { | 406 if (curr_entry) { |
| 403 DCHECK(!curr_entry->content_state().empty()); | 407 DCHECK(!curr_entry->content_state().empty()); |
| 404 // TODO(creis): Should send a message to the RenderView to let it know | 408 // TODO(creis): Should send a message to the RenderView to let it know |
| 405 // we're about to switch away, so that it sends an UpdateState message. | 409 // we're about to switch away, so that it sends an UpdateState message. |
| 406 } | 410 } |
| 407 | 411 |
| 408 pending_render_view_host_ = RenderViewHostFactory::Create( | 412 pending_render_view_host_ = RenderViewHostFactory::Create( |
| 409 instance, render_view_delegate_, MSG_ROUTING_NONE, NULL); | 413 instance, render_view_delegate_, MSG_ROUTING_NONE, NULL); |
| 414 NotificationService::current()->Notify( |
| 415 NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB, |
| 416 Source<RenderViewHostManager>(this), |
| 417 Details<RenderViewHost>(pending_render_view_host_)); |
| 410 | 418 |
| 411 bool success = delegate_->CreateRenderViewForRenderManager( | 419 bool success = delegate_->CreateRenderViewForRenderManager( |
| 412 pending_render_view_host_); | 420 pending_render_view_host_); |
| 413 if (success) { | 421 if (success) { |
| 414 // Don't show the view until we get a DidNavigate from it. | 422 // Don't show the view until we get a DidNavigate from it. |
| 415 pending_render_view_host_->view()->Hide(); | 423 pending_render_view_host_->view()->Hide(); |
| 416 } else { | 424 } else { |
| 417 CancelPending(); | 425 CancelPending(); |
| 418 } | 426 } |
| 419 return success; | 427 return success; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 | 580 |
| 573 pending_dom_ui_.reset(); | 581 pending_dom_ui_.reset(); |
| 574 } | 582 } |
| 575 | 583 |
| 576 void RenderViewHostManager::CrossSiteNavigationCanceled() { | 584 void RenderViewHostManager::CrossSiteNavigationCanceled() { |
| 577 DCHECK(cross_navigation_pending_); | 585 DCHECK(cross_navigation_pending_); |
| 578 cross_navigation_pending_ = false; | 586 cross_navigation_pending_ = false; |
| 579 if (pending_render_view_host_) | 587 if (pending_render_view_host_) |
| 580 CancelPending(); | 588 CancelPending(); |
| 581 } | 589 } |
| OLD | NEW |