mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update source files for bracket style
This commit is contained in:
@ -11,8 +11,9 @@ namespace alloy {
|
||||
|
||||
int GetTabIdForWebContents(content::WebContents* web_contents) {
|
||||
auto browser = AlloyBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
if (!browser)
|
||||
if (!browser) {
|
||||
return -1;
|
||||
}
|
||||
return browser->GetIdentifier();
|
||||
}
|
||||
|
||||
|
@ -68,12 +68,15 @@ void CefFileSystemDelegate::ConfirmSensitiveDirectoryAccess(
|
||||
// Based on ChromeFileSystemDelegate::GetDescriptionIdForAcceptType.
|
||||
int CefFileSystemDelegate::GetDescriptionIdForAcceptType(
|
||||
const std::string& accept_type) {
|
||||
if (accept_type == "image/*")
|
||||
if (accept_type == "image/*") {
|
||||
return IDS_IMAGE_FILES;
|
||||
if (accept_type == "audio/*")
|
||||
}
|
||||
if (accept_type == "audio/*") {
|
||||
return IDS_AUDIO_FILES;
|
||||
if (accept_type == "video/*")
|
||||
}
|
||||
if (accept_type == "video/*") {
|
||||
return IDS_VIDEO_FILES;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -82,8 +82,9 @@ void SyncValueStoreCache::DeleteStorageSoon(const std::string& extension_id) {
|
||||
value_store::ValueStore* SyncValueStoreCache::GetStorage(
|
||||
const Extension* extension) {
|
||||
auto iter = storage_map_.find(extension->id());
|
||||
if (iter != storage_map_.end())
|
||||
if (iter != storage_map_.end()) {
|
||||
return iter->second.get();
|
||||
}
|
||||
|
||||
value_store_util::ModelType model_type =
|
||||
extension->is_app() ? value_store_util::ModelType::APP
|
||||
|
@ -85,8 +85,9 @@ ExtensionFunction::ResponseAction TabsCreateFunction::Run() {
|
||||
|
||||
std::string error;
|
||||
auto result = cef_details_.OpenTab(options, user_gesture(), &error);
|
||||
if (!result)
|
||||
if (!result) {
|
||||
return RespondNow(Error(error));
|
||||
}
|
||||
|
||||
// Return data about the newly created tab.
|
||||
return RespondNow(has_callback() ? OneArgument(base::Value(result->ToValue()))
|
||||
@ -99,8 +100,9 @@ content::WebContents* BaseAPIFunction::GetWebContents(int tab_id) {
|
||||
// Find a browser that we can access, or set |error_| and return nullptr.
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser =
|
||||
cef_details_.GetBrowserForTabIdFirstTime(tab_id, &error_);
|
||||
if (!browser)
|
||||
if (!browser) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return browser->web_contents();
|
||||
}
|
||||
@ -112,8 +114,9 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
||||
|
||||
tab_id_ = params->tab_id ? *params->tab_id : -1;
|
||||
content::WebContents* web_contents = GetWebContents(tab_id_);
|
||||
if (!web_contents)
|
||||
if (!web_contents) {
|
||||
return RespondNow(Error(std::move(error_)));
|
||||
}
|
||||
|
||||
web_contents_ = web_contents;
|
||||
|
||||
@ -124,19 +127,22 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
||||
// Navigate the tab to a new location if the url is different.
|
||||
if (params->update_properties.url.has_value()) {
|
||||
std::string updated_url = *params->update_properties.url;
|
||||
if (!UpdateURL(updated_url, tab_id_, &error_))
|
||||
if (!UpdateURL(updated_url, tab_id_, &error_)) {
|
||||
return RespondNow(Error(std::move(error_)));
|
||||
}
|
||||
}
|
||||
|
||||
bool active = false;
|
||||
// TODO(rafaelw): Setting |active| from js doesn't make much sense.
|
||||
// Move tab selection management up to window.
|
||||
if (params->update_properties.selected.has_value())
|
||||
if (params->update_properties.selected.has_value()) {
|
||||
active = *params->update_properties.selected;
|
||||
}
|
||||
|
||||
// The 'active' property has replaced 'selected'.
|
||||
if (params->update_properties.active.has_value())
|
||||
if (params->update_properties.active.has_value()) {
|
||||
active = *params->update_properties.active;
|
||||
}
|
||||
|
||||
if (active) {
|
||||
// TODO: Activate the tab at |tab_id_|.
|
||||
@ -168,8 +174,9 @@ ExtensionFunction::ResponseAction TabsUpdateFunction::Run() {
|
||||
|
||||
if (params->update_properties.opener_tab_id.has_value()) {
|
||||
int opener_id = *params->update_properties.opener_tab_id;
|
||||
if (opener_id == tab_id_)
|
||||
if (opener_id == tab_id_) {
|
||||
return RespondNow(Error("Cannot set a tab's opener to itself."));
|
||||
}
|
||||
|
||||
// TODO: Set the opener for the tab at |tab_id_|.
|
||||
NOTIMPLEMENTED();
|
||||
@ -227,8 +234,9 @@ bool TabsUpdateFunction::UpdateURL(const std::string& url_string,
|
||||
}
|
||||
|
||||
ExtensionFunction::ResponseValue TabsUpdateFunction::GetResult() {
|
||||
if (!has_callback())
|
||||
if (!has_callback()) {
|
||||
return NoArguments();
|
||||
}
|
||||
|
||||
return ArgumentList(tabs::Get::Results::Create(cef_details_.CreateTabObject(
|
||||
AlloyBrowserHostImpl::GetBrowserForContents(web_contents_),
|
||||
@ -241,11 +249,13 @@ ExecuteCodeInTabFunction::ExecuteCodeInTabFunction()
|
||||
ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() {}
|
||||
|
||||
ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() {
|
||||
if (init_result_)
|
||||
if (init_result_) {
|
||||
return init_result_.value();
|
||||
}
|
||||
|
||||
if (args().size() < 2)
|
||||
if (args().size() < 2) {
|
||||
return set_init_result(VALIDATION_FAILURE);
|
||||
}
|
||||
|
||||
const auto& tab_id_value = args()[0];
|
||||
// |tab_id| is optional so it's ok if it's not there.
|
||||
@ -260,18 +270,21 @@ ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() {
|
||||
|
||||
// |details| are not optional.
|
||||
const base::Value& details_value = args()[1];
|
||||
if (!details_value.is_dict())
|
||||
if (!details_value.is_dict()) {
|
||||
return set_init_result(VALIDATION_FAILURE);
|
||||
}
|
||||
std::unique_ptr<InjectDetails> details(new InjectDetails());
|
||||
if (!InjectDetails::Populate(details_value, details.get()))
|
||||
if (!InjectDetails::Populate(details_value, details.get())) {
|
||||
return set_init_result(VALIDATION_FAILURE);
|
||||
}
|
||||
|
||||
// Find a browser that we can access, or fail with error.
|
||||
std::string error;
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser =
|
||||
cef_details_.GetBrowserForTabIdFirstTime(tab_id, &error);
|
||||
if (!browser)
|
||||
if (!browser) {
|
||||
return set_init_result_error(error);
|
||||
}
|
||||
|
||||
execute_tab_id_ = browser->GetIdentifier();
|
||||
details_ = std::move(details);
|
||||
@ -293,8 +306,9 @@ bool ExecuteCodeInTabFunction::CanExecuteScriptOnPage(std::string* error) {
|
||||
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser =
|
||||
cef_details_.GetBrowserForTabIdAgain(execute_tab_id_, error);
|
||||
if (!browser)
|
||||
if (!browser) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int frame_id = details_->frame_id ? *details_->frame_id
|
||||
: ExtensionApiFrameIdMap::kTopFrameId;
|
||||
@ -348,8 +362,9 @@ ScriptExecutor* ExecuteCodeInTabFunction::GetScriptExecutor(
|
||||
|
||||
CefRefPtr<AlloyBrowserHostImpl> browser =
|
||||
cef_details_.GetBrowserForTabIdAgain(execute_tab_id_, error);
|
||||
if (!browser)
|
||||
if (!browser) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return CefExtensionWebContentsObserver::FromWebContents(
|
||||
browser->web_contents())
|
||||
@ -406,12 +421,14 @@ ExtensionFunction::ResponseAction TabsSetZoomFunction::Run() {
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
||||
if (!web_contents)
|
||||
if (!web_contents) {
|
||||
return RespondNow(Error(std::move(error_)));
|
||||
}
|
||||
|
||||
GURL url(web_contents->GetVisibleURL());
|
||||
if (extension()->permissions_data()->IsRestrictedUrl(url, &error_))
|
||||
if (extension()->permissions_data()->IsRestrictedUrl(url, &error_)) {
|
||||
return RespondNow(Error(std::move(error_)));
|
||||
}
|
||||
|
||||
ZoomController* zoom_controller =
|
||||
ZoomController::FromWebContents(web_contents);
|
||||
@ -436,8 +453,9 @@ ExtensionFunction::ResponseAction TabsGetZoomFunction::Run() {
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
||||
if (!web_contents)
|
||||
if (!web_contents) {
|
||||
return RespondNow(Error(std::move(error_)));
|
||||
}
|
||||
|
||||
double zoom_level =
|
||||
zoom::ZoomController::FromWebContents(web_contents)->GetZoomLevel();
|
||||
@ -455,13 +473,15 @@ ExtensionFunction::ResponseAction TabsSetZoomSettingsFunction::Run() {
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
||||
if (!web_contents)
|
||||
if (!web_contents) {
|
||||
return RespondNow(Error(std::move(error_)));
|
||||
}
|
||||
|
||||
GURL url(web_contents->GetVisibleURL());
|
||||
std::string error;
|
||||
if (extension()->permissions_data()->IsRestrictedUrl(url, &error_))
|
||||
if (extension()->permissions_data()->IsRestrictedUrl(url, &error_)) {
|
||||
return RespondNow(Error(std::move(error_)));
|
||||
}
|
||||
|
||||
// "per-origin" scope is only available in "automatic" mode.
|
||||
if (params->zoom_settings.scope == tabs::ZOOM_SETTINGS_SCOPE_PER_ORIGIN &&
|
||||
@ -504,8 +524,9 @@ ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() {
|
||||
|
||||
int tab_id = params->tab_id ? *params->tab_id : -1;
|
||||
content::WebContents* web_contents = GetWebContents(tab_id);
|
||||
if (!web_contents)
|
||||
if (!web_contents) {
|
||||
return RespondNow(Error(std::move(error_)));
|
||||
}
|
||||
ZoomController* zoom_controller =
|
||||
ZoomController::FromWebContents(web_contents);
|
||||
|
||||
|
@ -65,8 +65,9 @@ CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForGlobalId(
|
||||
// Use the non-thread-safe but potentially faster approach.
|
||||
content::RenderFrameHost* host =
|
||||
content::RenderFrameHost::FromID(global_id);
|
||||
if (host)
|
||||
if (host) {
|
||||
return GetOwnerBrowserForHost(host, is_guest_view);
|
||||
}
|
||||
return nullptr;
|
||||
} else {
|
||||
// Use the thread-safe approach.
|
||||
@ -89,8 +90,9 @@ CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForGlobalId(
|
||||
CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForHost(
|
||||
content::RenderViewHost* host,
|
||||
bool* is_guest_view) {
|
||||
if (is_guest_view)
|
||||
if (is_guest_view) {
|
||||
*is_guest_view = false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostBase> browser =
|
||||
CefBrowserHostBase::GetBrowserForHost(host);
|
||||
@ -100,8 +102,9 @@ CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForHost(
|
||||
content::WebContents::FromRenderViewHost(host));
|
||||
if (owner) {
|
||||
browser = CefBrowserHostBase::GetBrowserForContents(owner);
|
||||
if (browser.get() && is_guest_view)
|
||||
if (browser.get() && is_guest_view) {
|
||||
*is_guest_view = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return browser;
|
||||
@ -110,8 +113,9 @@ CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForHost(
|
||||
CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForHost(
|
||||
content::RenderFrameHost* host,
|
||||
bool* is_guest_view) {
|
||||
if (is_guest_view)
|
||||
if (is_guest_view) {
|
||||
*is_guest_view = false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostBase> browser =
|
||||
CefBrowserHostBase::GetBrowserForHost(host);
|
||||
@ -121,8 +125,9 @@ CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForHost(
|
||||
content::WebContents::FromRenderFrameHost(host));
|
||||
if (owner) {
|
||||
browser = CefBrowserHostBase::GetBrowserForContents(owner);
|
||||
if (browser.get() && is_guest_view)
|
||||
if (browser.get() && is_guest_view) {
|
||||
*is_guest_view = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return browser;
|
||||
@ -134,8 +139,9 @@ CefRefPtr<AlloyBrowserHostImpl> GetBrowserForTabId(
|
||||
REQUIRE_ALLOY_RUNTIME();
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(browser_context);
|
||||
if (tab_id < 0 || !browser_context)
|
||||
if (tab_id < 0 || !browser_context) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto cef_browser_context =
|
||||
CefBrowserContext::FromBrowserContext(browser_context);
|
||||
@ -164,8 +170,9 @@ CefRefPtr<AlloyBrowserHostImpl> GetBrowserForTabId(
|
||||
const Extension* GetExtensionForUrl(content::BrowserContext* browser_context,
|
||||
const GURL& url) {
|
||||
ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context);
|
||||
if (!registry)
|
||||
if (!registry) {
|
||||
return nullptr;
|
||||
}
|
||||
std::string extension_id = url.host();
|
||||
return registry->enabled_extensions().GetByID(extension_id);
|
||||
}
|
||||
|
@ -66,8 +66,9 @@ const char* const kSupportedAPIs[] = {
|
||||
// static
|
||||
bool ChromeFunctionRegistry::IsSupported(const std::string& name) {
|
||||
for (size_t i = 0; kSupportedAPIs[i] != nullptr; ++i) {
|
||||
if (name == kSupportedAPIs[i])
|
||||
if (name == kSupportedAPIs[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -148,8 +148,9 @@ Profile* CefExtensionFunctionDetails::GetProfile() const {
|
||||
CefRefPtr<AlloyBrowserHostImpl> CefExtensionFunctionDetails::GetSenderBrowser()
|
||||
const {
|
||||
content::WebContents* web_contents = function_->GetSenderWebContents();
|
||||
if (web_contents)
|
||||
if (web_contents) {
|
||||
return AlloyBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -293,20 +294,23 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::OpenTab(
|
||||
bool user_gesture,
|
||||
std::string* error_message) const {
|
||||
CefRefPtr<AlloyBrowserHostImpl> sender_browser = GetSenderBrowser();
|
||||
if (!sender_browser)
|
||||
if (!sender_browser) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// windowId defaults to "current" window.
|
||||
int window_id = extension_misc::kCurrentWindowId;
|
||||
if (params.window_id.has_value())
|
||||
if (params.window_id.has_value()) {
|
||||
window_id = *params.window_id;
|
||||
}
|
||||
|
||||
// CEF doesn't have the concept of windows containing tab strips so we'll
|
||||
// select an "active browser" for BrowserContext sharing instead.
|
||||
CefRefPtr<AlloyBrowserHostImpl> active_browser =
|
||||
GetBrowserForTabIdFirstTime(window_id, error_message);
|
||||
if (!active_browser)
|
||||
if (!active_browser) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If an opener browser was specified then we expect it to exist.
|
||||
int opener_browser_id = -1;
|
||||
@ -330,13 +334,15 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::OpenTab(
|
||||
// Default to foreground for the new tab. The presence of 'active' property
|
||||
// will override this default.
|
||||
bool active = true;
|
||||
if (params.active.has_value())
|
||||
if (params.active.has_value()) {
|
||||
active = *params.active;
|
||||
}
|
||||
|
||||
// CEF doesn't use the index value but we let the client see/modify it.
|
||||
int index = 0;
|
||||
if (params.index.has_value())
|
||||
if (params.index.has_value()) {
|
||||
index = *params.index;
|
||||
}
|
||||
|
||||
auto cef_browser_context = CefBrowserContext::FromBrowserContext(
|
||||
active_browser->GetBrowserContext());
|
||||
@ -345,15 +351,17 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::OpenTab(
|
||||
CefRefPtr<CefExtension> cef_extension =
|
||||
cef_browser_context->GetExtension(function()->extension()->id());
|
||||
DCHECK(cef_extension);
|
||||
if (!cef_extension)
|
||||
if (!cef_extension) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Always use the same request context that the extension was registered with.
|
||||
// GetLoaderContext() will return NULL for internal extensions.
|
||||
CefRefPtr<CefRequestContext> request_context =
|
||||
cef_extension->GetLoaderContext();
|
||||
if (!request_context)
|
||||
if (!request_context) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CefBrowserCreateParams create_params;
|
||||
create_params.url = url.spec();
|
||||
@ -387,8 +395,9 @@ std::unique_ptr<api::tabs::Tab> CefExtensionFunctionDetails::OpenTab(
|
||||
// Browser creation may fail under certain rare circumstances.
|
||||
CefRefPtr<AlloyBrowserHostImpl> new_browser =
|
||||
AlloyBrowserHostImpl::Create(create_params);
|
||||
if (!new_browser)
|
||||
if (!new_browser) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Return data about the newly created tab.
|
||||
auto extension = function()->extension();
|
||||
@ -436,8 +445,9 @@ api::tabs::Tab CefExtensionFunctionDetails::CreateTabObject(
|
||||
tab_object.fav_icon_url = entry->GetFavicon().url.spec();
|
||||
}
|
||||
|
||||
if (opener_browser_id >= 0)
|
||||
if (opener_browser_id >= 0) {
|
||||
tab_object.opener_tab_id = opener_browser_id;
|
||||
}
|
||||
|
||||
return tab_object;
|
||||
}
|
||||
|
@ -76,8 +76,9 @@ std::unique_ptr<base::DictionaryValue> ParseManifest(
|
||||
|
||||
void ExecuteLoadFailure(CefRefPtr<CefExtensionHandler> handler,
|
||||
cef_errorcode_t result) {
|
||||
if (!handler)
|
||||
if (!handler) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(ExecuteLoadFailure, handler, result));
|
||||
@ -313,8 +314,9 @@ void CefExtensionSystem::LoadExtension(
|
||||
|
||||
ComponentExtensionInfo info(manifest.get(), root_directory, internal);
|
||||
const Extension* extension = LoadExtension(info, loader_context, handler);
|
||||
if (!extension)
|
||||
if (!extension) {
|
||||
ExecuteLoadFailure(handler, ERR_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
// Implementation based on ExtensionService::RemoveComponentExtension.
|
||||
@ -353,8 +355,9 @@ CefRefPtr<CefExtension> CefExtensionSystem::GetExtension(
|
||||
const std::string& extension_id) const {
|
||||
CEF_REQUIRE_UIT();
|
||||
ExtensionMap::const_iterator it = extension_map_.find(extension_id);
|
||||
if (it != extension_map_.end())
|
||||
if (it != extension_map_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -374,8 +377,9 @@ void CefExtensionSystem::OnRequestContextDeleted(CefRequestContext* context) {
|
||||
for (; it != map.end(); ++it) {
|
||||
CefRefPtr<CefExtensionImpl> cef_extension =
|
||||
static_cast<CefExtensionImpl*>(it->second.get());
|
||||
if (cef_extension->loader_context() == context)
|
||||
if (cef_extension->loader_context() == context) {
|
||||
UnloadExtension(it->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -434,8 +438,9 @@ CefExtensionSystem::store_factory() {
|
||||
}
|
||||
|
||||
InfoMap* CefExtensionSystem::info_map() {
|
||||
if (!info_map_.get())
|
||||
if (!info_map_.get()) {
|
||||
info_map_ = new InfoMap;
|
||||
}
|
||||
return info_map_.get();
|
||||
}
|
||||
|
||||
@ -686,8 +691,9 @@ void CefExtensionSystem::NotifyExtensionLoaded(const Extension* extension) {
|
||||
void CefExtensionSystem::OnExtensionRegisteredWithRequestContexts(
|
||||
scoped_refptr<const extensions::Extension> extension) {
|
||||
registry_->AddReady(extension);
|
||||
if (registry_->enabled_extensions().Contains(extension->id()))
|
||||
if (registry_->enabled_extensions().Contains(extension->id())) {
|
||||
registry_->TriggerOnReady(extension.get());
|
||||
}
|
||||
}
|
||||
|
||||
// Implementation based on ExtensionService::NotifyExtensionUnloaded.
|
||||
|
@ -72,8 +72,9 @@ bool CefExtensionViewHost::PreHandleGestureEvent(
|
||||
}
|
||||
|
||||
WebContents* CefExtensionViewHost::GetVisibleWebContents() const {
|
||||
if (extension_host_type() == mojom::ViewType::kExtensionPopup)
|
||||
if (extension_host_type() == mojom::ViewType::kExtensionPopup) {
|
||||
return host_contents();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,9 @@ void CefExtensionWebContentsObserver::RenderFrameCreated(
|
||||
ExtensionWebContentsObserver::RenderFrameCreated(render_frame_host);
|
||||
|
||||
const Extension* extension = GetExtensionFromFrame(render_frame_host, false);
|
||||
if (!extension)
|
||||
if (!extension) {
|
||||
return;
|
||||
}
|
||||
|
||||
int process_id = render_frame_host->GetProcess()->GetID();
|
||||
auto policy = content::ChildProcessSecurityPolicy::GetInstance();
|
||||
|
@ -75,8 +75,9 @@ void CefExtensionsAPIClient::AddAdditionalValueStoreCaches(
|
||||
}
|
||||
|
||||
FileSystemDelegate* CefExtensionsAPIClient::GetFileSystemDelegate() {
|
||||
if (!file_system_delegate_)
|
||||
if (!file_system_delegate_) {
|
||||
file_system_delegate_ = std::make_unique<cef::CefFileSystemDelegate>();
|
||||
}
|
||||
return file_system_delegate_.get();
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "libcef/browser/extensions/extensions_browser_api_provider.h"
|
||||
#include "libcef/browser/extensions/chrome_api_registration.h"
|
||||
|
||||
//#include "cef/libcef/browser/extensions/api/generated_api_registration.h"
|
||||
// #include "cef/libcef/browser/extensions/api/generated_api_registration.h"
|
||||
#include "extensions/browser/api/generated_api_registration.h"
|
||||
|
||||
namespace extensions {
|
||||
|
@ -49,13 +49,15 @@ void BindMimeHandlerService(
|
||||
mojo::PendingReceiver<extensions::mime_handler::MimeHandlerService>
|
||||
receiver) {
|
||||
auto* web_contents = content::WebContents::FromRenderFrameHost(frame_host);
|
||||
if (!web_contents)
|
||||
if (!web_contents) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* guest_view =
|
||||
extensions::MimeHandlerViewGuest::FromWebContents(web_contents);
|
||||
if (!guest_view)
|
||||
if (!guest_view) {
|
||||
return;
|
||||
}
|
||||
extensions::MimeHandlerServiceImpl::Create(guest_view->GetStreamWeakPtr(),
|
||||
std::move(receiver));
|
||||
}
|
||||
@ -65,13 +67,15 @@ void BindBeforeUnloadControl(
|
||||
mojo::PendingReceiver<extensions::mime_handler::BeforeUnloadControl>
|
||||
receiver) {
|
||||
auto* web_contents = content::WebContents::FromRenderFrameHost(frame_host);
|
||||
if (!web_contents)
|
||||
if (!web_contents) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* guest_view =
|
||||
extensions::MimeHandlerViewGuest::FromWebContents(web_contents);
|
||||
if (!guest_view)
|
||||
if (!guest_view) {
|
||||
return;
|
||||
}
|
||||
guest_view->FuseBeforeUnloadControl(std::move(receiver));
|
||||
}
|
||||
|
||||
@ -138,8 +142,9 @@ BrowserContext* CefExtensionsBrowserClient::GetOffTheRecordContext(
|
||||
BrowserContext* CefExtensionsBrowserClient::GetOriginalContext(
|
||||
BrowserContext* context) {
|
||||
auto cef_browser_context = CefBrowserContext::FromBrowserContext(context);
|
||||
if (cef_browser_context)
|
||||
if (cef_browser_context) {
|
||||
return cef_browser_context->AsBrowserContext();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -393,8 +398,9 @@ CefExtensionsBrowserClient::GetExtensionWebContentsObserver(
|
||||
}
|
||||
|
||||
KioskDelegate* CefExtensionsBrowserClient::GetKioskDelegate() {
|
||||
if (!kiosk_delegate_)
|
||||
if (!kiosk_delegate_) {
|
||||
kiosk_delegate_.reset(new CefKioskDelegate());
|
||||
}
|
||||
return kiosk_delegate_.get();
|
||||
}
|
||||
|
||||
|
@ -57,8 +57,9 @@ ValueStore::ReadResult CefValueStore::Get(const std::string& key) {
|
||||
ValueStore::ReadResult CefValueStore::Get(
|
||||
const std::vector<std::string>& keys) {
|
||||
read_count_++;
|
||||
if (!status_.ok())
|
||||
if (!status_.ok()) {
|
||||
return ReadResult(CreateStatusCopy(status_));
|
||||
}
|
||||
|
||||
base::Value::Dict settings;
|
||||
for (const auto& key : keys) {
|
||||
@ -72,8 +73,9 @@ ValueStore::ReadResult CefValueStore::Get(
|
||||
|
||||
ValueStore::ReadResult CefValueStore::Get() {
|
||||
read_count_++;
|
||||
if (!status_.ok())
|
||||
if (!status_.ok()) {
|
||||
return ReadResult(CreateStatusCopy(status_));
|
||||
}
|
||||
return ReadResult(storage_.Clone(), CreateStatusCopy(status_));
|
||||
}
|
||||
|
||||
@ -88,8 +90,9 @@ ValueStore::WriteResult CefValueStore::Set(WriteOptions options,
|
||||
ValueStore::WriteResult CefValueStore::Set(WriteOptions options,
|
||||
const base::Value::Dict& settings) {
|
||||
write_count_++;
|
||||
if (!status_.ok())
|
||||
if (!status_.ok()) {
|
||||
return WriteResult(CreateStatusCopy(status_));
|
||||
}
|
||||
|
||||
ValueStoreChangeList changes;
|
||||
for (const auto [key, value] : settings) {
|
||||
@ -113,8 +116,9 @@ ValueStore::WriteResult CefValueStore::Remove(const std::string& key) {
|
||||
ValueStore::WriteResult CefValueStore::Remove(
|
||||
const std::vector<std::string>& keys) {
|
||||
write_count_++;
|
||||
if (!status_.ok())
|
||||
if (!status_.ok()) {
|
||||
return WriteResult(CreateStatusCopy(status_));
|
||||
}
|
||||
|
||||
ValueStoreChangeList changes;
|
||||
for (auto const& key : keys) {
|
||||
|
@ -63,10 +63,11 @@ void CefValueStoreFactory::Reset() {
|
||||
|
||||
std::unique_ptr<ValueStore> CefValueStoreFactory::CreateStore() {
|
||||
std::unique_ptr<ValueStore> store;
|
||||
if (db_path_.empty())
|
||||
if (db_path_.empty()) {
|
||||
store = std::make_unique<CefValueStore>();
|
||||
else
|
||||
} else {
|
||||
store = std::make_unique<LeveldbValueStore>(kUMAClientName, db_path_);
|
||||
}
|
||||
last_created_store_ = store.get();
|
||||
return store;
|
||||
}
|
||||
|
Reference in New Issue
Block a user