Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2666193002: Switch RenderViewContextMenu to use RequestOpenURL (Closed)
Patch Set: cleanup Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after
2566 2566
2567 if (delegate_) 2567 if (delegate_)
2568 delegate_->ResizeDueToAutoResize(this, new_size); 2568 delegate_->ResizeDueToAutoResize(this, new_size);
2569 } 2569 }
2570 2570
2571 WebContents* WebContentsImpl::OpenURL(const OpenURLParams& params) { 2571 WebContents* WebContentsImpl::OpenURL(const OpenURLParams& params) {
2572 if (!delegate_) 2572 if (!delegate_)
2573 return NULL; 2573 return NULL;
2574 2574
2575 WebContents* new_contents = delegate_->OpenURLFromTab(this, params); 2575 WebContents* new_contents = delegate_->OpenURLFromTab(this, params);
2576
2577 RenderFrameHost* render_frame_host =
2578 RenderFrameHost::FromID(params.process_id, params.frame_id);
2579
2580 if (new_contents && new_contents != this) {
nasko 2017/02/14 00:10:23 The old code included a null check for the render_
Patrick Noland 2017/02/14 01:16:16 Done.
2581 for (auto& observer : observers_) {
2582 observer.DidOpenRequestedURL(new_contents, render_frame_host, params.url,
2583 params.referrer, params.disposition,
2584 params.transition,
2585 params.started_from_context_menu);
2586 }
2587 }
2588
2576 return new_contents; 2589 return new_contents;
2577 } 2590 }
2578 2591
2579 bool WebContentsImpl::Send(IPC::Message* message) { 2592 bool WebContentsImpl::Send(IPC::Message* message) {
2580 if (!GetRenderViewHost()) { 2593 if (!GetRenderViewHost()) {
2581 delete message; 2594 delete message;
2582 return false; 2595 return false;
2583 } 2596 }
2584 2597
2585 return GetRenderViewHost()->Send(message); 2598 return GetRenderViewHost()->Send(message);
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
3373 NotifyNavigationStateChanged(changed_flags); 3386 NotifyNavigationStateChanged(changed_flags);
3374 } 3387 }
3375 3388
3376 void WebContentsImpl::DidStartNavigationToPendingEntry(const GURL& url, 3389 void WebContentsImpl::DidStartNavigationToPendingEntry(const GURL& url,
3377 ReloadType reload_type) { 3390 ReloadType reload_type) {
3378 // Notify observers about navigation. 3391 // Notify observers about navigation.
3379 for (auto& observer : observers_) 3392 for (auto& observer : observers_)
3380 observer.DidStartNavigationToPendingEntry(url, reload_type); 3393 observer.DidStartNavigationToPendingEntry(url, reload_type);
3381 } 3394 }
3382 3395
3383 void WebContentsImpl::RequestOpenURL(RenderFrameHostImpl* render_frame_host,
3384 const OpenURLParams& params) {
3385 // OpenURL can blow away the source RFH. Use the process/frame routing ID as a
3386 // weak pointer of sorts.
3387 const int32_t process_id = render_frame_host->GetProcess()->GetID();
3388 const int32_t frame_id = render_frame_host->GetRoutingID();
3389
3390 WebContents* new_contents = OpenURL(params);
3391
3392 if (new_contents && RenderFrameHost::FromID(process_id, frame_id)) {
3393 // Notify observers.
3394 for (auto& observer : observers_) {
3395 observer.DidOpenRequestedURL(new_contents, render_frame_host, params.url,
3396 params.referrer, params.disposition,
3397 params.transition);
3398 }
3399 }
3400 }
3401
3402 bool WebContentsImpl::ShouldTransferNavigation(bool is_main_frame_navigation) { 3396 bool WebContentsImpl::ShouldTransferNavigation(bool is_main_frame_navigation) {
3403 if (!delegate_) 3397 if (!delegate_)
3404 return true; 3398 return true;
3405 return delegate_->ShouldTransferNavigation(is_main_frame_navigation); 3399 return delegate_->ShouldTransferNavigation(is_main_frame_navigation);
3406 } 3400 }
3407 3401
3408 bool WebContentsImpl::ShouldPreserveAbortedURLs() { 3402 bool WebContentsImpl::ShouldPreserveAbortedURLs() {
3409 if (!delegate_) 3403 if (!delegate_)
3410 return false; 3404 return false;
3411 return delegate_->ShouldPreserveAbortedURLs(this); 3405 return delegate_->ShouldPreserveAbortedURLs(this);
(...skipping 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after
5411 GetMainFrame()->AddMessageToConsole( 5405 GetMainFrame()->AddMessageToConsole(
5412 content::CONSOLE_MESSAGE_LEVEL_WARNING, 5406 content::CONSOLE_MESSAGE_LEVEL_WARNING,
5413 base::StringPrintf("This site does not have a valid SSL " 5407 base::StringPrintf("This site does not have a valid SSL "
5414 "certificate! Without SSL, your site's and " 5408 "certificate! Without SSL, your site's and "
5415 "visitors' data is vulnerable to theft and " 5409 "visitors' data is vulnerable to theft and "
5416 "tampering. Get a valid SSL certificate before" 5410 "tampering. Get a valid SSL certificate before"
5417 " releasing your website to the public.")); 5411 " releasing your website to the public."));
5418 } 5412 }
5419 5413
5420 } // namespace content 5414 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698