mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
libcef: Format with clang-tidy (see #3632)
This commit is contained in:
@@ -1,89 +1,87 @@
|
||||
// Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/extensions/api/file_system/cef_file_system_delegate.h"
|
||||
|
||||
#include "apps/saved_files_service.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/functional/callback.h"
|
||||
#include "chrome/browser/extensions/api/file_system/file_entry_picker.h"
|
||||
#include "chrome/grit/generated_resources.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "extensions/common/api/file_system.h"
|
||||
#include "extensions/common/extension.h"
|
||||
|
||||
namespace extensions {
|
||||
namespace cef {
|
||||
|
||||
CefFileSystemDelegate::CefFileSystemDelegate() = default;
|
||||
|
||||
CefFileSystemDelegate::~CefFileSystemDelegate() = default;
|
||||
|
||||
base::FilePath CefFileSystemDelegate::GetDefaultDirectory() {
|
||||
return base::FilePath();
|
||||
}
|
||||
|
||||
base::FilePath CefFileSystemDelegate::GetManagedSaveAsDirectory(
|
||||
content::BrowserContext* browser_context,
|
||||
const Extension& extension) {
|
||||
return base::FilePath();
|
||||
}
|
||||
|
||||
bool CefFileSystemDelegate::ShowSelectFileDialog(
|
||||
scoped_refptr<ExtensionFunction> extension_function,
|
||||
ui::SelectFileDialog::Type type,
|
||||
const base::FilePath& default_path,
|
||||
const ui::SelectFileDialog::FileTypeInfo* file_types,
|
||||
FileSystemDelegate::FilesSelectedCallback files_selected_callback,
|
||||
base::OnceClosure file_selection_canceled_callback) {
|
||||
auto web_contents = extension_function->GetSenderWebContents();
|
||||
if (!web_contents) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The file picker will hold a reference to the ExtensionFunction
|
||||
// instance, preventing its destruction (and subsequent sending of the
|
||||
// function response) until the user has selected a file or cancelled the
|
||||
// picker. At that point, the picker will delete itself, which will also free
|
||||
// the function instance.
|
||||
new FileEntryPicker(web_contents, default_path, *file_types, type,
|
||||
std::move(files_selected_callback),
|
||||
std::move(file_selection_canceled_callback));
|
||||
return true;
|
||||
}
|
||||
|
||||
void CefFileSystemDelegate::ConfirmSensitiveDirectoryAccess(
|
||||
bool has_write_permission,
|
||||
const std::u16string& app_name,
|
||||
content::WebContents* web_contents,
|
||||
base::OnceClosure on_accept,
|
||||
base::OnceClosure on_cancel) {
|
||||
NOTIMPLEMENTED();
|
||||
|
||||
// Run the cancel callback by default.
|
||||
std::move(on_cancel).Run();
|
||||
}
|
||||
|
||||
// Based on ChromeFileSystemDelegate::GetDescriptionIdForAcceptType.
|
||||
int CefFileSystemDelegate::GetDescriptionIdForAcceptType(
|
||||
const std::string& accept_type) {
|
||||
if (accept_type == "image/*") {
|
||||
return IDS_IMAGE_FILES;
|
||||
}
|
||||
if (accept_type == "audio/*") {
|
||||
return IDS_AUDIO_FILES;
|
||||
}
|
||||
if (accept_type == "video/*") {
|
||||
return IDS_VIDEO_FILES;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SavedFilesServiceInterface* CefFileSystemDelegate::GetSavedFilesService(
|
||||
content::BrowserContext* browser_context) {
|
||||
return apps::SavedFilesService::Get(browser_context);
|
||||
}
|
||||
|
||||
} // namespace cef
|
||||
} // namespace extensions
|
||||
// Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/extensions/api/file_system/cef_file_system_delegate.h"
|
||||
|
||||
#include "apps/saved_files_service.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/functional/callback.h"
|
||||
#include "chrome/browser/extensions/api/file_system/file_entry_picker.h"
|
||||
#include "chrome/grit/generated_resources.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "extensions/common/api/file_system.h"
|
||||
#include "extensions/common/extension.h"
|
||||
|
||||
namespace extensions::cef {
|
||||
|
||||
CefFileSystemDelegate::CefFileSystemDelegate() = default;
|
||||
|
||||
CefFileSystemDelegate::~CefFileSystemDelegate() = default;
|
||||
|
||||
base::FilePath CefFileSystemDelegate::GetDefaultDirectory() {
|
||||
return base::FilePath();
|
||||
}
|
||||
|
||||
base::FilePath CefFileSystemDelegate::GetManagedSaveAsDirectory(
|
||||
content::BrowserContext* browser_context,
|
||||
const Extension& extension) {
|
||||
return base::FilePath();
|
||||
}
|
||||
|
||||
bool CefFileSystemDelegate::ShowSelectFileDialog(
|
||||
scoped_refptr<ExtensionFunction> extension_function,
|
||||
ui::SelectFileDialog::Type type,
|
||||
const base::FilePath& default_path,
|
||||
const ui::SelectFileDialog::FileTypeInfo* file_types,
|
||||
FileSystemDelegate::FilesSelectedCallback files_selected_callback,
|
||||
base::OnceClosure file_selection_canceled_callback) {
|
||||
auto web_contents = extension_function->GetSenderWebContents();
|
||||
if (!web_contents) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The file picker will hold a reference to the ExtensionFunction
|
||||
// instance, preventing its destruction (and subsequent sending of the
|
||||
// function response) until the user has selected a file or cancelled the
|
||||
// picker. At that point, the picker will delete itself, which will also free
|
||||
// the function instance.
|
||||
new FileEntryPicker(web_contents, default_path, *file_types, type,
|
||||
std::move(files_selected_callback),
|
||||
std::move(file_selection_canceled_callback));
|
||||
return true;
|
||||
}
|
||||
|
||||
void CefFileSystemDelegate::ConfirmSensitiveDirectoryAccess(
|
||||
bool has_write_permission,
|
||||
const std::u16string& app_name,
|
||||
content::WebContents* web_contents,
|
||||
base::OnceClosure on_accept,
|
||||
base::OnceClosure on_cancel) {
|
||||
NOTIMPLEMENTED();
|
||||
|
||||
// Run the cancel callback by default.
|
||||
std::move(on_cancel).Run();
|
||||
}
|
||||
|
||||
// Based on ChromeFileSystemDelegate::GetDescriptionIdForAcceptType.
|
||||
int CefFileSystemDelegate::GetDescriptionIdForAcceptType(
|
||||
const std::string& accept_type) {
|
||||
if (accept_type == "image/*") {
|
||||
return IDS_IMAGE_FILES;
|
||||
}
|
||||
if (accept_type == "audio/*") {
|
||||
return IDS_AUDIO_FILES;
|
||||
}
|
||||
if (accept_type == "video/*") {
|
||||
return IDS_VIDEO_FILES;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
SavedFilesServiceInterface* CefFileSystemDelegate::GetSavedFilesService(
|
||||
content::BrowserContext* browser_context) {
|
||||
return apps::SavedFilesService::Get(browser_context);
|
||||
}
|
||||
|
||||
} // namespace extensions::cef
|
||||
|
@@ -1,58 +1,56 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_
|
||||
#define CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "extensions/browser/api/execute_code_function.h"
|
||||
#include "extensions/browser/api/file_system/file_system_delegate.h"
|
||||
#include "extensions/browser/extension_function.h"
|
||||
|
||||
namespace content {
|
||||
class WebContents;
|
||||
}
|
||||
|
||||
namespace extensions {
|
||||
namespace cef {
|
||||
|
||||
class CefFileSystemDelegate : public FileSystemDelegate {
|
||||
public:
|
||||
CefFileSystemDelegate();
|
||||
|
||||
CefFileSystemDelegate(const CefFileSystemDelegate&) = delete;
|
||||
CefFileSystemDelegate& operator=(const CefFileSystemDelegate&) = delete;
|
||||
|
||||
~CefFileSystemDelegate() override;
|
||||
|
||||
// FileSystemDelegate
|
||||
base::FilePath GetDefaultDirectory() override;
|
||||
base::FilePath GetManagedSaveAsDirectory(
|
||||
content::BrowserContext* browser_context,
|
||||
const Extension& extension) override;
|
||||
bool ShowSelectFileDialog(
|
||||
scoped_refptr<ExtensionFunction> extension_function,
|
||||
ui::SelectFileDialog::Type type,
|
||||
const base::FilePath& default_path,
|
||||
const ui::SelectFileDialog::FileTypeInfo* file_types,
|
||||
FileSystemDelegate::FilesSelectedCallback files_selected_callback,
|
||||
base::OnceClosure file_selection_canceled_callback) override;
|
||||
void ConfirmSensitiveDirectoryAccess(bool has_write_permission,
|
||||
const std::u16string& app_name,
|
||||
content::WebContents* web_contents,
|
||||
base::OnceClosure on_accept,
|
||||
base::OnceClosure on_cancel) override;
|
||||
int GetDescriptionIdForAcceptType(const std::string& accept_type) override;
|
||||
SavedFilesServiceInterface* GetSavedFilesService(
|
||||
content::BrowserContext* browser_context) override;
|
||||
};
|
||||
|
||||
} // namespace cef
|
||||
} // namespace extensions
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_
|
||||
#define CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "extensions/browser/api/execute_code_function.h"
|
||||
#include "extensions/browser/api/file_system/file_system_delegate.h"
|
||||
#include "extensions/browser/extension_function.h"
|
||||
|
||||
namespace content {
|
||||
class WebContents;
|
||||
}
|
||||
|
||||
namespace extensions::cef {
|
||||
|
||||
class CefFileSystemDelegate : public FileSystemDelegate {
|
||||
public:
|
||||
CefFileSystemDelegate();
|
||||
|
||||
CefFileSystemDelegate(const CefFileSystemDelegate&) = delete;
|
||||
CefFileSystemDelegate& operator=(const CefFileSystemDelegate&) = delete;
|
||||
|
||||
~CefFileSystemDelegate() override;
|
||||
|
||||
// FileSystemDelegate
|
||||
base::FilePath GetDefaultDirectory() override;
|
||||
base::FilePath GetManagedSaveAsDirectory(
|
||||
content::BrowserContext* browser_context,
|
||||
const Extension& extension) override;
|
||||
bool ShowSelectFileDialog(
|
||||
scoped_refptr<ExtensionFunction> extension_function,
|
||||
ui::SelectFileDialog::Type type,
|
||||
const base::FilePath& default_path,
|
||||
const ui::SelectFileDialog::FileTypeInfo* file_types,
|
||||
FileSystemDelegate::FilesSelectedCallback files_selected_callback,
|
||||
base::OnceClosure file_selection_canceled_callback) override;
|
||||
void ConfirmSensitiveDirectoryAccess(bool has_write_permission,
|
||||
const std::u16string& app_name,
|
||||
content::WebContents* web_contents,
|
||||
base::OnceClosure on_accept,
|
||||
base::OnceClosure on_cancel) override;
|
||||
int GetDescriptionIdForAcceptType(const std::string& accept_type) override;
|
||||
SavedFilesServiceInterface* GetSavedFilesService(
|
||||
content::BrowserContext* browser_context) override;
|
||||
};
|
||||
|
||||
} // namespace extensions::cef
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_
|
||||
|
@@ -21,9 +21,7 @@
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace extensions {
|
||||
|
||||
namespace cef {
|
||||
namespace extensions::cef {
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -101,5 +99,4 @@ value_store::ValueStore* SyncValueStoreCache::GetStorage(
|
||||
storage_map_[extension->id()] = std::move(storage);
|
||||
return storage_ptr;
|
||||
}
|
||||
} // namespace cef
|
||||
} // namespace extensions
|
||||
} // namespace extensions::cef
|
||||
|
@@ -16,8 +16,7 @@ namespace value_store {
|
||||
class ValueStoreFactory;
|
||||
}
|
||||
|
||||
namespace extensions {
|
||||
namespace cef {
|
||||
namespace extensions::cef {
|
||||
|
||||
// Based on LocalValueStoreCache
|
||||
// ValueStoreCache for the SYNC namespace. It owns a backend for apps and
|
||||
@@ -54,7 +53,6 @@ class SyncValueStoreCache : public ValueStoreCache {
|
||||
StorageMap storage_map_;
|
||||
};
|
||||
|
||||
} // namespace cef
|
||||
} // namespace extensions
|
||||
} // namespace extensions::cef
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_API_STORAGE_SYNC_VALUE_STORE_CACHE_H_
|
||||
|
@@ -25,8 +25,7 @@
|
||||
|
||||
using zoom::ZoomController;
|
||||
|
||||
namespace extensions {
|
||||
namespace cef {
|
||||
namespace extensions::cef {
|
||||
|
||||
namespace keys = extensions::tabs_constants;
|
||||
namespace tabs = api::tabs;
|
||||
@@ -241,10 +240,9 @@ ExtensionFunction::ResponseValue TabsUpdateFunction::GetResult() {
|
||||
/*opener_browser_id=*/-1, /*active=*/true, tab_id_)));
|
||||
}
|
||||
|
||||
ExecuteCodeInTabFunction::ExecuteCodeInTabFunction()
|
||||
: cef_details_(this), execute_tab_id_(-1) {}
|
||||
ExecuteCodeInTabFunction::ExecuteCodeInTabFunction() : cef_details_(this) {}
|
||||
|
||||
ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() {}
|
||||
ExecuteCodeInTabFunction::~ExecuteCodeInTabFunction() = default;
|
||||
|
||||
ExecuteCodeFunction::InitResult ExecuteCodeInTabFunction::Init() {
|
||||
if (init_result_) {
|
||||
@@ -538,5 +536,4 @@ ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() {
|
||||
ArgumentList(tabs::GetZoomSettings::Results::Create(zoom_settings)));
|
||||
}
|
||||
|
||||
} // namespace cef
|
||||
} // namespace extensions
|
||||
} // namespace extensions::cef
|
||||
|
@@ -18,11 +18,10 @@ namespace content {
|
||||
class WebContents;
|
||||
}
|
||||
|
||||
namespace extensions {
|
||||
namespace cef {
|
||||
namespace extensions::cef {
|
||||
|
||||
class TabsGetFunction : public ExtensionFunction {
|
||||
~TabsGetFunction() override {}
|
||||
~TabsGetFunction() override = default;
|
||||
|
||||
ResponseAction Run() override;
|
||||
|
||||
@@ -32,7 +31,7 @@ class TabsGetFunction : public ExtensionFunction {
|
||||
class TabsCreateFunction : public ExtensionFunction {
|
||||
public:
|
||||
TabsCreateFunction();
|
||||
~TabsCreateFunction() override {}
|
||||
~TabsCreateFunction() override = default;
|
||||
|
||||
ResponseAction Run() override;
|
||||
|
||||
@@ -47,7 +46,7 @@ class BaseAPIFunction : public ExtensionFunction {
|
||||
BaseAPIFunction();
|
||||
|
||||
protected:
|
||||
~BaseAPIFunction() override {}
|
||||
~BaseAPIFunction() override = default;
|
||||
|
||||
// Gets the WebContents for |tab_id| if it is specified. Otherwise get the
|
||||
// WebContents for the active tab in the current window. Calling this function
|
||||
@@ -60,7 +59,7 @@ class BaseAPIFunction : public ExtensionFunction {
|
||||
|
||||
class TabsUpdateFunction : public BaseAPIFunction {
|
||||
private:
|
||||
~TabsUpdateFunction() override {}
|
||||
~TabsUpdateFunction() override = default;
|
||||
|
||||
ResponseAction Run() override;
|
||||
|
||||
@@ -98,19 +97,19 @@ class ExecuteCodeInTabFunction : public ExecuteCodeFunction {
|
||||
std::unique_ptr<std::string> data);
|
||||
|
||||
// Id of tab which executes code.
|
||||
int execute_tab_id_;
|
||||
int execute_tab_id_ = -1;
|
||||
};
|
||||
|
||||
class TabsExecuteScriptFunction : public ExecuteCodeInTabFunction {
|
||||
private:
|
||||
~TabsExecuteScriptFunction() override {}
|
||||
~TabsExecuteScriptFunction() override = default;
|
||||
|
||||
DECLARE_EXTENSION_FUNCTION("tabs.executeScript", TABS_EXECUTESCRIPT)
|
||||
};
|
||||
|
||||
class TabsInsertCSSFunction : public ExecuteCodeInTabFunction {
|
||||
private:
|
||||
~TabsInsertCSSFunction() override {}
|
||||
~TabsInsertCSSFunction() override = default;
|
||||
|
||||
bool ShouldInsertCSS() const override;
|
||||
|
||||
@@ -119,7 +118,7 @@ class TabsInsertCSSFunction : public ExecuteCodeInTabFunction {
|
||||
|
||||
class TabsRemoveCSSFunction : public ExecuteCodeInTabFunction {
|
||||
private:
|
||||
~TabsRemoveCSSFunction() override {}
|
||||
~TabsRemoveCSSFunction() override = default;
|
||||
|
||||
bool ShouldRemoveCSS() const override;
|
||||
|
||||
@@ -132,7 +131,7 @@ class ZoomAPIFunction : public ExtensionFunction {
|
||||
ZoomAPIFunction();
|
||||
|
||||
protected:
|
||||
~ZoomAPIFunction() override {}
|
||||
~ZoomAPIFunction() override = default;
|
||||
|
||||
// Gets the WebContents for |tab_id| if it is specified. Otherwise get the
|
||||
// WebContents for the active tab in the current window. Calling this function
|
||||
@@ -147,7 +146,7 @@ class ZoomAPIFunction : public ExtensionFunction {
|
||||
|
||||
class TabsSetZoomFunction : public BaseAPIFunction {
|
||||
private:
|
||||
~TabsSetZoomFunction() override {}
|
||||
~TabsSetZoomFunction() override = default;
|
||||
|
||||
ResponseAction Run() override;
|
||||
|
||||
@@ -156,7 +155,7 @@ class TabsSetZoomFunction : public BaseAPIFunction {
|
||||
|
||||
class TabsGetZoomFunction : public BaseAPIFunction {
|
||||
private:
|
||||
~TabsGetZoomFunction() override {}
|
||||
~TabsGetZoomFunction() override = default;
|
||||
|
||||
ResponseAction Run() override;
|
||||
|
||||
@@ -165,7 +164,7 @@ class TabsGetZoomFunction : public BaseAPIFunction {
|
||||
|
||||
class TabsSetZoomSettingsFunction : public BaseAPIFunction {
|
||||
private:
|
||||
~TabsSetZoomSettingsFunction() override {}
|
||||
~TabsSetZoomSettingsFunction() override = default;
|
||||
|
||||
ResponseAction Run() override;
|
||||
|
||||
@@ -174,14 +173,13 @@ class TabsSetZoomSettingsFunction : public BaseAPIFunction {
|
||||
|
||||
class TabsGetZoomSettingsFunction : public BaseAPIFunction {
|
||||
private:
|
||||
~TabsGetZoomSettingsFunction() override {}
|
||||
~TabsGetZoomSettingsFunction() override = default;
|
||||
|
||||
ResponseAction Run() override;
|
||||
|
||||
DECLARE_EXTENSION_FUNCTION("tabs.getZoomSettings", TABS_GETZOOMSETTINGS)
|
||||
};
|
||||
|
||||
} // namespace cef
|
||||
} // namespace extensions
|
||||
} // namespace extensions::cef
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_API_TABS_TABS_API_H_
|
||||
|
Reference in New Issue
Block a user