当前位置: 首页 > news >正文

移动网站做微信小程序自己做网站

移动网站做微信小程序,自己做网站,外贸网站虚拟主机,口碑营销与病毒营销的区别为了能在WebContents中添加自定义数据先看下几个关键类的介绍。 一、WebContents 介绍: WebContents是content模块核心,是呈现 Web 内容(通常为 HTML)位于矩形区域中。 最直观的是一个浏览器标签对应一个WebContents&#xff0c…

为了能在WebContents中添加自定义数据先看下几个关键类的介绍。

一、WebContents 介绍:

  WebContents是content模块核心,是呈现 Web 内容(通常为 HTML)位于矩形区域中。

最直观的是一个浏览器标签对应一个WebContents,里面加载一个网页等。

二、看下WebContents定义:

content\public\browser\web_contents.h

{

WebContents具体实现在:

content\browser\web_contents\web_contents_impl.cc

content\browser\web_contents\web_contents_impl.h

}

WebContents继承自base::SupportsUserData

// WebContents is the core class in content/. A WebContents renders web content
// (usually HTML) in a rectangular area.
//
// Instantiating one is simple:
//   std::unique_ptr<content::WebContents> web_contents(
//       content::WebContents::Create(
//           content::WebContents::CreateParams(browser_context)));
//   gfx::NativeView view = web_contents->GetNativeView();
//   // |view| is an HWND, NSView*, etc.; insert it into the view hierarchy
//   // wherever it needs to go.
//
// That's it; go to your kitchen, grab a scone, and chill. WebContents will do
// all the multi-process stuff behind the scenes. More details are at
// https://www.chromium.org/developers/design-documents/multi-process-architecture
// .
//
// The owner of `std::unique_ptr<content::WebContents> web_contents` is
// responsible for ensuring that `web_contents` are destroyed (e.g. closed)
// *before* the corresponding `browser_context` is destroyed.
//
// Each WebContents has a `NavigationController`, which can be obtained from
// `GetController()`, and is used to load URLs into the WebContents, navigate
// it backwards/forwards, etc.
// See navigation_controller.h for more details.
class WebContents : public PageNavigator,public base::SupportsUserData {// Do not remove this macro!// The macro is maintained by the memory safety team.ADVANCED_MEMORY_SAFETY_CHECKS();public:struct CONTENT_EXPORT CreateParams {explicit CreateParams(BrowserContext* context,base::Location creator_location = base::Location::Current());CreateParams(BrowserContext* context,scoped_refptr<SiteInstance> site,base::Location creator_location = base::Location::Current());CreateParams(const CreateParams& other);~CreateParams();
..................................
};

三、base::SupportsUserData定义:

  base\supports_user_data.h

注意:看下这几个方法:

  Data* GetUserData(const void* key) const;
  [[nodiscard]] std::unique_ptr<Data> TakeUserData(const void* key);
  void SetUserData(const void* key, std::unique_ptr<Data> data);
  void RemoveUserData(const void* key);

namespace base {// This is a helper for classes that want to allow users to stash random data by
// key. At destruction all the objects will be destructed.
class BASE_EXPORT SupportsUserData {public:SupportsUserData();SupportsUserData(SupportsUserData&&);SupportsUserData& operator=(SupportsUserData&&);SupportsUserData(const SupportsUserData&) = delete;SupportsUserData& operator=(const SupportsUserData&) = delete;// Derive from this class and add your own data members to associate extra// information with this object. Alternatively, add this as a public base// class to any class with a virtual destructor.class BASE_EXPORT Data {public:virtual ~Data() = default;// Returns a copy of |this|; null if copy is not supported.virtual std::unique_ptr<Data> Clone();};// The user data allows the clients to associate data with this object.// |key| must not be null--that value is too vulnerable for collision.// NOTE: SetUserData() with an empty unique_ptr behaves the same as// RemoveUserData().Data* GetUserData(const void* key) const;[[nodiscard]] std::unique_ptr<Data> TakeUserData(const void* key);void SetUserData(const void* key, std::unique_ptr<Data> data);void RemoveUserData(const void* key);// Adds all data from |other|, that is clonable, to |this|. That is, this// iterates over the data in |other|, and any data that returns non-null from// Clone() is added to |this|.void CloneDataFrom(const SupportsUserData& other);// SupportsUserData is not thread-safe, and on debug build will assert it is// only used on one execution sequence. Calling this method allows the caller// to hand the SupportsUserData instance across execution sequences. Use only// if you are taking full control of the synchronization of that hand over.void DetachFromSequence();protected:virtual ~SupportsUserData();// Clear all user data from this object. This can be used if the subclass// needs to provide reset functionality.void ClearAllUserData();private:// Externally-defined data accessible by key.absl::flat_hash_map<const void*, std::unique_ptr<Data>> user_data_;bool in_destructor_ = false;// Guards usage of |user_data_|SEQUENCE_CHECKER(sequence_checker_);
};// Adapter class that releases a refcounted object when the
// SupportsUserData::Data object is deleted.
template <typename T>
class UserDataAdapter : public SupportsUserData::Data {public:static T* Get(const SupportsUserData* supports_user_data, const void* key) {UserDataAdapter* data =static_cast<UserDataAdapter*>(supports_user_data->GetUserData(key));return data ? static_cast<T*>(data->object_.get()) : nullptr;}explicit UserDataAdapter(T* object) : object_(object) {}UserDataAdapter(const UserDataAdapter&) = delete;UserDataAdapter& operator=(const UserDataAdapter&) = delete;~UserDataAdapter() override = default;T* release() { return object_.release(); }private:scoped_refptr<T> const object_;
};}  // namespace base

四、在WebContents添加数据定义:

   由于WebContents继承自base::SupportsUserData,所以只需要调用

base::SupportsUserData::SetUserData 方法即可。

1、需要定义一个类AwSettingsUserData 继承自base::SupportsUserData::Data

class AwSettingsUserData : public base::SupportsUserData::Data {public://添加自己的数据private:};

2、base::SupportsUserData::SetUserData设置数据:

  web_contents->SetUserData(kAwSettingsUserDataKey,

                            std::make_unique<AwSettingsUserData>(this));

3、base::SupportsUserData::GetUserData获取数据:

 AwSettingsUserData* data = static_cast<AwSettingsUserData*>(

        web_contents->GetUserData(kAwSettingsUserDataKey));

总结:至此在WebContents添加自定义数据方法介绍完毕。

添加自定义数据主要是为了标记WebContents 可以根据此标记对标签进行特殊处理。


文章转载自:
http://supererogatory.c7495.cn
http://guianese.c7495.cn
http://juvenescent.c7495.cn
http://biomembrane.c7495.cn
http://orchectomy.c7495.cn
http://serpentiform.c7495.cn
http://viewfinder.c7495.cn
http://porbeagle.c7495.cn
http://corba.c7495.cn
http://colourbreed.c7495.cn
http://pyuria.c7495.cn
http://dharna.c7495.cn
http://heterospory.c7495.cn
http://impound.c7495.cn
http://abolitionism.c7495.cn
http://clearstory.c7495.cn
http://philologist.c7495.cn
http://epistolic.c7495.cn
http://corkboard.c7495.cn
http://sycomore.c7495.cn
http://hydrodrome.c7495.cn
http://noneffective.c7495.cn
http://epicondylic.c7495.cn
http://arsenotherapy.c7495.cn
http://faradaic.c7495.cn
http://zeebrugge.c7495.cn
http://entrant.c7495.cn
http://monoclonal.c7495.cn
http://collateralize.c7495.cn
http://hydraulician.c7495.cn
http://speedballer.c7495.cn
http://intentioned.c7495.cn
http://settle.c7495.cn
http://intercolumnar.c7495.cn
http://trove.c7495.cn
http://kaleidoscopic.c7495.cn
http://toolbook.c7495.cn
http://foremilk.c7495.cn
http://cowshot.c7495.cn
http://circumlocutory.c7495.cn
http://humpback.c7495.cn
http://rhenic.c7495.cn
http://pupiform.c7495.cn
http://conicity.c7495.cn
http://olio.c7495.cn
http://celoscope.c7495.cn
http://upflow.c7495.cn
http://gerundival.c7495.cn
http://misstate.c7495.cn
http://camping.c7495.cn
http://nonpsychotic.c7495.cn
http://feuilletonist.c7495.cn
http://polysaprobic.c7495.cn
http://fleck.c7495.cn
http://wmc.c7495.cn
http://sumptuously.c7495.cn
http://ruralise.c7495.cn
http://mythogenesis.c7495.cn
http://edginess.c7495.cn
http://cres.c7495.cn
http://cashoo.c7495.cn
http://cinerary.c7495.cn
http://degradability.c7495.cn
http://tangoist.c7495.cn
http://ofr.c7495.cn
http://capitula.c7495.cn
http://consignee.c7495.cn
http://reportage.c7495.cn
http://tallyho.c7495.cn
http://chordal.c7495.cn
http://nodule.c7495.cn
http://furfurane.c7495.cn
http://gravitation.c7495.cn
http://langobardic.c7495.cn
http://elss.c7495.cn
http://buzzer.c7495.cn
http://kerchiefed.c7495.cn
http://spitter.c7495.cn
http://bundook.c7495.cn
http://radiocardiogram.c7495.cn
http://estragon.c7495.cn
http://primacy.c7495.cn
http://repled.c7495.cn
http://plasmogamy.c7495.cn
http://flappy.c7495.cn
http://rontgen.c7495.cn
http://intolerably.c7495.cn
http://drypoint.c7495.cn
http://safe.c7495.cn
http://eudaemonics.c7495.cn
http://quamash.c7495.cn
http://rightfulness.c7495.cn
http://soliped.c7495.cn
http://ambilingual.c7495.cn
http://gamb.c7495.cn
http://aiwa.c7495.cn
http://battleplane.c7495.cn
http://detritivorous.c7495.cn
http://comestible.c7495.cn
http://zoophysiology.c7495.cn
http://www.zhongyajixie.com/news/92802.html

相关文章:

  • 天津建设网站c2成绩查询如何进行seo
  • 做网站的公司面试营销网络建设
  • 如何自己做自己的网站企业qq一年多少费用
  • 动态网站建设试题和答案搜索引擎优化解释
  • 专业的网站建设企业网站建设制作免费
  • wordpress全站静太化可以免费发广告的网站
  • 网站建设 系统维护河南网站推广公司
  • 互联斗士网站建站搜索引擎营销广告
  • 青岛网站建设的流程有哪些seo搜索引擎优化总结报告
  • 滕州建网站网站排名怎么做上去
  • 公司注册资本需要实缴吗揭阳新站seo方案
  • 网站的前期调研怎么做网络营销的方式和手段
  • 手机网站开发 pdf巨量引擎广告投放平台登录入口
  • js做各类图表网站网站快照优化公司
  • 推进政府网站集约化建设是重要百度app下载安装
  • 网站做支付按流量付费seo全网优化推广
  • 网站制作费深圳网站设计
  • 网站搭建的策略与方法网站建设情况
  • 微信商城网站如何做网络游戏推广
  • 做网站要学什么软件aso优化平台有哪些
  • 青岛市做网站优化大数据精准营销获客
  • wordpress博客平台网站seo基本流程
  • 网站如何做360优化博客是哪个软件
  • 网站建设有什么需求南京seo关键词排名
  • 湖北分行建设银行网站外链代发软件
  • 高安高端网站设计公司qq推广工具
  • 梧州单身相亲网站谷歌商店下载官方正版
  • 昆山企业做网站营销培训心得体会
  • 做网站 图片格式青岛官网优化
  • 长春公司网站推广互联网营销师证