1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/frame_host/navigation_handle_impl.h"
7 #include "content/browser/frame_host/navigator_delegate.h"
8 #include "net/url_request/redirect_info.h"
13 scoped_ptr
<NavigationHandleImpl
> NavigationHandleImpl::Create(
15 const bool is_main_frame
,
16 NavigatorDelegate
* delegate
) {
17 return scoped_ptr
<NavigationHandleImpl
>(
18 new NavigationHandleImpl(url
, is_main_frame
, delegate
));
21 NavigationHandleImpl::NavigationHandleImpl(const GURL
& url
,
22 const bool is_main_frame
,
23 NavigatorDelegate
* delegate
)
25 net_error_code_(net::OK
),
27 is_main_frame_(is_main_frame
),
28 is_transferring_(false),
30 delegate_
->DidStartNavigation(this);
33 NavigationHandleImpl::~NavigationHandleImpl() {
34 delegate_
->DidFinishNavigation(this);
37 const GURL
& NavigationHandleImpl::GetURL() const {
41 net::Error
NavigationHandleImpl::GetNetErrorCode() const {
42 return net_error_code_
;
45 bool NavigationHandleImpl::IsInMainFrame() const {
46 return is_main_frame_
;
49 bool NavigationHandleImpl::HasCommittedDocument() const {
50 return state_
== DID_COMMIT
;
53 bool NavigationHandleImpl::HasCommittedErrorPage() const {
54 return state_
== DID_COMMIT_ERROR_PAGE
;
57 void NavigationHandleImpl::DidRedirectNavigation(const GURL
& new_url
) {
59 delegate_
->DidRedirectNavigation(this);
62 void NavigationHandleImpl::DidCommitNavigation() {
63 state_
= net_error_code_
== net::OK
? DID_COMMIT
: DID_COMMIT_ERROR_PAGE
;
64 delegate_
->DidCommitNavigation(this);
67 } // namespace content