Chromium Code Reviews| 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..78bc2b2fb065a42e84abb353fe504757665b169e |
| --- /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 ios { |
| +class WebState; |
| +} |
| + |
| +namespace web { |
| + |
| +struct LoadCommittedDetails; |
| + |
| +class WebStateObserver { |
|
stuartmorgan
2014/12/04 23:22:58
Whoops :( Could you add a class-level comment whil
|
| + public: |
| + // Returns the web state associated with this observer. |
| + ios::WebState* web_state() const { return web_state_; } |
| + |
| + // 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) {}; |
| + |
| + // 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(ios::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(ios::WebState* web_state); |
| + |
| + private: |
| + friend class WebStateImpl; |
|
stuartmorgan
2014/12/04 23:22:58
Shouldn't there be a forward declaration for this
|
| + |
| + // Stops observing the current web state. |
| + void ResetWebState(); |
| + |
| + ios::WebState* web_state_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WebStateObserver); |
| +}; |
| + |
| +} // namespace web |
| + |
| +#endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_OBSERVER_H_ |