From 47a372a466cf229b92b9fbb7fcc3b6768af70b68 Mon Sep 17 00:00:00 2001 From: Arnaud Renevier Date: Fri, 23 May 2014 15:41:49 -0700 Subject: [PATCH] Add Tizen-platform implementation of ContentClient This directory contains IPC messages from the renderer to the browser process and vice versa. It also contains EFL implementation of ContentClient. And util functions to get a WebContents from a render view id or from a frame id. impl/common/version_info.h is a copy of src/chrome/common/chrome_version_info.h Change-Id: If485df0c62defac9c3aef4d334f156a2e1a04985 --- tizen_src/impl/chromium-efl.gyp | 10 ++ tizen_src/impl/common/content_client_efl.cc | 23 +++ tizen_src/impl/common/content_client_efl.h | 15 ++ tizen_src/impl/common/message_generator_efl.cc | 29 ++++ tizen_src/impl/common/message_generator_efl.h | 5 + tizen_src/impl/common/render_messages_efl.h | 227 +++++++++++++++++++++++++ tizen_src/impl/common/version_info.cc | 89 ++++++++++ tizen_src/impl/common/version_info.h | 109 ++++++++++++ tizen_src/impl/common/version_info_efl.h | 23 +++ tizen_src/impl/common/web_contents_utils.cc | 40 +++++ tizen_src/impl/common/web_contents_utils.h | 14 ++ 11 files changed, 584 insertions(+) create mode 100644 tizen_src/impl/common/content_client_efl.cc create mode 100644 tizen_src/impl/common/content_client_efl.h create mode 100644 tizen_src/impl/common/message_generator_efl.cc create mode 100644 tizen_src/impl/common/message_generator_efl.h create mode 100644 tizen_src/impl/common/render_messages_efl.h create mode 100644 tizen_src/impl/common/version_info.cc create mode 100644 tizen_src/impl/common/version_info.h create mode 100644 tizen_src/impl/common/version_info_efl.h create mode 100644 tizen_src/impl/common/web_contents_utils.cc create mode 100644 tizen_src/impl/common/web_contents_utils.h diff --git a/tizen_src/impl/chromium-efl.gyp b/tizen_src/impl/chromium-efl.gyp index aa059fe..0389568 100644 --- a/tizen_src/impl/chromium-efl.gyp +++ b/tizen_src/impl/chromium-efl.gyp @@ -56,6 +56,16 @@ 'browser/renderer_host/native_web_keyboard_event_efl.cc', 'command_line_efl.cc', 'command_line_efl.h', + 'common/content_client_efl.cc', + 'common/content_client_efl.h', + 'common/message_generator_efl.cc', + 'common/message_generator_efl.h', + 'common/render_messages_efl.h', + 'common/version_info.cc', + 'common/version_info.h', + 'common/version_info_efl.h', + 'common/web_contents_utils.cc', + 'common/web_contents_utils.h', 'network_delegate_efl.cc', 'network_delegate_efl.h', 'paths_efl.cc', diff --git a/tizen_src/impl/common/content_client_efl.cc b/tizen_src/impl/common/content_client_efl.cc new file mode 100644 index 0000000..9629938 --- /dev/null +++ b/tizen_src/impl/common/content_client_efl.cc @@ -0,0 +1,23 @@ +#include "common/content_client_efl.h" + +#include "base/basictypes.h" +#include "base/command_line.h" +#include "content/public/common/content_switches.h" +#include "common/version_info.h" +#include "webkit/common/user_agent/user_agent_util.h" + +std::string ContentClientEfl::GetProduct() const +{ + return EflWebView::VersionInfo::GetInstance()->ProductNameAndVersionForUserAgent(); +} + +std::string ContentClientEfl::GetUserAgent() const +{ + std::string product = GetProduct(); + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kUseMobileUserAgent)) { + product += " Mobile"; + } + return webkit_glue::BuildUserAgentFromOSAndProduct(EflWebView::VersionInfo::GetInstance()->OSType(), + product); +} diff --git a/tizen_src/impl/common/content_client_efl.h b/tizen_src/impl/common/content_client_efl.h new file mode 100644 index 0000000..7625324 --- /dev/null +++ b/tizen_src/impl/common/content_client_efl.h @@ -0,0 +1,15 @@ +#ifndef CONTENT_CLIENT_EFL_H_ +#define CONTENT_CLIENT_EFL_H_ + +#include "content/public/common/content_client.h" + +#include "base/compiler_specific.h" + +class ContentClientEfl : public content::ContentClient { + public: + // ContentClient implementation. + virtual std::string GetProduct() const OVERRIDE; + virtual std::string GetUserAgent() const OVERRIDE; +}; + +#endif // CONTENT_CLIENT_EFL_H_ diff --git a/tizen_src/impl/common/message_generator_efl.cc b/tizen_src/impl/common/message_generator_efl.cc new file mode 100644 index 0000000..5deed98 --- /dev/null +++ b/tizen_src/impl/common/message_generator_efl.cc @@ -0,0 +1,29 @@ +// Get basic type definitions. +#define IPC_MESSAGE_IMPL +#include "common/message_generator_efl.h" + +// Generate constructors. +#include "ipc/struct_constructor_macros.h" +#include "common/message_generator_efl.h" + +// Generate destructors. +#include "ipc/struct_destructor_macros.h" +#include "common/message_generator_efl.h" + +// Generate param traits write methods. +#include "ipc/param_traits_write_macros.h" +namespace IPC { +#include "common/message_generator_efl.h" +} // namespace IPC + +// Generate param traits read methods. +#include "ipc/param_traits_read_macros.h" +namespace IPC { +#include "common/message_generator_efl.h" +} // namespace IPC + +// Generate param traits log methods. +#include "ipc/param_traits_log_macros.h" +namespace IPC { +#include "common/message_generator_efl.h" +} // namespace IPC diff --git a/tizen_src/impl/common/message_generator_efl.h b/tizen_src/impl/common/message_generator_efl.h new file mode 100644 index 0000000..769b89f --- /dev/null +++ b/tizen_src/impl/common/message_generator_efl.h @@ -0,0 +1,5 @@ +// Multiply-included file, hence no include guard. +// efl message generator + +#include "common/render_messages_efl.h" +#include "components/editing/content/common/editing_messages.h" diff --git a/tizen_src/impl/common/render_messages_efl.h b/tizen_src/impl/common/render_messages_efl.h new file mode 100644 index 0000000..b965c74 --- /dev/null +++ b/tizen_src/impl/common/render_messages_efl.h @@ -0,0 +1,227 @@ +// Multiply-included file, no traditional include guard. + +#include "base/values.h" +#include "ipc/ipc_message_macros.h" +#include "ipc/ipc_channel_handle.h" +#include "content/public/common/common_param_traits.h" +#include "content/public/common/referrer.h" +#include "API/ewk_hit_test_private.h" +#include "API/ewk_text_style_private.h" +#include "API/ewk_ipc_message_private.h" +#include "cache_params_efl.h" +#include "public/ewk_csp_header_type.h" +#include "public/ewk_hit_test.h" +#include "navigation_policy_params.h" +#include "public/ewk_ipc_message.h" +#include "renderer/print_pages_params.h" +#include "third_party/WebKit/public/web/WebNavigationPolicy.h" +#include "third_party/WebKit/public/web/WebNavigationType.h" +#include "url/gurl.h" + +#include + +//----------------------------------------------------------------------------- +// RenderView messages +// These are messages sent from the browser to the renderer process. + +// these messages belong to "chrome messages" in chromium +// we can add our own class for them but then we need to patch ipc/ipc_message_start.h +// so using same message class for these messages. +// but actual messages are different so they shouldn't mess with chrome messages +#define IPC_MESSAGE_START ChromeMsgStart + +IPC_STRUCT_TRAITS_BEGIN(CacheParamsEfl) + IPC_STRUCT_TRAITS_MEMBER(cache_total_capacity) + IPC_STRUCT_TRAITS_MEMBER(cache_min_dead_capacity) + IPC_STRUCT_TRAITS_MEMBER(cache_max_dead_capacity) +IPC_STRUCT_TRAITS_END() + +IPC_ENUM_TRAITS(Ewk_CSP_Header_Type) + +IPC_ENUM_TRAITS(blink::WebNavigationPolicy) +IPC_ENUM_TRAITS(blink::WebNavigationType) + +IPC_STRUCT_TRAITS_BEGIN(NavigationPolicyParams) + IPC_STRUCT_TRAITS_MEMBER(render_view_id) + IPC_STRUCT_TRAITS_MEMBER(url) + IPC_STRUCT_TRAITS_MEMBER(referrer) + IPC_STRUCT_TRAITS_MEMBER(policy) + IPC_STRUCT_TRAITS_MEMBER(type) + IPC_STRUCT_TRAITS_MEMBER(should_replace_current_entry) + IPC_STRUCT_TRAITS_MEMBER(is_main_frame) + IPC_STRUCT_TRAITS_MEMBER(is_redirect) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(SelectionColor) + IPC_STRUCT_TRAITS_MEMBER(r) + IPC_STRUCT_TRAITS_MEMBER(g) + IPC_STRUCT_TRAITS_MEMBER(b) + IPC_STRUCT_TRAITS_MEMBER(a) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(SelectionStylePrams) + IPC_STRUCT_TRAITS_MEMBER(underline_state) + IPC_STRUCT_TRAITS_MEMBER(italic_state) + IPC_STRUCT_TRAITS_MEMBER(bold_state) + IPC_STRUCT_TRAITS_MEMBER(bg_color) + IPC_STRUCT_TRAITS_MEMBER(color) + IPC_STRUCT_TRAITS_MEMBER(font_size) + IPC_STRUCT_TRAITS_MEMBER(order_list_state) + IPC_STRUCT_TRAITS_MEMBER(un_order_list_state) + IPC_STRUCT_TRAITS_MEMBER(text_align_center_state) + IPC_STRUCT_TRAITS_MEMBER(text_align_left_state) + IPC_STRUCT_TRAITS_MEMBER(text_align_right_state) + IPC_STRUCT_TRAITS_MEMBER(text_align_full_state) + IPC_STRUCT_TRAITS_MEMBER(has_composition) +IPC_STRUCT_TRAITS_END() + +IPC_ENUM_TRAITS(Ewk_Hit_Test_Mode) +IPC_ENUM_TRAITS(Ewk_Hit_Test_Result_Context) + +IPC_STRUCT_TRAITS_BEGIN(Ewk_Hit_Test::Hit_Test_Node_Data) + IPC_STRUCT_TRAITS_MEMBER(tagName) + IPC_STRUCT_TRAITS_MEMBER(nodeValue) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(Ewk_Hit_Test::Hit_Test_Image_Buffer) + IPC_STRUCT_TRAITS_MEMBER(fileNameExtension) + IPC_STRUCT_TRAITS_MEMBER(imageBitmap) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(Ewk_Hit_Test) + IPC_STRUCT_TRAITS_MEMBER(context) + IPC_STRUCT_TRAITS_MEMBER(linkURI) + IPC_STRUCT_TRAITS_MEMBER(linkLabel) + IPC_STRUCT_TRAITS_MEMBER(linkTitle) + IPC_STRUCT_TRAITS_MEMBER(imageURI) + IPC_STRUCT_TRAITS_MEMBER(mediaURI) + IPC_STRUCT_TRAITS_MEMBER(isEditable) + IPC_STRUCT_TRAITS_MEMBER(mode) + IPC_STRUCT_TRAITS_MEMBER(nodeData) + IPC_STRUCT_TRAITS_MEMBER(imageData) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(DidPrintPagesParams) + IPC_STRUCT_TRAITS_MEMBER(metafile_data_handle) + IPC_STRUCT_TRAITS_MEMBER(data_size) + IPC_STRUCT_TRAITS_MEMBER(document_cookie) + IPC_STRUCT_TRAITS_MEMBER(filename) +IPC_STRUCT_TRAITS_END() + +IPC_STRUCT_TRAITS_BEGIN(Ewk_IPC_Wrt_Message_Data) + IPC_STRUCT_TRAITS_MEMBER(type) + IPC_STRUCT_TRAITS_MEMBER(value) + IPC_STRUCT_TRAITS_MEMBER(id) + IPC_STRUCT_TRAITS_MEMBER(reference_id) +IPC_STRUCT_TRAITS_END() + +// Tells the renderer to clear the cache. +IPC_MESSAGE_CONTROL0(EflViewMsg_ClearCache) +IPC_MESSAGE_ROUTED0(EwkViewMsg_UseSettingsFont) + +IPC_MESSAGE_CONTROL1(EflViewMsg_SetCache, + CacheParamsEfl) + +// Tells the renderer to dump as much memory as it can, perhaps because we +// have memory pressure or the renderer is (or will be) paged out. This +// should only result in purging objects we can recalculate, e.g. caches or +// JS garbage, not in purging irreplaceable objects. +IPC_MESSAGE_CONTROL0(EwkViewMsg_PurgeMemory) + +IPC_MESSAGE_CONTROL4(EwkViewMsg_SetWidgetInfo, + int, // result: widgetHandle + double, // result: scale + std::string, // result: theme + std::string) // result: encodedBundle + +IPC_MESSAGE_CONTROL1(EwkViewMsg_SendWrtMessage, + Ewk_IPC_Wrt_Message_Data /* data */); + +IPC_MESSAGE_ROUTED0(EwkViewMsg_GetSelectionStyle) + +IPC_MESSAGE_ROUTED2(EwkViewMsg_SetCSP, + std::string, /* policy */ + Ewk_CSP_Header_Type /* header type */) + +IPC_MESSAGE_ROUTED2(EwkViewMsg_SetScroll, + int, /* horizontal position */ + int /* vertical position */) + +IPC_MESSAGE_ROUTED3(EwkViewMsg_DoHitTest, + int, /* horizontal position */ + int, /* vertical position */ + Ewk_Hit_Test_Mode /* mode */) + +IPC_MESSAGE_ROUTED3(EwkViewMsg_PrintToPdf, + int, /* width */ + int, /* height */ + base::FilePath /* file name to save pdf*/) + +// from renderer to browser + +IPC_MESSAGE_ROUTED1(EwkHostMsg_DidPrintPagesToPdf, + DidPrintPagesParams /* pdf document parameters */) + +IPC_SYNC_MESSAGE_CONTROL1_1(EwkHostMsg_DecideNavigationPolicy, + NavigationPolicyParams, + bool /*handled*/) + +IPC_SYNC_MESSAGE_ROUTED0_2(EwkHostMsg_GetContentSecurityPolicy, + std::string, /* policy */ + Ewk_CSP_Header_Type /* header type */) + +IPC_SYNC_MESSAGE_ROUTED1_1(EwkHostMsg_WrtSyncMessage, + Ewk_IPC_Wrt_Message_Data /* data */, + std::string /*result*/); + +IPC_MESSAGE_ROUTED3(EwkViewMsg_Scale, + double, /* scale factor */ + int, /* center x */ + int /* center y */) + +IPC_MESSAGE_ROUTED1(EwkViewMsg_PlainTextGet, + int /* callback id */) + +IPC_MESSAGE_ROUTED2(EwkHostMsg_PlainTextGetContents, + std::string, /* contentText */ + int /* callback id */) + +IPC_MESSAGE_ROUTED1(EwkHostMsg_WrtMessage, + Ewk_IPC_Wrt_Message_Data /* data */); + +IPC_MESSAGE_ROUTED2(EwkHostMsg_DidChangeContentsSize, + int, /* width */ + int /* height */) + +IPC_MESSAGE_ROUTED1(EwkViewMsg_SelectionTextStyleState, + SelectionStylePrams /* params */) + +IPC_MESSAGE_ROUTED2(EwkViewMsg_SelectClosestWord, + int, /* x */ + int /* y */) + +IPC_MESSAGE_ROUTED2(EwkHostMsg_DidChangeMaxScrollOffset, + int, /*max scrollX*/ + int /*max scrollY*/) + +IPC_MESSAGE_CONTROL3(EwkViewHostMsg_HitTestReply, + int, /* render_view_id */ + Ewk_Hit_Test, /* Ewk Hit test data without node map */ + NodeAttributesMap /* node attributes */) + +IPC_MESSAGE_ROUTED1(EwkViewMsg_GetMHTMLData, + int /* callback id */) + +IPC_MESSAGE_ROUTED2(EwkHostMsg_ReadMHTMLData, + std::string, /* Mhtml text */ + int /* callback id */) + +IPC_MESSAGE_ROUTED1(EwkHostMsg_DidChangePageScaleFactor, + double /* page scale factor */) + +IPC_MESSAGE_ROUTED2(EwkHostMsg_DidChangePageScaleRange, + double, /* minimum page scale factor */ + double /* maximum page scale factor */) + +IPC_MESSAGE_ROUTED1(EwkViewMsg_SetDrawsTransparentBackground, + bool /* enabled */) diff --git a/tizen_src/impl/common/version_info.cc b/tizen_src/impl/common/version_info.cc new file mode 100644 index 0000000..f738ac4 --- /dev/null +++ b/tizen_src/impl/common/version_info.cc @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2013 Samsung Electronics. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + */ + +#include "common/version_info.h" + +#include "common/version_info_efl.h" + +namespace EflWebView { + +const char kOSTypeTizen[] = "Tizen"; +const char kOSTypeAndroid[] = "Android"; + +VersionInfo* VersionInfo::version_info_ = NULL; + +VersionInfo* VersionInfo::GetInstance() +{ + if(!version_info_) + version_info_ = new VersionInfo; + return version_info_; +} + +void VersionInfo::DeleteInstance() +{ + if(version_info_) + delete version_info_; + version_info_ = NULL; +} + +VersionInfo::VersionInfo() + : product_name_(PRODUCT_NAME), + product_version_(PRODUCT_VERSION), + fake_android_(true) +{ +} + +void VersionInfo::SetProductName(const std::string& name) +{ + product_name_ = name; +} + +std::string VersionInfo::LastChange() const +{ + return LAST_CHANGE; +} + +bool VersionInfo::IsOfficialBuild() const +{ + return IS_OFFICIAL_BUILD; +} + +std::string VersionInfo::CreateVersionString() const +{ + std::string current_version; + if (is_valid()) { + current_version += Version(); + current_version += " ("; + current_version += " "; + current_version += LastChange(); + current_version += " "; + current_version += OSType(); + current_version += ")"; + } + return current_version; +} + +std::string VersionInfo::OSType() const +{ + return (fake_android_ ? kOSTypeAndroid : kOSTypeTizen); +} + +std::string VersionInfo::ProductNameAndVersionForUserAgent() const +{ + if (!is_valid()) + return std::string(); + return ( Name() + std::string("/") + Version()); +} + +} //namespace EflWebView diff --git a/tizen_src/impl/common/version_info.h b/tizen_src/impl/common/version_info.h new file mode 100644 index 0000000..d020270 --- /dev/null +++ b/tizen_src/impl/common/version_info.h @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2013 Samsung Electronics. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + */ + +#ifndef VERSION_INFO_H_ +#define VERSION_INFO_H_ + +#include + +#include "base/basictypes.h" +#include "base/memory/scoped_ptr.h" + +namespace EflWebView { +// An instance of VersionInfo has information about the +// current running build of Chrome. +class VersionInfo { + public: + // The possible channels for an installation, from most fun to most stable. + enum Channel { + CHANNEL_UNKNOWN = 0, // Probably blue + CHANNEL_CANARY, // Yellow + CHANNEL_DEV, // Technicolor + CHANNEL_BETA, // Rainbow + CHANNEL_STABLE // Full-spectrum + }; + + static VersionInfo* GetInstance(); + static void DeleteInstance(); + // In the rare case where we fail to get the version info, + // is_valid() will return false. The other functions will return + // the empty string in this case, so it's not harmful if you don't + // check is_valid(). + bool is_valid() const + { return true; } + + // E.g. "Chrome/a.b.c.d" + std::string ProductNameAndVersionForUserAgent() const; + + // E.g. "Chromium" or "Google Chrome". + std::string Name() const + { return product_name_; } + + void SetProductName(const std::string& name); + + // Version number, e.g. "6.0.490.1". + std::string Version() const + { return product_version_; } + + // The SVN revision of this release. E.g. "55800". + std::string LastChange() const; + + // Whether this is an "official" release of the current Version(): + // whether knowing Version() is enough to completely determine what + // LastChange() is. + bool IsOfficialBuild() const; + + // OS type. E.g. "Windows", "Linux", "FreeBSD", ... + std::string OSType() const; + + // Returns a human-readable modifier for the version string. For a branded + // build, this modifier is the channel ("canary", "dev", or "beta", but "" + // for stable). On Windows, this may be modified with additional information + // after a hyphen. For multi-user installations, it will return "canary-m", + // "dev-m", "beta-m", and for a stable channel multi-user installation, "m". + // In branded builds, when the channel cannot be determined, "unknown" will + // be returned. In unbranded builds, the modifier is usually an empty string + // (""), although on Linux, it may vary in certain distributions. + // GetVersionStringModifier() is intended to be used for display purposes. + // To simply test the channel, use GetChannel(). + static std::string GetVersionStringModifier() + { return "" ; } + + // Returns the channel for the installation. In branded builds, this will be + // CHANNEL_STABLE, CHANNEL_BETA, CHANNEL_DEV, or CHANNEL_CANARY. In unbranded + // builds, or in branded builds when the channel cannot be determined, this + // will be CHANNEL_UNKNOWN. + static Channel GetChannel() + { return CHANNEL_DEV; } + + // Returns a version string to be displayed in "About Chromium" dialog. + std::string CreateVersionString() const; + + private: + VersionInfo(); + ~VersionInfo() { } + + std::string product_name_; + std::string product_version_; + // Whether to fake Android user agent + // Many sites sniff for "Android" along with "Mobile" in User Agent string + bool fake_android_; + static VersionInfo* version_info_; + + DISALLOW_COPY_AND_ASSIGN(VersionInfo); +}; + +} // namespace EflWebView + +#endif // VERSION_INFO_H_ diff --git a/tizen_src/impl/common/version_info_efl.h b/tizen_src/impl/common/version_info_efl.h new file mode 100644 index 0000000..92b6dc9 --- /dev/null +++ b/tizen_src/impl/common/version_info_efl.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2013 Samsung Electronics. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + */ + +#ifndef VERSION_INFO_EFL_H_ +#define VERSION_INFO_EFL_H_ + +#define PRODUCT_NAME "efl-webengine" +#define PRODUCT_VERSION "0.1.1.1" +#define LAST_CHANGE "@LASTCHANGE@" +#define IS_OFFICIAL_BUILD 0 + +#endif // VERSION_INFO_EFL_H_ diff --git a/tizen_src/impl/common/web_contents_utils.cc b/tizen_src/impl/common/web_contents_utils.cc new file mode 100644 index 0000000..3b79fae --- /dev/null +++ b/tizen_src/impl/common/web_contents_utils.cc @@ -0,0 +1,40 @@ +#include "common/web_contents_utils.h" + +#include "content/public/browser/render_view_host.h" +#include "content/public/browser/render_frame_host.h" +#include "content/public/browser/web_contents.h" + +#include "browser_context_efl.h" + +using content::WebContents; +using content::RenderFrameHost; +using content::RenderViewHost; + +namespace web_contents_utils { + +WebContents* WebContentsFromViewID(int render_process_id, int render_view_id) +{ + RenderViewHost* render_view_host = RenderViewHost::FromID(render_process_id, render_view_id); + + if (!render_view_host) + return NULL; + + return WebContents::FromRenderViewHost(render_view_host); +} + +WebContents* WebContentsFromFrameID(int render_process_id, int render_frame_id) +{ + RenderFrameHost* render_frame_host = RenderFrameHost::FromID(render_process_id, render_frame_id); + + if (!render_frame_host) + return NULL; + + RenderViewHost* render_view_host = render_frame_host->GetRenderViewHost(); + + if (!render_view_host) + return NULL; + + return WebContents::FromRenderViewHost(render_view_host); +} + +} // namespace web_contents_utils diff --git a/tizen_src/impl/common/web_contents_utils.h b/tizen_src/impl/common/web_contents_utils.h new file mode 100644 index 0000000..d661841 --- /dev/null +++ b/tizen_src/impl/common/web_contents_utils.h @@ -0,0 +1,14 @@ +#ifndef WEB_CONTENTS_UTILS_H +#define WEB_CONTENTS_UTILS_H + +namespace content { +class WebContents; +} // namespace content + +namespace web_contents_utils { + content::WebContents* WebContentsFromViewID(int render_process_id, int render_view_id); + content::WebContents* WebContentsFromFrameID(int render_process_id, int render_frame_id); +} // namespace web_contents_utils + +#endif // WEB_CONTENTS_UTILS_H + -- 2.7.4