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

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: Fix gyp 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/web/public/load_committed_details.h"
8 #include "ios/web/public/web_state/web_state.h"
9
10 namespace web {
11
12 WebStateObserver::WebStateObserver(WebState* web_state) : web_state_(nullptr) {
13 Observe(web_state);
14 }
15
16 WebStateObserver::WebStateObserver() : web_state_(nullptr) {
17 }
18
19 WebStateObserver::~WebStateObserver() {
20 if (web_state_)
21 web_state_->RemoveObserver(this);
22 }
23
24 void WebStateObserver::Observe(WebState* web_state) {
25 if (web_state == web_state_) {
26 // Early exit to avoid infinite loops if we're in the middle of a callback.
27 return;
28 }
29 if (web_state_)
30 web_state_->RemoveObserver(this);
31 web_state_ = web_state;
32 if (web_state_)
33 web_state_->AddObserver(this);
34 }
35
36 void WebStateObserver::ResetWebState() {
37 web_state_->RemoveObserver(this);
38 web_state_ = nullptr;
39 }
40
41 } // namespace web
OLDNEW
« ios/web/public/web_state/web_state_observer.h ('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