OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/interstitial_page_impl.h" | 5 #include "content/browser/frame_host/interstitial_page_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 // Delete this and call Shutdown on the RVH asynchronously, as we may have | 289 // Delete this and call Shutdown on the RVH asynchronously, as we may have |
290 // been called from a RVH delegate method, and we can't delete the RVH out | 290 // been called from a RVH delegate method, and we can't delete the RVH out |
291 // from under itself. | 291 // from under itself. |
292 base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( | 292 base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( |
293 FROM_HERE, base::Bind(&InterstitialPageImpl::Shutdown, | 293 FROM_HERE, base::Bind(&InterstitialPageImpl::Shutdown, |
294 weak_ptr_factory_.GetWeakPtr())); | 294 weak_ptr_factory_.GetWeakPtr())); |
295 render_view_host_ = NULL; | 295 render_view_host_ = NULL; |
296 frame_tree_.root()->ResetForNewProcess(); | 296 frame_tree_.root()->ResetForNewProcess(); |
297 controller_->delegate()->DetachInterstitialPage(); | 297 controller_->delegate()->DetachInterstitialPage(); |
298 // Let's revert to the original title if necessary. | 298 // Let's revert to the original title if necessary. |
299 NavigationEntry* entry = controller_->GetVisibleEntry(); | 299 NavigationEntryImpl* entry = controller_->GetVisibleEntry(); |
300 if (entry && !new_navigation_ && should_revert_web_contents_title_) { | 300 if (entry && !new_navigation_ && should_revert_web_contents_title_) { |
301 entry->SetTitle(original_web_contents_title_); | 301 static_cast<WebContentsImpl*>(web_contents_)->UpdateTitleForEntry( |
302 entry, original_web_contents_title_); | |
302 controller_->delegate()->NotifyNavigationStateChanged( | 303 controller_->delegate()->NotifyNavigationStateChanged( |
303 INVALIDATE_TYPE_TITLE); | 304 INVALIDATE_TYPE_TITLE); |
Charlie Reis
2016/06/24 22:21:17
One way to make this cleaner would be to move Noti
afakhry
2016/06/27 14:29:18
I made it public, moved the call to NotifyNavigati
Charlie Reis
2016/06/28 21:13:31
If no one is listening to the return value, we sho
| |
304 } | 305 } |
305 | 306 |
306 static_cast<WebContentsImpl*>(web_contents_)->DidChangeVisibleSSLState(); | 307 static_cast<WebContentsImpl*>(web_contents_)->DidChangeVisibleSSLState(); |
307 | 308 |
308 InterstitialPageMap::iterator iter = | 309 InterstitialPageMap::iterator iter = |
309 g_web_contents_to_interstitial_page->find(web_contents_); | 310 g_web_contents_to_interstitial_page->find(web_contents_); |
310 DCHECK(iter != g_web_contents_to_interstitial_page->end()); | 311 DCHECK(iter != g_web_contents_to_interstitial_page->end()); |
311 if (iter != g_web_contents_to_interstitial_page->end()) | 312 if (iter != g_web_contents_to_interstitial_page->end()) |
312 g_web_contents_to_interstitial_page->erase(iter); | 313 g_web_contents_to_interstitial_page->erase(iter); |
313 | 314 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 void InterstitialPageImpl::UpdateTitle( | 385 void InterstitialPageImpl::UpdateTitle( |
385 RenderFrameHost* render_frame_host, | 386 RenderFrameHost* render_frame_host, |
386 int32_t page_id, | 387 int32_t page_id, |
387 const base::string16& title, | 388 const base::string16& title, |
388 base::i18n::TextDirection title_direction) { | 389 base::i18n::TextDirection title_direction) { |
389 if (!enabled()) | 390 if (!enabled()) |
390 return; | 391 return; |
391 | 392 |
392 RenderViewHost* render_view_host = render_frame_host->GetRenderViewHost(); | 393 RenderViewHost* render_view_host = render_frame_host->GetRenderViewHost(); |
393 DCHECK(render_view_host == render_view_host_); | 394 DCHECK(render_view_host == render_view_host_); |
394 NavigationEntry* entry = controller_->GetVisibleEntry(); | 395 NavigationEntryImpl* entry = controller_->GetVisibleEntry(); |
395 if (!entry) { | 396 if (!entry) { |
396 // There may be no visible entry if no URL has committed (e.g., after | 397 // There may be no visible entry if no URL has committed (e.g., after |
397 // window.open("")). InterstitialPages with the new_navigation flag create | 398 // window.open("")). InterstitialPages with the new_navigation flag create |
398 // a transient NavigationEntry and thus have a visible entry. However, | 399 // a transient NavigationEntry and thus have a visible entry. However, |
399 // interstitials can still be created when there is no visible entry. For | 400 // interstitials can still be created when there is no visible entry. For |
400 // example, the opener window may inject content into the initial blank | 401 // example, the opener window may inject content into the initial blank |
401 // page, which might trigger a SafeBrowsingBlockingPage. | 402 // page, which might trigger a SafeBrowsingBlockingPage. |
402 return; | 403 return; |
403 } | 404 } |
404 | 405 |
405 // If this interstitial is shown on an existing navigation entry, we'll need | 406 // If this interstitial is shown on an existing navigation entry, we'll need |
406 // to remember its title so we can revert to it when hidden. | 407 // to remember its title so we can revert to it when hidden. |
407 if (!new_navigation_ && !should_revert_web_contents_title_) { | 408 if (!new_navigation_ && !should_revert_web_contents_title_) { |
408 original_web_contents_title_ = entry->GetTitle(); | 409 original_web_contents_title_ = entry->GetTitle(); |
409 should_revert_web_contents_title_ = true; | 410 should_revert_web_contents_title_ = true; |
410 } | 411 } |
411 // TODO(evan): make use of title_direction. | 412 // TODO(evan): make use of title_direction. |
412 // http://code.google.com/p/chromium/issues/detail?id=27094 | 413 // http://code.google.com/p/chromium/issues/detail?id=27094 |
413 entry->SetTitle(title); | 414 static_cast<WebContentsImpl*>(web_contents_)->UpdateTitleForEntry(entry, |
415 title); | |
414 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE); | 416 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE); |
Charlie Reis
2016/06/24 22:21:17
Same here.
afakhry
2016/06/27 14:29:18
Done.
| |
415 } | 417 } |
416 | 418 |
417 InterstitialPage* InterstitialPageImpl::GetAsInterstitialPage() { | 419 InterstitialPage* InterstitialPageImpl::GetAsInterstitialPage() { |
418 return this; | 420 return this; |
419 } | 421 } |
420 | 422 |
421 AccessibilityMode InterstitialPageImpl::GetAccessibilityMode() const { | 423 AccessibilityMode InterstitialPageImpl::GetAccessibilityMode() const { |
422 if (web_contents_) | 424 if (web_contents_) |
423 return static_cast<WebContentsImpl*>(web_contents_)->GetAccessibilityMode(); | 425 return static_cast<WebContentsImpl*>(web_contents_)->GetAccessibilityMode(); |
424 else | 426 else |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
660 // resume blocked requests for it. If it is not a new navigation, then it | 662 // resume blocked requests for it. If it is not a new navigation, then it |
661 // means the interstitial was shown as a result of a resource loading in the | 663 // means the interstitial was shown as a result of a resource loading in the |
662 // page and we won't return to the original page, so we cancel blocked | 664 // page and we won't return to the original page, so we cancel blocked |
663 // requests in that case. | 665 // requests in that case. |
664 if (new_navigation_) | 666 if (new_navigation_) |
665 TakeActionOnResourceDispatcher(RESUME); | 667 TakeActionOnResourceDispatcher(RESUME); |
666 else | 668 else |
667 TakeActionOnResourceDispatcher(CANCEL); | 669 TakeActionOnResourceDispatcher(CANCEL); |
668 | 670 |
669 if (should_discard_pending_nav_entry_) { | 671 if (should_discard_pending_nav_entry_) { |
672 // Revert back to the last committed title (if any) before we discard the | |
673 // non-committed entries. | |
674 NavigationEntryImpl* last_committed_entry = | |
675 controller_->GetLastCommittedEntry(); | |
676 if (last_committed_entry) { | |
677 NavigationEntryImpl* visible_entry = controller_->GetVisibleEntry(); | |
Charlie Reis
2016/06/24 22:21:17
I think this might be wrong. In general, we shoul
afakhry
2016/06/27 14:29:18
We need this if we want TitleWasSet() to be emitte
Charlie Reis
2016/06/28 00:47:09
I feel like we're going about this the wrong way.
afakhry
2016/06/28 14:34:17
Yes, it happens as a result of calling:
delegate_
Charlie Reis
2016/06/28 21:13:31
I see.
This seems to boil down to WebContentsObse
| |
678 static_cast<WebContentsImpl*>(web_contents_)->UpdateTitleForEntry( | |
679 visible_entry, last_committed_entry->GetTitle()); | |
680 } | |
681 | |
670 // Since no navigation happens we have to discard the transient entry | 682 // Since no navigation happens we have to discard the transient entry |
671 // explicitely. Note that by calling DiscardNonCommittedEntries() we also | 683 // explicitly. Note that by calling DiscardNonCommittedEntries() we also |
672 // discard the pending entry, which is what we want, since the navigation is | 684 // discard the pending entry, which is what we want, since the navigation is |
673 // cancelled. | 685 // cancelled. |
674 controller_->DiscardNonCommittedEntries(); | 686 controller_->DiscardNonCommittedEntries(); |
675 } | 687 } |
676 | 688 |
677 if (reload_on_dont_proceed_) | 689 if (reload_on_dont_proceed_) |
678 controller_->Reload(true); | 690 controller_->Reload(true); |
679 | 691 |
680 Hide(); | 692 Hide(); |
681 delegate_->OnDontProceed(); | 693 delegate_->OnDontProceed(); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
940 void InterstitialPageImpl::UnderlyingContentObserver::WebContentsDestroyed() { | 952 void InterstitialPageImpl::UnderlyingContentObserver::WebContentsDestroyed() { |
941 interstitial_->OnNavigatingAwayOrTabClosing(); | 953 interstitial_->OnNavigatingAwayOrTabClosing(); |
942 } | 954 } |
943 | 955 |
944 TextInputManager* InterstitialPageImpl::GetTextInputManager() { | 956 TextInputManager* InterstitialPageImpl::GetTextInputManager() { |
945 return !web_contents_ ? nullptr : static_cast<WebContentsImpl*>(web_contents_) | 957 return !web_contents_ ? nullptr : static_cast<WebContentsImpl*>(web_contents_) |
946 ->GetTextInputManager(); | 958 ->GetTextInputManager(); |
947 } | 959 } |
948 | 960 |
949 } // namespace content | 961 } // namespace content |
OLD | NEW |