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

Side by Side Diff: ios/web/web_state/web_state_impl.mm

Issue 1874903003: Reversed WebState <-> CRWWebController ownership. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self review Created 4 years, 8 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 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 "ios/web/web_state/web_state_impl.h" 5 #include "ios/web/web_state/web_state_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
11 #include "ios/web/interstitials/web_interstitial_impl.h" 11 #include "ios/web/interstitials/web_interstitial_impl.h"
12 #import "ios/web/navigation/crw_session_controller.h" 12 #import "ios/web/navigation/crw_session_controller.h"
13 #import "ios/web/navigation/crw_session_entry.h" 13 #import "ios/web/navigation/crw_session_entry.h"
14 #include "ios/web/navigation/navigation_item_impl.h" 14 #include "ios/web/navigation/navigation_item_impl.h"
15 #include "ios/web/net/request_group_util.h" 15 #include "ios/web/net/request_group_util.h"
16 #include "ios/web/public/browser_state.h" 16 #include "ios/web/public/browser_state.h"
17 #include "ios/web/public/navigation_item.h" 17 #include "ios/web/public/navigation_item.h"
18 #include "ios/web/public/url_util.h" 18 #include "ios/web/public/url_util.h"
19 #include "ios/web/public/web_client.h" 19 #include "ios/web/public/web_client.h"
20 #include "ios/web/public/web_state/credential.h" 20 #include "ios/web/public/web_state/credential.h"
21 #include "ios/web/public/web_state/ui/crw_content_view.h" 21 #include "ios/web/public/web_state/ui/crw_content_view.h"
22 #include "ios/web/public/web_state/web_state_observer.h" 22 #include "ios/web/public/web_state/web_state_observer.h"
23 #include "ios/web/public/web_state/web_state_policy_decider.h" 23 #include "ios/web/public/web_state/web_state_policy_decider.h"
24 #include "ios/web/web_state/global_web_state_event_tracker.h" 24 #include "ios/web/web_state/global_web_state_event_tracker.h"
25 #import "ios/web/web_state/ui/crw_web_controller.h" 25 #import "ios/web/web_state/ui/crw_web_controller.h"
26 #import "ios/web/web_state/ui/crw_web_controller_container_view.h" 26 #import "ios/web/web_state/ui/crw_web_controller_container_view.h"
27 #import "ios/web/web_state/ui/crw_wk_web_view_web_controller.h"
27 #include "ios/web/web_state/web_state_facade_delegate.h" 28 #include "ios/web/web_state/web_state_facade_delegate.h"
28 #import "ios/web/webui/web_ui_ios_controller_factory_registry.h" 29 #import "ios/web/webui/web_ui_ios_controller_factory_registry.h"
29 #import "ios/web/webui/web_ui_ios_impl.h" 30 #import "ios/web/webui/web_ui_ios_impl.h"
30 #include "net/http/http_response_headers.h" 31 #include "net/http/http_response_headers.h"
31 32
32 namespace web { 33 namespace web {
33 34
34 WebStateImpl::WebStateImpl(BrowserState* browser_state) 35 WebStateImpl::WebStateImpl(BrowserState* browser_state)
35 : is_loading_(false), 36 : is_loading_(false),
36 is_being_destroyed_(false), 37 is_being_destroyed_(false),
37 facade_delegate_(nullptr), 38 facade_delegate_(nullptr),
38 web_controller_(nil), 39 web_controller_(nil),
39 navigation_manager_(this, browser_state), 40 navigation_manager_(this, browser_state),
40 interstitial_(nullptr), 41 interstitial_(nullptr),
41 weak_factory_(this) { 42 weak_factory_(this) {
42 GlobalWebStateEventTracker::GetInstance()->OnWebStateCreated(this); 43 GlobalWebStateEventTracker::GetInstance()->OnWebStateCreated(this);
44 web_controller_.reset(
45 [[CRWWKWebViewWebController alloc] initWithWebState:this]);
43 } 46 }
44 47
45 WebStateImpl::~WebStateImpl() { 48 WebStateImpl::~WebStateImpl() {
49 [web_controller_ close];
46 is_being_destroyed_ = true; 50 is_being_destroyed_ = true;
47 51
48 // WebUI depends on web state so it must be destroyed first in case any WebUI 52 // WebUI depends on web state so it must be destroyed first in case any WebUI
49 // implementations depends on accessing web state during destruction. 53 // implementations depends on accessing web state during destruction.
50 ClearWebUI(); 54 ClearWebUI();
51 55
52 // The facade layer (owned by the delegate) should be destroyed before the web 56 // The facade layer (owned by the delegate) should be destroyed before the web
53 // layer. 57 // layer.
54 DCHECK(!facade_delegate_); 58 DCHECK(!facade_delegate_);
55 59
(...skipping 30 matching lines...) Expand all
86 // deciders. This makes the call here odd looking, but it's really just 90 // deciders. This makes the call here odd looking, but it's really just
87 // managing the list, not setting observers on deciders. 91 // managing the list, not setting observers on deciders.
88 DCHECK(policy_deciders_.HasObserver(decider)); 92 DCHECK(policy_deciders_.HasObserver(decider));
89 policy_deciders_.RemoveObserver(decider); 93 policy_deciders_.RemoveObserver(decider);
90 } 94 }
91 95
92 bool WebStateImpl::Configured() const { 96 bool WebStateImpl::Configured() const {
93 return web_controller_ != nil; 97 return web_controller_ != nil;
94 } 98 }
95 99
100 CRWWebController* WebStateImpl::GetWebController() {
101 return web_controller_;
102 }
103
96 void WebStateImpl::SetWebController(CRWWebController* web_controller) { 104 void WebStateImpl::SetWebController(CRWWebController* web_controller) {
97 DCHECK(!web_controller_); 105 [web_controller_ close];
kkhorimoto 2016/04/12 21:36:13 DCHECK_EQ(this, web_controller.webState)? We migh
Eugene But (OOO till 7-30) 2016/04/13 02:51:26 SetWebController is used only in unit tests and in
98 web_controller_ = web_controller; 106 web_controller_.reset([web_controller retain]);
99 } 107 }
100 108
101 WebStateFacadeDelegate* WebStateImpl::GetFacadeDelegate() const { 109 WebStateFacadeDelegate* WebStateImpl::GetFacadeDelegate() const {
102 return facade_delegate_; 110 return facade_delegate_;
103 } 111 }
104 112
105 void WebStateImpl::SetFacadeDelegate(WebStateFacadeDelegate* facade_delegate) { 113 void WebStateImpl::SetFacadeDelegate(WebStateFacadeDelegate* facade_delegate) {
106 facade_delegate_ = facade_delegate; 114 facade_delegate_ = facade_delegate;
107 } 115 }
108 116
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 const LoadCommittedDetails& load_details) { 570 const LoadCommittedDetails& load_details) {
563 FOR_EACH_OBSERVER(WebStateObserver, observers_, 571 FOR_EACH_OBSERVER(WebStateObserver, observers_,
564 NavigationItemCommitted(load_details)); 572 NavigationItemCommitted(load_details));
565 } 573 }
566 574
567 WebState* WebStateImpl::GetWebState() { 575 WebState* WebStateImpl::GetWebState() {
568 return this; 576 return this;
569 } 577 }
570 578
571 } // namespace web 579 } // namespace web
OLDNEW
« ios/web/web_state/ui/crw_wk_web_view_web_controller.h ('K') | « ios/web/web_state/web_state_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698