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/browser/tab_contents/interstitial_page.h" | 5 #include "content/browser/tab_contents/interstitial_page.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "content/browser/renderer_host/render_process_host_impl.h" | 15 #include "content/browser/renderer_host/render_process_host_impl.h" |
16 #include "content/browser/renderer_host/render_view_host.h" | 16 #include "content/browser/renderer_host/render_view_host.h" |
17 #include "content/browser/renderer_host/render_widget_host_view.h" | 17 #include "content/browser/renderer_host/render_widget_host_view.h" |
18 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 18 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
19 #include "content/browser/site_instance.h" | 19 #include "content/browser/site_instance.h" |
20 #include "content/browser/tab_contents/navigation_controller.h" | 20 #include "content/browser/tab_contents/navigation_controller.h" |
21 #include "content/browser/tab_contents/navigation_entry.h" | 21 #include "content/browser/tab_contents/navigation_entry_impl.h" |
22 #include "content/browser/tab_contents/tab_contents.h" | 22 #include "content/browser/tab_contents/tab_contents.h" |
23 #include "content/browser/tab_contents/tab_contents_view.h" | 23 #include "content/browser/tab_contents/tab_contents_view.h" |
24 #include "content/common/dom_storage_common.h" | 24 #include "content/common/dom_storage_common.h" |
25 #include "content/common/view_messages.h" | 25 #include "content/common/view_messages.h" |
26 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/browser/content_browser_client.h" | 27 #include "content/public/browser/content_browser_client.h" |
28 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
29 #include "content/public/browser/notification_source.h" | 29 #include "content/public/browser/notification_source.h" |
30 #include "content/public/common/bindings_policy.h" | 30 #include "content/public/common/bindings_policy.h" |
31 #include "content/public/common/page_transition_types.h" | 31 #include "content/public/common/page_transition_types.h" |
32 #include "content/public/common/view_type.h" | 32 #include "content/public/common/view_type.h" |
33 #include "net/base/escape.h" | 33 #include "net/base/escape.h" |
34 #include "net/url_request/url_request_context_getter.h" | 34 #include "net/url_request/url_request_context_getter.h" |
35 | 35 |
36 using content::BrowserThread; | 36 using content::BrowserThread; |
| 37 using content::NavigationEntry; |
| 38 using content::NavigationEntryImpl; |
37 using content::WebContents; | 39 using content::WebContents; |
38 using WebKit::WebDragOperation; | 40 using WebKit::WebDragOperation; |
39 using WebKit::WebDragOperationsMask; | 41 using WebKit::WebDragOperationsMask; |
40 | 42 |
41 namespace { | 43 namespace { |
42 | 44 |
43 void ResourceRequestHelper(ResourceDispatcherHost* resource_dispatcher_host, | 45 void ResourceRequestHelper(ResourceDispatcherHost* resource_dispatcher_host, |
44 int process_id, | 46 int process_id, |
45 int render_view_host_id, | 47 int render_view_host_id, |
46 ResourceRequestAction action) { | 48 ResourceRequestAction action) { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 notification_registrar_.Add( | 181 notification_registrar_.Add( |
180 this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 182 this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
181 content::Source<RenderWidgetHost>(tab_->GetRenderViewHost())); | 183 content::Source<RenderWidgetHost>(tab_->GetRenderViewHost())); |
182 | 184 |
183 // Update the tab_to_interstitial_page_ map. | 185 // Update the tab_to_interstitial_page_ map. |
184 iter = tab_to_interstitial_page_->find(tab_); | 186 iter = tab_to_interstitial_page_->find(tab_); |
185 DCHECK(iter == tab_to_interstitial_page_->end()); | 187 DCHECK(iter == tab_to_interstitial_page_->end()); |
186 (*tab_to_interstitial_page_)[tab_] = this; | 188 (*tab_to_interstitial_page_)[tab_] = this; |
187 | 189 |
188 if (new_navigation_) { | 190 if (new_navigation_) { |
189 NavigationEntry* entry = new NavigationEntry; | 191 NavigationEntryImpl* entry = new NavigationEntryImpl; |
190 entry->SetURL(url_); | 192 entry->SetURL(url_); |
191 entry->SetVirtualURL(url_); | 193 entry->SetVirtualURL(url_); |
192 entry->set_page_type(content::PAGE_TYPE_INTERSTITIAL); | 194 entry->set_page_type(content::PAGE_TYPE_INTERSTITIAL); |
193 | 195 |
194 // Give sub-classes a chance to set some states on the navigation entry. | 196 // Give sub-classes a chance to set some states on the navigation entry. |
195 UpdateEntry(entry); | 197 UpdateEntry(entry); |
196 | 198 |
197 tab_->GetController().AddTransientEntry(entry); | 199 tab_->GetController().AddTransientEntry(entry); |
198 } | 200 } |
199 | 201 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 if (render_view_host_->view() && render_view_host_->view()->HasFocus() && | 233 if (render_view_host_->view() && render_view_host_->view()->HasFocus() && |
232 tab_->GetRenderViewHost()->view()) { | 234 tab_->GetRenderViewHost()->view()) { |
233 tab_->GetRenderViewHost()->view()->Focus(); | 235 tab_->GetRenderViewHost()->view()->Focus(); |
234 } | 236 } |
235 | 237 |
236 render_view_host_->Shutdown(); | 238 render_view_host_->Shutdown(); |
237 render_view_host_ = NULL; | 239 render_view_host_ = NULL; |
238 if (tab_->GetInterstitialPage()) | 240 if (tab_->GetInterstitialPage()) |
239 tab_->remove_interstitial_page(); | 241 tab_->remove_interstitial_page(); |
240 // Let's revert to the original title if necessary. | 242 // Let's revert to the original title if necessary. |
241 content::NavigationEntry* entry = tab_->GetController().GetActiveEntry(); | 243 NavigationEntry* entry = tab_->GetController().GetActiveEntry(); |
242 if (!new_navigation_ && should_revert_tab_title_) { | 244 if (!new_navigation_ && should_revert_tab_title_) { |
243 entry->SetTitle(original_tab_title_); | 245 entry->SetTitle(original_tab_title_); |
244 tab_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TITLE); | 246 tab_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TITLE); |
245 } | 247 } |
246 | 248 |
247 content::NotificationService::current()->Notify( | 249 content::NotificationService::current()->Notify( |
248 content::NOTIFICATION_INTERSTITIAL_DETACHED, | 250 content::NOTIFICATION_INTERSTITIAL_DETACHED, |
249 content::Source<TabContents>(tab_), | 251 content::Source<TabContents>(tab_), |
250 content::NotificationService::NoDetails()); | 252 content::NotificationService::NoDetails()); |
251 | 253 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 // hang. | 365 // hang. |
364 tab_was_loading_ = tab_->IsLoading(); | 366 tab_was_loading_ = tab_->IsLoading(); |
365 tab_->SetIsLoading(false, NULL); | 367 tab_->SetIsLoading(false, NULL); |
366 } | 368 } |
367 | 369 |
368 void InterstitialPage::UpdateTitle(RenderViewHost* render_view_host, | 370 void InterstitialPage::UpdateTitle(RenderViewHost* render_view_host, |
369 int32 page_id, | 371 int32 page_id, |
370 const string16& title, | 372 const string16& title, |
371 base::i18n::TextDirection title_direction) { | 373 base::i18n::TextDirection title_direction) { |
372 DCHECK(render_view_host == render_view_host_); | 374 DCHECK(render_view_host == render_view_host_); |
373 content::NavigationEntry* entry = tab_->GetController().GetActiveEntry(); | 375 NavigationEntry* entry = tab_->GetController().GetActiveEntry(); |
374 if (!entry) { | 376 if (!entry) { |
375 // Crash reports from the field indicate this can be NULL. | 377 // Crash reports from the field indicate this can be NULL. |
376 // This is unexpected as InterstitialPages constructed with the | 378 // This is unexpected as InterstitialPages constructed with the |
377 // new_navigation flag set to true create a transient navigation entry | 379 // new_navigation flag set to true create a transient navigation entry |
378 // (that is returned as the active entry). And the only case so far of | 380 // (that is returned as the active entry). And the only case so far of |
379 // interstitial created with that flag set to false is with the | 381 // interstitial created with that flag set to false is with the |
380 // SafeBrowsingBlockingPage, when the resource triggering the interstitial | 382 // SafeBrowsingBlockingPage, when the resource triggering the interstitial |
381 // is a sub-resource, meaning the main page has already been loaded and a | 383 // is a sub-resource, meaning the main page has already been loaded and a |
382 // navigation entry should have been created. | 384 // navigation entry should have been created. |
383 NOTREACHED(); | 385 NOTREACHED(); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 void InterstitialPage::InterstitialPageRVHViewDelegate::TakeFocus( | 674 void InterstitialPage::InterstitialPageRVHViewDelegate::TakeFocus( |
673 bool reverse) { | 675 bool reverse) { |
674 if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate()) | 676 if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate()) |
675 interstitial_page_->tab()->GetViewDelegate()->TakeFocus(reverse); | 677 interstitial_page_->tab()->GetViewDelegate()->TakeFocus(reverse); |
676 } | 678 } |
677 | 679 |
678 void InterstitialPage::InterstitialPageRVHViewDelegate::OnFindReply( | 680 void InterstitialPage::InterstitialPageRVHViewDelegate::OnFindReply( |
679 int request_id, int number_of_matches, const gfx::Rect& selection_rect, | 681 int request_id, int number_of_matches, const gfx::Rect& selection_rect, |
680 int active_match_ordinal, bool final_update) { | 682 int active_match_ordinal, bool final_update) { |
681 } | 683 } |
OLD | NEW |