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

Side by Side Diff: ios/web/web_state/web_state_observer.cc

Issue 780873002: Upstream iOS web code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
(Empty)
1 // Copyright 2014 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.
4
5 #include "ios/web/public/web_state/web_state_observer.h"
6
7 #include "ios/public/provider/web/web_state.h"
8 #include "ios/web/public/load_committed_details.h"
9
10 namespace web {
11
12 WebStateObserver::WebStateObserver(ios::WebState* web_state)
13 : web_state_(nullptr) {
14 Observe(web_state);
15 }
16
17 WebStateObserver::WebStateObserver() : web_state_(nullptr) {
18 }
19
20 WebStateObserver::~WebStateObserver() {
21 if (web_state_)
22 web_state_->RemoveObserver(this);
23 }
24
25 void WebStateObserver::Observe(ios::WebState* web_state) {
26 if (web_state == web_state_) {
27 // Early exit to avoid infinite loops if we're in the middle of a callback.
28 return;
29 }
30 if (web_state_)
31 web_state_->RemoveObserver(this);
32 web_state_ = web_state;
33 if (web_state_)
34 web_state_->AddObserver(this);
35 }
36
37 void WebStateObserver::ResetWebState() {
38 web_state_->RemoveObserver(this);
39 web_state_ = NULL;
stuartmorgan 2014/12/04 23:22:58 Could you change this to nullptr?
40 }
41
42 } // namespace web
OLDNEW
« ios/web/string_util_unittest.cc ('K') | « ios/web/string_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698