Read guest view's info from WebContentsPreferences
This commit is contained in:
parent
b1afe538ee
commit
9c235509a6
8 changed files with 45 additions and 144 deletions
|
@ -3,14 +3,12 @@
|
|||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/api/atom_api_web_contents.h"
|
||||
#include "atom/browser/web_view_constants.h"
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
#include "atom/browser/web_view_manager.h"
|
||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "net/base/filename_util.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace mate {
|
||||
|
||||
|
@ -26,31 +24,6 @@ struct Converter<content::WebContents*> {
|
|||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct Converter<atom::WebViewManager::WebViewInfo> {
|
||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
||||
atom::WebViewManager::WebViewInfo* out) {
|
||||
Dictionary options;
|
||||
if (!ConvertFromV8(isolate, val, &options))
|
||||
return false;
|
||||
|
||||
GURL preload_url;
|
||||
if (!options.Get(atom::web_view::kPreloadUrl, &preload_url))
|
||||
return false;
|
||||
|
||||
if (!preload_url.is_empty() &&
|
||||
!net::FileURLToFilePath(preload_url, &(out->preload_script)))
|
||||
return false;
|
||||
|
||||
return options.Get(atom::web_view::kNodeIntegration,
|
||||
&(out->node_integration)) &&
|
||||
options.Get(atom::web_view::kPlugins, &(out->plugins)) &&
|
||||
options.Get(atom::web_view::kPartitionId, &(out->partition_id)) &&
|
||||
options.Get(atom::web_view::kDisableWebSecurity,
|
||||
&(out->disable_web_security));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace {
|
||||
|
@ -69,17 +42,13 @@ void AddGuest(int guest_instance_id,
|
|||
int element_instance_id,
|
||||
content::WebContents* embedder,
|
||||
content::WebContents* guest_web_contents,
|
||||
atom::WebViewManager::WebViewInfo info) {
|
||||
const base::DictionaryValue& options) {
|
||||
auto manager = GetWebViewManager(embedder);
|
||||
if (manager)
|
||||
manager->AddGuest(guest_instance_id, element_instance_id, embedder,
|
||||
guest_web_contents);
|
||||
|
||||
info.guest_instance_id = guest_instance_id;
|
||||
info.embedder = embedder;
|
||||
auto data = new atom::WebViewManager::WebViewInfoUserData(info);
|
||||
guest_web_contents->SetUserData(
|
||||
atom::web_view::kWebViewInfoKeyName, data);
|
||||
atom::WebContentsPreferences::From(guest_web_contents)->Merge(options);
|
||||
}
|
||||
|
||||
void RemoveGuest(content::WebContents* embedder, int guest_instance_id) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue