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

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

Issue 777183002: Upstream iOS web API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup 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/web_state/web_state.h ('k') | ios/web/web_state/web_state.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_user_data.h
diff --git a/ios/public/provider/web/web_state_user_data.h b/ios/web/public/web_state/web_state_user_data.h
similarity index 68%
rename from ios/public/provider/web/web_state_user_data.h
rename to ios/web/public/web_state/web_state_user_data.h
index 17d2fab6f90b744fdbe00133444d12e8da0f8cb9..e8ec8a86067af530828ee185e6b9834e12ef64c1 100644
--- a/ios/public/provider/web/web_state_user_data.h
+++ b/ios/web/public/web_state/web_state_user_data.h
@@ -2,32 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef IOS_PUBLIC_PROVIDER_WEB_WEB_STATE_USER_DATA_H_
-#define IOS_PUBLIC_PROVIDER_WEB_WEB_STATE_USER_DATA_H_
+#ifndef IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_USER_DATA_H_
+#define IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_USER_DATA_H_
-#include "ios/public/consumer/base/supports_user_data.h"
-#include "ios/public/provider/web/web_state.h"
+#include "base/supports_user_data.h"
+#include "ios/web/public/web_state/web_state.h"
-namespace ios {
+namespace web {
// A base class for classes attached to, and scoped to, the lifetime of a
// WebState. For example:
//
// --- in foo.h ---
-// class Foo : public ios::WebStateUserData<Foo> {
+// class Foo : public WebStateUserData<Foo> {
sdefresne 2014/12/05 15:32:51 Please keep this as "// class Foo : public web::We
// public:
// virtual ~Foo();
// // ... more public stuff here ...
// private:
-// explicit Foo(ios::WebState* web_state);
sdefresne 2014/12/05 15:32:51 Same here, web::WebState.
-// friend class ios::WebStateUserData<Foo>;
sdefresne 2014/12/05 15:32:51 Same here, web::WebState.
+// explicit Foo(WebState* web_state);
+// friend class WebStateUserData<Foo>;
// // ... more private stuff here ...
// }
// --- in foo.cc ---
// DEFINE_WEB_CONTENTS_USER_DATA_KEY(Foo);
//
template <typename T>
-class WebStateUserData : public ios::SupportsUserData::Data {
+class WebStateUserData : public base::SupportsUserData::Data {
public:
// Creates an object of type T, and attaches it to the specified WebState.
// If an instance is already attached, does nothing.
@@ -45,11 +45,13 @@ class WebStateUserData : public ios::SupportsUserData::Data {
static const T* FromWebState(const WebState* web_state) {
return static_cast<const T*>(web_state->GetUserData(UserDataKey()));
}
+ // Removes the instance attached to the specified WebState.
+ static void RemoveFromWebState(WebState* web_state) {
+ web_state->RemoveUserData(UserDataKey());
+ }
protected:
- static inline void* UserDataKey() {
- return &kLocatorKey;
- }
+ static inline void* UserDataKey() { return &kLocatorKey; }
private:
// The user data key.
@@ -64,9 +66,9 @@ class WebStateUserData : public ios::SupportsUserData::Data {
// specialization. (C++98: 14.7.3.15; C++11: 14.7.3.13)
//
#define DEFINE_WEB_STATE_USER_DATA_KEY(TYPE) \
-template<> \
-int ios::WebStateUserData<TYPE>::kLocatorKey = 0
+ template <> \
+ int web::WebStateUserData<TYPE>::kLocatorKey = 0
-} // namespace ios
+} // namespace web
-#endif // IOS_PUBLIC_PROVIDER_WEB_WEB_STATE_USER_DATA_H_
+#endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_USER_DATA_H_
« no previous file with comments | « ios/web/public/web_state/web_state.h ('k') | ios/web/web_state/web_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698