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_ |