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

Unified Diff: ios/web/public/web_state/web_state_observer.h

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/public/string_util.h ('k') | ios/web/string_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/public/web_state/web_state_observer.h
diff --git a/ios/web/public/web_state/web_state_observer.h b/ios/web/public/web_state/web_state_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..f63d06e81e88f66e99160b274529a4074d163493
--- /dev/null
+++ b/ios/web/public/web_state/web_state_observer.h
@@ -0,0 +1,71 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_OBSERVER_H_
+#define IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_OBSERVER_H_
+
+#include "base/macros.h"
+
+namespace web {
+
+struct LoadCommittedDetails;
+class WebState;
+class WebStateImpl;
+
+// An observer API implemented by classes which are interested in various page
+// load events from WebState.
+class WebStateObserver {
+ public:
+ // Returns the web state associated with this observer.
+ WebState* web_state() const { return web_state_; }
tfarina 2014/12/12 18:41:07 this is not fully const-correctness. Could you mak
stuartmorgan 2014/12/12 19:16:45 This matches WebContentsObserver's WebContents get
+
+ // This method is invoked when a new non-pending navigation item is created.
+ // This corresponds to one NavigationManager item being created
+ // (in the case of new navigations) or renavigated to (for back/forward
+ // navigations).
+ virtual void NavigationItemCommitted(
+ const LoadCommittedDetails& load_details) {};
tfarina 2014/12/12 18:41:07 no need of ';' in those virtual methods.
stuartmorgan 2014/12/12 19:19:57 If you find style nits in already-submitted code,
+
+ // Called when the current page is loaded.
+ virtual void PageLoaded() {};
+
+ // Called on URL hash change events.
+ virtual void URLHashChanged() {};
+
+ // Called on history state change events.
+ virtual void HistoryStateChanged() {};
+
+ // Invoked when the WebState is being destroyed. Gives subclasses a chance
+ // to cleanup.
+ virtual void WebStateDestroyed() {}
+
+ protected:
+ // Use this constructor when the object is tied to a single WebState for
+ // its entire lifetime.
+ explicit WebStateObserver(WebState* web_state);
+
+ // Use this constructor when the object wants to observe a WebState for
+ // part of its lifetime. It can then call Observe() to start and stop
+ // observing.
+ WebStateObserver();
+
+ virtual ~WebStateObserver();
+
+ // Start observing a different WebState; used with the default constructor.
+ void Observe(WebState* web_state);
+
+ private:
+ friend class WebStateImpl;
+
+ // Stops observing the current web state.
+ void ResetWebState();
+
+ WebState* web_state_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebStateObserver);
+};
+
+} // namespace web
+
+#endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_OBSERVER_H_
« no previous file with comments | « ios/web/public/string_util.h ('k') | ios/web/string_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698