Merge pull request #12649 from electron/clang-format-brightray

clang-format brightray
This commit is contained in:
Shelley Vohr 2018-04-18 22:59:04 -04:00 committed by GitHub
commit c090dd2f81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
61 changed files with 1547 additions and 1684 deletions

View file

@ -51,14 +51,12 @@ BrowserClient* BrowserClient::Get() {
return g_browser_client;
}
BrowserClient::BrowserClient()
: browser_main_parts_(nullptr) {
BrowserClient::BrowserClient() : browser_main_parts_(nullptr) {
DCHECK(!g_browser_client);
g_browser_client = this;
}
BrowserClient::~BrowserClient() {
}
BrowserClient::~BrowserClient() {}
NotificationPresenter* BrowserClient::GetNotificationPresenter() {
if (!notification_presenter_) {

View file

@ -61,8 +61,8 @@ class BrowserContext::ResourceContext : public content::ResourceContext {
BrowserContext::BrowserContextMap BrowserContext::browser_context_map_;
// static
scoped_refptr<BrowserContext> BrowserContext::Get(
const std::string& partition, bool in_memory) {
scoped_refptr<BrowserContext> BrowserContext::Get(const std::string& partition,
bool in_memory) {
PartitionKey key(partition, in_memory);
if (browser_context_map_[key].get())
return WrapRefCounted(browser_context_map_[key].get());
@ -137,13 +137,9 @@ net::URLRequestContextGetter* BrowserContext::CreateRequestContext(
content::URLRequestInterceptorScopedVector protocol_interceptors) {
DCHECK(!url_request_getter_.get());
url_request_getter_ = new URLRequestContextGetter(
this,
static_cast<NetLog*>(BrowserClient::Get()->GetNetLog()),
GetPath(),
in_memory_,
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
protocol_handlers,
std::move(protocol_interceptors));
this, static_cast<NetLog*>(BrowserClient::Get()->GetNetLog()), GetPath(),
in_memory_, BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
protocol_handlers, std::move(protocol_interceptors));
resource_context_->set_url_request_context_getter(url_request_getter_.get());
return url_request_getter_.get();
}
@ -204,8 +200,7 @@ content::PermissionManager* BrowserContext::GetPermissionManager() {
return permission_manager_.get();
}
content::BackgroundFetchDelegate*
BrowserContext::GetBackgroundFetchDelegate() {
content::BackgroundFetchDelegate* BrowserContext::GetBackgroundFetchDelegate() {
return nullptr;
}
@ -228,8 +223,7 @@ BrowserContext::CreateRequestContextForStoragePartition(
return nullptr;
}
net::URLRequestContextGetter*
BrowserContext::CreateMediaRequestContext() {
net::URLRequestContextGetter* BrowserContext::CreateMediaRequestContext() {
return url_request_getter_.get();
}

View file

@ -32,8 +32,8 @@ class BrowserContext : public base::RefCounted<BrowserContext>,
public:
// Get the BrowserContext according to its |partition| and |in_memory|,
// empty pointer when be returned when there is no matching BrowserContext.
static scoped_refptr<BrowserContext> Get(
const std::string& partition, bool in_memory);
static scoped_refptr<BrowserContext> Get(const std::string& partition,
bool in_memory);
base::WeakPtr<BrowserContext> GetWeakPtr() {
return weak_factory_.GetWeakPtr();

View file

@ -98,8 +98,7 @@ void OverrideLinuxAppDataPath() {
if (PathService::Get(DIR_APP_DATA, &path))
return;
std::unique_ptr<base::Environment> env(base::Environment::Create());
path = base::nix::GetXDGDirectory(env.get(),
base::nix::kXdgConfigHomeEnvVar,
path = base::nix::GetXDGDirectory(env.get(), base::nix::kXdgConfigHomeEnvVar,
base::nix::kDotConfigDir);
PathService::Override(DIR_APP_DATA, path);
}
@ -167,11 +166,9 @@ base::string16 MediaStringProvider(media::MessageId id) {
} // namespace
BrowserMainParts::BrowserMainParts() {
}
BrowserMainParts::BrowserMainParts() {}
BrowserMainParts::~BrowserMainParts() {
}
BrowserMainParts::~BrowserMainParts() {}
#if defined(OS_WIN) || defined(OS_LINUX)
void OverrideAppLogsPath() {
@ -220,7 +217,7 @@ void BrowserMainParts::ToolkitInitialized() {
gfx::PlatformFontWin::adjust_font_callback = &AdjustUIFont;
gfx::PlatformFontWin::get_minimum_font_size_callback = &GetMinimumFontSize;
wchar_t module_name[MAX_PATH] = { 0 };
wchar_t module_name[MAX_PATH] = {0};
if (GetModuleFileName(NULL, module_name, MAX_PATH))
ui::CursorLoaderWin::SetCursorResourceModule(module_name);
#endif

View file

@ -7,15 +7,13 @@
#include <algorithm>
DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy()
: hide_inspected_contents_(false) {
}
: hide_inspected_contents_(false) {}
DevToolsContentsResizingStrategy::DevToolsContentsResizingStrategy(
const gfx::Rect& bounds)
: bounds_(bounds),
hide_inspected_contents_(bounds_.IsEmpty() && !bounds_.x() &&
!bounds_.y()) {
}
!bounds_.y()) {}
void DevToolsContentsResizingStrategy::CopyFrom(
const DevToolsContentsResizingStrategy& strategy) {
@ -34,13 +32,13 @@ void ApplyDevToolsContentsResizingStrategy(
const gfx::Size& container_size,
gfx::Rect* new_devtools_bounds,
gfx::Rect* new_contents_bounds) {
new_devtools_bounds->SetRect(
0, 0, container_size.width(), container_size.height());
new_devtools_bounds->SetRect(0, 0, container_size.width(),
container_size.height());
const gfx::Rect& bounds = strategy.bounds();
if (bounds.size().IsEmpty() && !strategy.hide_inspected_contents()) {
new_contents_bounds->SetRect(
0, 0, container_size.width(), container_size.height());
new_contents_bounds->SetRect(0, 0, container_size.width(),
container_size.height());
return;
}

View file

@ -14,8 +14,7 @@
class DevToolsContentsResizingStrategy {
public:
DevToolsContentsResizingStrategy();
explicit DevToolsContentsResizingStrategy(
const gfx::Rect& bounds);
explicit DevToolsContentsResizingStrategy(const gfx::Rect& bounds);
void CopyFrom(const DevToolsContentsResizingStrategy& strategy);
bool Equals(const DevToolsContentsResizingStrategy& strategy);

View file

@ -33,8 +33,7 @@ bool GetValue(const base::Value& value, gfx::Rect* rect) {
int y = 0;
int width = 0;
int height = 0;
if (!dict->GetInteger("x", &x) ||
!dict->GetInteger("y", &y) ||
if (!dict->GetInteger("x", &x) || !dict->GetInteger("y", &y) ||
!dict->GetInteger("width", &width) ||
!dict->GetInteger("height", &height))
return false;
@ -69,8 +68,7 @@ template <typename T, typename... Ts>
struct ParamTuple<T, Ts...> {
bool Parse(const base::ListValue& list,
const base::ListValue::const_iterator& it) {
return it != list.end() && GetValue(*it, &head) &&
tail.Parse(list, it + 1);
return it != list.end() && GetValue(*it, &head) && tail.Parse(list, it + 1);
}
template <typename H, typename... As>
@ -82,7 +80,7 @@ struct ParamTuple<T, Ts...> {
ParamTuple<Ts...> tail;
};
template<typename... As>
template <typename... As>
bool ParseAndHandle(const base::Callback<void(As...)>& handler,
const DispatchCallback& callback,
const base::ListValue& list) {
@ -93,7 +91,7 @@ bool ParseAndHandle(const base::Callback<void(As...)>& handler,
return true;
}
template<typename... As>
template <typename... As>
bool ParseAndHandleWithCallback(
const base::Callback<void(const DispatchCallback&, As...)>& handler,
const DispatchCallback& callback,
@ -126,28 +124,28 @@ class DispatcherImpl : public DevToolsEmbedderMessageDispatcher {
return it != handlers_.end() && it->second.Run(callback, *params);
}
template<typename... As>
template <typename... As>
void RegisterHandler(const std::string& method,
void (Delegate::*handler)(As...),
Delegate* delegate) {
handlers_[method] = base::Bind(&ParseAndHandle<As...>,
base::Bind(handler,
base::Unretained(delegate)));
handlers_[method] =
base::Bind(&ParseAndHandle<As...>,
base::Bind(handler, base::Unretained(delegate)));
}
template<typename... As>
template <typename... As>
void RegisterHandlerWithCallback(
const std::string& method,
void (Delegate::*handler)(const DispatchCallback&, As...),
Delegate* delegate) {
handlers_[method] = base::Bind(&ParseAndHandleWithCallback<As...>,
base::Bind(handler,
base::Unretained(delegate)));
handlers_[method] =
base::Bind(&ParseAndHandleWithCallback<As...>,
base::Bind(handler, base::Unretained(delegate)));
}
private:
using Handler = base::Callback<bool(const DispatchCallback&,
const base::ListValue&)>;
using Handler =
base::Callback<bool(const DispatchCallback&, const base::ListValue&)>;
using HandlerMap = std::map<std::string, Handler>;
HandlerMap handlers_;
};
@ -165,15 +163,15 @@ DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(
&Delegate::SetInspectedPageBounds, delegate);
d->RegisterHandler("inspectElementCompleted",
&Delegate::InspectElementCompleted, delegate);
d->RegisterHandler("inspectedURLChanged",
&Delegate::InspectedURLChanged, delegate);
d->RegisterHandlerWithCallback("setIsDocked",
&Delegate::SetIsDocked, delegate);
d->RegisterHandler("inspectedURLChanged", &Delegate::InspectedURLChanged,
delegate);
d->RegisterHandlerWithCallback("setIsDocked", &Delegate::SetIsDocked,
delegate);
d->RegisterHandler("openInNewTab", &Delegate::OpenInNewTab, delegate);
d->RegisterHandler("save", &Delegate::SaveToFile, delegate);
d->RegisterHandler("append", &Delegate::AppendToFile, delegate);
d->RegisterHandler("requestFileSystems",
&Delegate::RequestFileSystems, delegate);
d->RegisterHandler("requestFileSystems", &Delegate::RequestFileSystems,
delegate);
d->RegisterHandler("addFileSystem", &Delegate::AddFileSystem, delegate);
d->RegisterHandler("removeFileSystem", &Delegate::RemoveFileSystem, delegate);
d->RegisterHandler("upgradeDraggedFileSystemPermissions",
@ -193,10 +191,10 @@ DevToolsEmbedderMessageDispatcher::CreateForDevToolsFrontend(
d->RegisterHandler("dispatchProtocolMessage",
&Delegate::DispatchProtocolMessageFromDevToolsFrontend,
delegate);
d->RegisterHandlerWithCallback("sendJsonRequest",
&Delegate::SendJsonRequest, delegate);
d->RegisterHandlerWithCallback("getPreferences",
&Delegate::GetPreferences, delegate);
d->RegisterHandlerWithCallback("sendJsonRequest", &Delegate::SendJsonRequest,
delegate);
d->RegisterHandlerWithCallback("getPreferences", &Delegate::GetPreferences,
delegate);
d->RegisterHandler("setPreference", &Delegate::SetPreference, delegate);
d->RegisterHandler("removePreference", &Delegate::RemovePreference, delegate);
d->RegisterHandler("clearPreferences", &Delegate::ClearPreferences, delegate);

View file

@ -16,7 +16,7 @@
namespace base {
class ListValue;
class Value;
}
} // namespace base
namespace brightray {

View file

@ -78,7 +78,7 @@ class Index {
FileIdsMap file_ids_;
FileId last_file_id_;
// The index in this vector is the trigram id.
vector<vector<FileId> > index_;
vector<vector<FileId>> index_;
typedef map<FilePath, Time> IndexedFilesMap;
IndexedFilesMap index_times_;
vector<bool> is_normalized_;
@ -192,21 +192,19 @@ vector<FilePath> Index::Search(string query) {
for (; it != trigrams.end(); ++it) {
Trigram trigram = *it;
if (first) {
std::copy(index_[trigram].begin(),
index_[trigram].end(),
std::copy(index_[trigram].begin(), index_[trigram].end(),
std::inserter(file_ids, file_ids.begin()));
first = false;
continue;
}
set<FileId> intersection = base::STLSetIntersection<set<FileId> >(
file_ids, index_[trigram]);
set<FileId> intersection =
base::STLSetIntersection<set<FileId>>(file_ids, index_[trigram]);
file_ids.swap(intersection);
}
vector<FilePath> result;
FileIdsMap::const_iterator ids_it = file_ids_.begin();
for (; ids_it != file_ids_.end(); ++ids_it) {
if (trigrams.empty() ||
file_ids.find(ids_it->second) != file_ids.end()) {
if (trigrams.empty() || file_ids.find(ids_it->second) != file_ids.end()) {
result.push_back(ids_it->first);
}
}
@ -280,15 +278,13 @@ DevToolsFileSystemIndexer::FileSystemIndexingJob::~FileSystemIndexingJob() {}
void DevToolsFileSystemIndexer::FileSystemIndexingJob::Start() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::FILE,
FROM_HERE,
BrowserThread::FILE, FROM_HERE,
Bind(&FileSystemIndexingJob::CollectFilesToIndex, this));
}
void DevToolsFileSystemIndexer::FileSystemIndexingJob::Stop() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(BrowserThread::FILE,
FROM_HERE,
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
Bind(&FileSystemIndexingJob::StopOnFileThread, this));
}
@ -307,8 +303,7 @@ void DevToolsFileSystemIndexer::FileSystemIndexingJob::CollectFilesToIndex() {
FilePath file_path = file_enumerator_->Next();
if (file_path.empty()) {
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
BrowserThread::UI, FROM_HERE,
Bind(total_work_callback_, file_path_times_.size()));
indexing_it_ = file_path_times_.begin();
IndexFiles();
@ -322,8 +317,7 @@ void DevToolsFileSystemIndexer::FileSystemIndexingJob::CollectFilesToIndex() {
file_path_times_[file_path] = current_last_modified_time;
}
BrowserThread::PostTask(
BrowserThread::FILE,
FROM_HERE,
BrowserThread::FILE, FROM_HERE,
Bind(&FileSystemIndexingJob::CollectFilesToIndex, this));
}
@ -338,8 +332,7 @@ void DevToolsFileSystemIndexer::FileSystemIndexingJob::IndexFiles() {
}
FilePath file_path = indexing_it_->first;
current_file_.CreateOrOpen(
file_path,
base::File::FLAG_OPEN | base::File::FLAG_READ,
file_path, base::File::FLAG_OPEN | base::File::FLAG_READ,
Bind(&FileSystemIndexingJob::StartFileIndexing, this));
}
@ -408,8 +401,8 @@ void DevToolsFileSystemIndexer::FileSystemIndexingJob::FinishFileIndexing(
CloseFile();
if (success) {
FilePath file_path = indexing_it_->first;
g_trigram_index.Get().SetTrigramsForFile(
file_path, current_trigrams_, file_path_times_[file_path]);
g_trigram_index.Get().SetTrigramsForFile(file_path, current_trigrams_,
file_path_times_[file_path]);
}
ReportWorked();
++indexing_it_;
@ -435,14 +428,13 @@ void DevToolsFileSystemIndexer::FileSystemIndexingJob::ReportWorked() {
++files_indexed_;
if (should_send_worked_nitification) {
last_worked_notification_time_ = current_time;
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, Bind(worked_callback_, files_indexed_));
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
Bind(worked_callback_, files_indexed_));
files_indexed_ = 0;
}
}
DevToolsFileSystemIndexer::DevToolsFileSystemIndexer() {
}
DevToolsFileSystemIndexer::DevToolsFileSystemIndexer() {}
DevToolsFileSystemIndexer::~DevToolsFileSystemIndexer() {}
@ -453,11 +445,9 @@ DevToolsFileSystemIndexer::IndexPath(
const WorkedCallback& worked_callback,
const DoneCallback& done_callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
scoped_refptr<FileSystemIndexingJob> indexing_job =
new FileSystemIndexingJob(FilePath::FromUTF8Unsafe(file_system_path),
total_work_callback,
worked_callback,
done_callback);
scoped_refptr<FileSystemIndexingJob> indexing_job = new FileSystemIndexingJob(
FilePath::FromUTF8Unsafe(file_system_path), total_work_callback,
worked_callback, done_callback);
indexing_job->Start();
return indexing_job;
}
@ -467,13 +457,9 @@ void DevToolsFileSystemIndexer::SearchInPath(const string& file_system_path,
const SearchCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::FILE,
FROM_HERE,
Bind(&DevToolsFileSystemIndexer::SearchInPathOnFileThread,
this,
file_system_path,
query,
callback));
BrowserThread::FILE, FROM_HERE,
Bind(&DevToolsFileSystemIndexer::SearchInPathOnFileThread, this,
file_system_path, query, callback));
}
void DevToolsFileSystemIndexer::SearchInPathOnFileThread(

View file

@ -21,7 +21,7 @@ namespace base {
class FilePath;
class FileEnumerator;
class Time;
}
} // namespace base
namespace content {
class WebContents;
@ -56,9 +56,7 @@ class DevToolsFileSystemIndexer
void IndexFiles();
void StartFileIndexing(base::File::Error error);
void ReadFromFile();
void OnRead(base::File::Error error,
const char* data,
int bytes_read);
void OnRead(base::File::Error error, const char* data, int bytes_read);
void FinishFileIndexing(bool success);
void CloseFile();
void CloseCallback(base::File::Error error);

View file

@ -34,8 +34,7 @@ namespace {
class TCPServerSocketFactory : public content::DevToolsSocketFactory {
public:
TCPServerSocketFactory(const std::string& address, int port)
: address_(address), port_(port) {
}
: address_(address), port_(port) {}
private:
// content::ServerSocketFactory.
@ -58,8 +57,7 @@ class TCPServerSocketFactory : public content::DevToolsSocketFactory {
DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory);
};
std::unique_ptr<content::DevToolsSocketFactory>
CreateSocketFactory() {
std::unique_ptr<content::DevToolsSocketFactory> CreateSocketFactory() {
auto& command_line = *base::CommandLine::ForCurrentProcess();
// See if the user specified a port on the command line (useful for
// automation). If not, use an ephemeral port by specifying 0.
@ -68,8 +66,8 @@ CreateSocketFactory() {
int temp_port;
std::string port_str =
command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort);
if (base::StringToInt(port_str, &temp_port) &&
temp_port > 0 && temp_port < 65535) {
if (base::StringToInt(port_str, &temp_port) && temp_port > 0 &&
temp_port < 65535) {
port = temp_port;
} else {
DLOG(WARNING) << "Invalid http debugger port number " << temp_port;
@ -86,19 +84,14 @@ CreateSocketFactory() {
// static
void DevToolsManagerDelegate::StartHttpHandler() {
content::DevToolsAgentHost::StartRemoteDebuggingServer(
CreateSocketFactory(),
std::string(),
base::FilePath(),
base::FilePath());
CreateSocketFactory(), std::string(), base::FilePath(), base::FilePath());
}
DevToolsManagerDelegate::DevToolsManagerDelegate() {}
DevToolsManagerDelegate::~DevToolsManagerDelegate() {
}
DevToolsManagerDelegate::~DevToolsManagerDelegate() {}
void DevToolsManagerDelegate::Inspect(content::DevToolsAgentHost* agent_host) {
}
void DevToolsManagerDelegate::Inspect(content::DevToolsAgentHost* agent_host) {}
bool DevToolsManagerDelegate::HandleCommand(
content::DevToolsAgentHost* agent_host,
@ -113,8 +106,9 @@ DevToolsManagerDelegate::CreateNewTarget(const GURL& url) {
}
std::string DevToolsManagerDelegate::GetDiscoveryPageHTML() {
return ResourceBundle::GetSharedInstance().GetRawDataResource(
IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string();
return ResourceBundle::GetSharedInstance()
.GetRawDataResource(IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE)
.as_string();
}
std::string DevToolsManagerDelegate::GetFrontendResource(

View file

@ -22,8 +22,7 @@ class DevToolsManagerDelegate : public content::DevToolsManagerDelegate {
// DevToolsManagerDelegate implementation.
void Inspect(content::DevToolsAgentHost* agent_host) override;
bool HandleCommand(
content::DevToolsAgentHost* agent_host,
bool HandleCommand(content::DevToolsAgentHost* agent_host,
int session_id,
base::DictionaryValue* command) override;
scoped_refptr<content::DevToolsAgentHost> CreateNewTarget(

View file

@ -23,7 +23,8 @@ const char kChromeUIDevToolsBundledPath[] = "bundled";
std::string PathWithoutParams(const std::string& path) {
return GURL(std::string("chrome-devtools://devtools/") + path)
.path().substr(1);
.path()
.substr(1);
}
std::string GetMimeTypeForPath(const std::string& path) {
@ -57,9 +58,7 @@ class BundledDataSource : public content::URLDataSource {
BundledDataSource() {}
// content::URLDataSource implementation.
std::string GetSource() const override {
return kChromeUIDevToolsHost;
}
std::string GetSource() const override { return kChromeUIDevToolsHost; }
void StartDataRequest(
const std::string& path,
@ -83,17 +82,11 @@ class BundledDataSource : public content::URLDataSource {
return GetMimeTypeForPath(path);
}
bool ShouldAddContentSecurityPolicy() const override {
return false;
}
bool ShouldAddContentSecurityPolicy() const override { return false; }
bool ShouldDenyXFrameOptions() const override {
return false;
}
bool ShouldDenyXFrameOptions() const override { return false; }
bool ShouldServeMimeTypeAsContentTypeHeader() const override {
return true;
}
bool ShouldServeMimeTypeAsContentTypeHeader() const override { return true; }
void StartBundledDataRequest(const std::string& path,
const GotDataCallback& callback) {

View file

@ -11,20 +11,19 @@ class InspectableWebContentsDelegate {
// Requested by WebContents of devtools.
virtual void DevToolsReloadPage() {}
virtual void DevToolsSaveToFile(
const std::string& url, const std::string& content, bool save_as) {}
virtual void DevToolsAppendToFile(
const std::string& url, const std::string& content) {}
virtual void DevToolsSaveToFile(const std::string& url,
const std::string& content,
bool save_as) {}
virtual void DevToolsAppendToFile(const std::string& url,
const std::string& content) {}
virtual void DevToolsRequestFileSystems() {}
virtual void DevToolsAddFileSystem(
const base::FilePath& file_system_path) {}
virtual void DevToolsAddFileSystem(const base::FilePath& file_system_path) {}
virtual void DevToolsRemoveFileSystem(
const base::FilePath& file_system_path) {}
virtual void DevToolsIndexPath(
int request_id, const std::string& file_system_path) {}
virtual void DevToolsIndexPath(int request_id,
const std::string& file_system_path) {}
virtual void DevToolsStopIndexing(int request_id) {}
virtual void DevToolsSearchInPath(
int request_id,
virtual void DevToolsSearchInPath(int request_id,
const std::string& file_system_path,
const std::string& query) {}
};

View file

@ -42,9 +42,9 @@ namespace brightray {
namespace {
const double kPresetZoomFactors[] = { 0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1.0,
1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0,
5.0 };
const double kPresetZoomFactors[] = {0.25, 0.333, 0.5, 0.666, 0.75, 0.9,
1.0, 1.1, 1.25, 1.5, 1.75, 2.0,
2.5, 3.0, 4.0, 5.0};
const char kChromeUIDevToolsURL[] =
"chrome-devtools://devtools/bundled/inspector.html?"
@ -117,16 +117,14 @@ double GetNextZoomLevel(double level, bool out) {
}
GURL GetRemoteBaseURL() {
return GURL(base::StringPrintf(
"%s%s/%s/",
return GURL(base::StringPrintf("%s%s/%s/",
kChromeUIDevToolsRemoteFrontendBase,
kChromeUIDevToolsRemoteFrontendPath,
content::GetWebKitRevision().c_str()));
}
GURL GetDevToolsURL(bool can_dock) {
auto url_string =
base::StringPrintf(kChromeUIDevToolsURL,
auto url_string = base::StringPrintf(kChromeUIDevToolsURL,
GetRemoteBaseURL().spec().c_str(),
can_dock ? "true" : "");
return GURL(url_string);
@ -157,12 +155,9 @@ class ResponseWriter : public net::URLFetcherResponseWriter {
ResponseWriter::ResponseWriter(
base::WeakPtr<InspectableWebContentsImpl> bindings,
int stream_id)
: bindings_(bindings),
stream_id_(stream_id) {
}
: bindings_(bindings), stream_id_(stream_id) {}
ResponseWriter::~ResponseWriter() {
}
ResponseWriter::~ResponseWriter() {}
int ResponseWriter::Initialize(const net::CompletionCallback& callback) {
return net::OK;
@ -172,14 +167,13 @@ int ResponseWriter::Write(net::IOBuffer* buffer,
int num_bytes,
const net::CompletionCallback& callback) {
auto* id = new base::Value(stream_id_);
base::Value* chunk =
new base::Value(std::string(buffer->data(), num_bytes));
base::Value* chunk = new base::Value(std::string(buffer->data(), num_bytes));
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(&InspectableWebContentsImpl::CallClientFunction,
bindings_, "DevToolsAPI.streamWrite",
base::Owned(id), base::Owned(chunk), nullptr));
base::Bind(&InspectableWebContentsImpl::CallClientFunction, bindings_,
"DevToolsAPI.streamWrite", base::Owned(id), base::Owned(chunk),
nullptr));
return num_bytes;
}
@ -223,8 +217,9 @@ InspectableWebContentsImpl::InspectableWebContentsImpl(
if (!IsPointInScreen(devtools_bounds_.origin())) {
gfx::Rect display;
if (web_contents->GetNativeView()) {
display = display::Screen::GetScreen()->
GetDisplayNearestView(web_contents->GetNativeView()).bounds();
display = display::Screen::GetScreen()
->GetDisplayNearestView(web_contents->GetNativeView())
.bounds();
} else {
display = display::Screen::GetScreen()->GetPrimaryDisplay().bounds();
}
@ -311,8 +306,7 @@ void InspectableWebContentsImpl::ShowDevTools() {
if (!external_devtools_web_contents_) { // no external devtools
managed_devtools_web_contents_.reset(
content::WebContents::Create(
content::WebContents::CreateParams(
content::WebContents::Create(content::WebContents::CreateParams(
web_contents_->GetBrowserContext())));
managed_devtools_web_contents_->SetDelegate(this);
}
@ -321,10 +315,8 @@ void InspectableWebContentsImpl::ShowDevTools() {
AttachTo(content::DevToolsAgentHost::GetOrCreateFor(web_contents_.get()));
GetDevToolsWebContents()->GetController().LoadURL(
GetDevToolsURL(can_dock_),
content::Referrer(),
ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
std::string());
GetDevToolsURL(can_dock_), content::Referrer(),
ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
}
void InspectableWebContentsImpl::CloseDevTools() {
@ -406,8 +398,7 @@ void InspectableWebContentsImpl::UpdateDevToolsZoomLevel(double level) {
void InspectableWebContentsImpl::ActivateWindow() {
// Set the zoom level.
SetZoomLevelForWebContents(GetDevToolsWebContents(),
GetDevToolsZoomLevel());
SetZoomLevelForWebContents(GetDevToolsWebContents(), GetDevToolsZoomLevel());
}
void InspectableWebContentsImpl::CloseWindow() {
@ -424,8 +415,8 @@ void InspectableWebContentsImpl::LoadCompleted() {
SetIsDocked(DispatchCallback(), false);
} else {
if (dock_state_.empty()) {
const base::DictionaryValue* prefs = pref_service_->GetDictionary(
kDevToolsPreferences);
const base::DictionaryValue* prefs =
pref_service_->GetDictionary(kDevToolsPreferences);
std::string current_dock_state;
prefs->GetString("currentDockState", &current_dock_state);
base::RemoveChars(current_dock_state, "\"", &dock_state_);
@ -449,13 +440,12 @@ void InspectableWebContentsImpl::SetInspectedPageBounds(const gfx::Rect& rect) {
view_->SetContentsResizingStrategy(contents_resizing_strategy_);
}
void InspectableWebContentsImpl::InspectElementCompleted() {
}
void InspectableWebContentsImpl::InspectElementCompleted() {}
void InspectableWebContentsImpl::InspectedURLChanged(const std::string& url) {
if (managed_devtools_web_contents_)
view_->SetTitle(base::UTF8ToUTF16(base::StringPrintf(kTitleFormat,
url.c_str())));
view_->SetTitle(
base::UTF8ToUTF16(base::StringPrintf(kTitleFormat, url.c_str())));
}
void InspectableWebContentsImpl::LoadNetworkResource(
@ -493,17 +483,17 @@ void InspectableWebContentsImpl::SetIsDocked(const DispatchCallback& callback,
callback.Run(nullptr);
}
void InspectableWebContentsImpl::OpenInNewTab(const std::string& url) {
}
void InspectableWebContentsImpl::OpenInNewTab(const std::string& url) {}
void InspectableWebContentsImpl::SaveToFile(
const std::string& url, const std::string& content, bool save_as) {
void InspectableWebContentsImpl::SaveToFile(const std::string& url,
const std::string& content,
bool save_as) {
if (delegate_)
delegate_->DevToolsSaveToFile(url, content, save_as);
}
void InspectableWebContentsImpl::AppendToFile(
const std::string& url, const std::string& content) {
void InspectableWebContentsImpl::AppendToFile(const std::string& url,
const std::string& content) {
if (delegate_)
delegate_->DevToolsAppendToFile(url, content);
}
@ -528,11 +518,11 @@ void InspectableWebContentsImpl::RemoveFileSystem(
}
void InspectableWebContentsImpl::UpgradeDraggedFileSystemPermissions(
const std::string& file_system_url) {
}
const std::string& file_system_url) {}
void InspectableWebContentsImpl::IndexPath(
int request_id, const std::string& file_system_path) {
int request_id,
const std::string& file_system_path) {
if (delegate_)
delegate_->DevToolsIndexPath(request_id, file_system_path);
}
@ -551,8 +541,7 @@ void InspectableWebContentsImpl::SearchInPath(
}
void InspectableWebContentsImpl::SetWhitelistedShortcuts(
const std::string& message) {
}
const std::string& message) {}
void InspectableWebContentsImpl::ZoomIn() {
double new_level = GetNextZoomLevel(GetDevToolsZoomLevel(), false);
@ -571,14 +560,14 @@ void InspectableWebContentsImpl::ResetZoom() {
UpdateDevToolsZoomLevel(0.);
}
void InspectableWebContentsImpl::SetDevicesUpdatesEnabled(bool enabled) {
}
void InspectableWebContentsImpl::SetDevicesUpdatesEnabled(bool enabled) {}
void InspectableWebContentsImpl::DispatchProtocolMessageFromDevToolsFrontend(
const std::string& message) {
// If the devtools wants to reload the page, hijack the message and handle it
// to the delegate.
if (base::MatchPattern(message, "{\"id\":*,"
if (base::MatchPattern(message,
"{\"id\":*,"
"\"method\":\"Page.reload\","
"\"params\":*}")) {
if (delegate_)
@ -599,8 +588,8 @@ void InspectableWebContentsImpl::SendJsonRequest(
void InspectableWebContentsImpl::GetPreferences(
const DispatchCallback& callback) {
const base::DictionaryValue* prefs = pref_service_->GetDictionary(
kDevToolsPreferences);
const base::DictionaryValue* prefs =
pref_service_->GetDictionary(kDevToolsPreferences);
callback.Run(prefs);
}
@ -634,8 +623,7 @@ void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend(
base::DictionaryValue* dict = nullptr;
std::unique_ptr<base::Value> parsed_message(base::JSONReader::Read(message));
if (!parsed_message ||
!parsed_message->GetAsDictionary(&dict) ||
if (!parsed_message || !parsed_message->GetAsDictionary(&dict) ||
!dict->GetString(kFrontendHostMethod, &method) ||
(dict->HasKey(kFrontendHostParams) &&
!dict->GetList(kFrontendHostParams, &params))) {
@ -646,20 +634,19 @@ void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend(
dict->GetInteger(kFrontendHostId, &id);
embedder_message_dispatcher_->Dispatch(
base::Bind(&InspectableWebContentsImpl::SendMessageAck,
weak_factory_.GetWeakPtr(),
id),
method,
params);
weak_factory_.GetWeakPtr(), id),
method, params);
}
void InspectableWebContentsImpl::DispatchProtocolMessage(
content::DevToolsAgentHost* agent_host, const std::string& message) {
content::DevToolsAgentHost* agent_host,
const std::string& message) {
if (!frontend_loaded_)
return;
if (message.length() < kMaxMessageChunkSize) {
base::string16 javascript = base::UTF8ToUTF16(
"DevToolsAPI.dispatchMessage(" + message + ");");
base::string16 javascript =
base::UTF8ToUTF16("DevToolsAPI.dispatchMessage(" + message + ");");
GetDevToolsWebContents()->GetMainFrame()->ExecuteJavaScript(javascript);
return;
}
@ -667,14 +654,14 @@ void InspectableWebContentsImpl::DispatchProtocolMessage(
base::Value total_size(static_cast<int>(message.length()));
for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) {
base::Value message_value(message.substr(pos, kMaxMessageChunkSize));
CallClientFunction("DevToolsAPI.dispatchMessageChunk",
&message_value, pos ? nullptr : &total_size, nullptr);
CallClientFunction("DevToolsAPI.dispatchMessageChunk", &message_value,
pos ? nullptr : &total_size, nullptr);
}
}
void InspectableWebContentsImpl::AgentHostClosed(
content::DevToolsAgentHost* agent_host, bool replaced) {
}
content::DevToolsAgentHost* agent_host,
bool replaced) {}
void InspectableWebContentsImpl::RenderFrameHostChanged(
content::RenderFrameHost* old_host,
@ -707,8 +694,9 @@ bool InspectableWebContentsImpl::DidAddMessageToConsole(
const base::string16& message,
int32_t line_no,
const base::string16& source_id) {
logging::LogMessage("CONSOLE", line_no, level).stream() << "\"" <<
message << "\", source: " << source_id << " (" << line_no << ")";
logging::LogMessage("CONSOLE", line_no, level).stream()
<< "\"" << message << "\", source: " << source_id << " (" << line_no
<< ")";
return true;
}
@ -846,8 +834,7 @@ void InspectableWebContentsImpl::OnURLFetchComplete(
void InspectableWebContentsImpl::SendMessageAck(int request_id,
const base::Value* arg) {
base::Value id_value(request_id);
CallClientFunction("DevToolsAPI.embedderMessageAck",
&id_value, arg, nullptr);
CallClientFunction("DevToolsAPI.embedderMessageAck", &id_value, arg, nullptr);
}
} // namespace brightray

View file

@ -29,8 +29,8 @@ namespace brightray {
class InspectableWebContentsDelegate;
class InspectableWebContentsView;
class InspectableWebContentsImpl :
public InspectableWebContents,
class InspectableWebContentsImpl
: public InspectableWebContents,
public content::DevToolsAgentHostClient,
public content::WebContentsObserver,
public content::WebContentsDelegate,
@ -156,8 +156,8 @@ class InspectableWebContentsImpl :
const GURL& target_url,
const std::string& partition_id,
content::SessionStorageNamespace* session_storage_namespace) override;
void HandleKeyboardEvent(
content::WebContents*, const content::NativeWebKeyboardEvent&) override;
void HandleKeyboardEvent(content::WebContents*,
const content::NativeWebKeyboardEvent&) override;
void CloseContents(content::WebContents* source) override;
content::ColorChooser* OpenColorChooser(
content::WebContents* source,
@ -172,8 +172,7 @@ class InspectableWebContentsImpl :
// net::URLFetcherDelegate:
void OnURLFetchComplete(const net::URLFetcher* source) override;
void SendMessageAck(int request_id,
const base::Value* arg1);
void SendMessageAck(int request_id, const base::Value* arg1);
bool frontend_loaded_;
scoped_refptr<content::DevToolsAgentHost> agent_host_;

View file

@ -25,9 +25,7 @@ class InspectableWebContentsView {
void SetDelegate(InspectableWebContentsViewDelegate* delegate) {
delegate_ = delegate;
}
InspectableWebContentsViewDelegate* GetDelegate() const {
return delegate_;
}
InspectableWebContentsViewDelegate* GetDelegate() const { return delegate_; }
#if defined(TOOLKIT_VIEWS)
// Returns the container control, which has devtools view attached.

View file

@ -7,4 +7,3 @@ gfx::ImageSkia InspectableWebContentsViewDelegate::GetDevToolsWindowIcon() {
}
} // namespace brightray

View file

@ -20,8 +20,8 @@ class InspectableWebContentsViewDelegate {
#if defined(USE_X11)
// Called when creating devtools window.
virtual void GetDevToolsWindowWMClass(
std::string* name, std::string* class_name) {}
virtual void GetDevToolsWindowWMClass(std::string* name,
std::string* class_name) {}
#endif
};

View file

@ -13,7 +13,7 @@
namespace net {
class URLRequestContext;
class URLRequestContextGetter;
}
} // namespace net
namespace brightray {

View file

@ -6,8 +6,7 @@
#include <dlfcn.h>
LibNotifyLoader::LibNotifyLoader() : loaded_(false) {
}
LibNotifyLoader::LibNotifyLoader() : loaded_(false) {}
LibNotifyLoader::~LibNotifyLoader() {
CleanUp(loaded_);
@ -21,16 +20,14 @@ bool LibNotifyLoader::Load(const std::string& library_name) {
if (!library_)
return false;
notify_is_initted =
reinterpret_cast<decltype(this->notify_is_initted)>(
notify_is_initted = reinterpret_cast<decltype(this->notify_is_initted)>(
dlsym(library_, "notify_is_initted"));
if (!notify_is_initted) {
CleanUp(true);
return false;
}
notify_init =
reinterpret_cast<decltype(this->notify_init)>(
notify_init = reinterpret_cast<decltype(this->notify_init)>(
dlsym(library_, "notify_init"));
if (!notify_init) {
CleanUp(true);

View file

@ -29,7 +29,7 @@ const std::set<std::string>& GetServerCapabilities() {
static std::set<std::string> caps;
if (caps.empty()) {
auto capabilities = libnotify_loader_.notify_get_server_caps();
for (auto l=capabilities; l != nullptr; l=l->next)
for (auto l = capabilities; l != nullptr; l = l->next)
caps.insert(static_cast<const char*>(l->data));
g_list_free_full(capabilities, g_free);
}
@ -48,10 +48,9 @@ bool NotifierSupportsActions() {
}
void log_and_clear_error(GError* error, const char* context) {
LOG(ERROR) << context
<< ": domain=" << error->domain
<< " code=" << error->code
<< " message=\"" << error->message << '"';
LOG(ERROR) << context << ": domain=" << error->domain
<< " code=" << error->code << " message=\"" << error->message
<< '"';
g_error_free(error);
}
@ -76,9 +75,7 @@ bool LibnotifyNotification::Initialize() {
LibnotifyNotification::LibnotifyNotification(NotificationDelegate* delegate,
NotificationPresenter* presenter)
: Notification(delegate, presenter),
notification_(nullptr) {
}
: Notification(delegate, presenter), notification_(nullptr) {}
LibnotifyNotification::~LibnotifyNotification() {
if (notification_) {
@ -90,11 +87,10 @@ LibnotifyNotification::~LibnotifyNotification() {
void LibnotifyNotification::Show(const NotificationOptions& options) {
notification_ = libnotify_loader_.notify_notification_new(
base::UTF16ToUTF8(options.title).c_str(),
base::UTF16ToUTF8(options.msg).c_str(),
nullptr);
base::UTF16ToUTF8(options.msg).c_str(), nullptr);
g_signal_connect(
notification_, "closed", G_CALLBACK(OnNotificationClosedThunk), this);
g_signal_connect(notification_, "closed",
G_CALLBACK(OnNotificationClosedThunk), this);
// NB: On Unity and on any other DE using Notify-OSD, adding a notification
// action will cause the notification to display as a modal dialog box.
@ -106,10 +102,10 @@ void LibnotifyNotification::Show(const NotificationOptions& options) {
if (!options.icon.drawsNothing()) {
GdkPixbuf* pixbuf = libgtkui::GdkPixbufFromSkBitmap(options.icon);
libnotify_loader_.notify_notification_set_image_from_pixbuf(
notification_, pixbuf);
libnotify_loader_.notify_notification_set_timeout(
notification_, NOTIFY_EXPIRES_DEFAULT);
libnotify_loader_.notify_notification_set_image_from_pixbuf(notification_,
pixbuf);
libnotify_loader_.notify_notification_set_timeout(notification_,
NOTIFY_EXPIRES_DEFAULT);
g_object_unref(pixbuf);
}
@ -121,8 +117,8 @@ void LibnotifyNotification::Show(const NotificationOptions& options) {
// Always try to append notifications.
// Unique tags can be used to prevent this.
if (HasCapability("append")) {
libnotify_loader_.notify_notification_set_hint_string(
notification_, "append", "true");
libnotify_loader_.notify_notification_set_hint_string(notification_,
"append", "true");
} else if (HasCapability("x-canonical-append")) {
libnotify_loader_.notify_notification_set_hint_string(
notification_, "x-canonical-append", "true");
@ -172,8 +168,8 @@ void LibnotifyNotification::OnNotificationClosed(
NotificationDismissed();
}
void LibnotifyNotification::OnNotificationView(
NotifyNotification* notification, char* action) {
void LibnotifyNotification::OnNotificationView(NotifyNotification* notification,
char* action) {
NotificationClicked();
}

View file

@ -27,10 +27,15 @@ class LibnotifyNotification : public Notification {
void Dismiss() override;
private:
CHROMEG_CALLBACK_0(LibnotifyNotification, void, OnNotificationClosed,
CHROMEG_CALLBACK_0(LibnotifyNotification,
void,
OnNotificationClosed,
NotifyNotification*);
CHROMEG_CALLBACK_1(LibnotifyNotification, void, OnNotificationView,
NotifyNotification*, char*);
CHROMEG_CALLBACK_1(LibnotifyNotification,
void,
OnNotificationView,
NotifyNotification*,
char*);
NotifyNotification* notification_;

View file

@ -16,11 +16,9 @@ NotificationPresenter* NotificationPresenter::Create() {
return new NotificationPresenterLinux;
}
NotificationPresenterLinux::NotificationPresenterLinux() {
}
NotificationPresenterLinux::NotificationPresenterLinux() {}
NotificationPresenterLinux::~NotificationPresenterLinux() {
}
NotificationPresenterLinux::~NotificationPresenterLinux() {}
Notification* NotificationPresenterLinux::CreateNotificationObject(
NotificationDelegate* delegate) {

View file

@ -10,8 +10,8 @@ class InspectableWebContentsViewMac;
using brightray::InspectableWebContentsViewMac;
@interface BRYInspectableWebContentsView : BaseView<NSWindowDelegate> {
@private
@interface BRYInspectableWebContentsView : BaseView <NSWindowDelegate> {
@private
brightray::InspectableWebContentsViewMac* inspectableWebContentsView_;
base::scoped_nsobject<NSWindow> devtools_window_;
@ -22,14 +22,16 @@ using brightray::InspectableWebContentsViewMac;
DevToolsContentsResizingStrategy strategy_;
}
- (instancetype)initWithInspectableWebContentsViewMac:(InspectableWebContentsViewMac*)view;
- (instancetype)initWithInspectableWebContentsViewMac:
(InspectableWebContentsViewMac*)view;
- (void)removeObservers;
- (void)notifyDevToolsFocused;
- (void)setDevToolsVisible:(BOOL)visible;
- (BOOL)isDevToolsVisible;
- (BOOL)isDevToolsFocused;
- (void)setIsDocked:(BOOL)docked;
- (void)setContentsResizingStrategy:(const DevToolsContentsResizingStrategy&)strategy;
- (void)setContentsResizingStrategy:
(const DevToolsContentsResizingStrategy&)strategy;
- (void)setTitle:(NSString*)title;
@end

View file

@ -11,12 +11,13 @@ namespace brightray {
class NotificationPresenterMac;
}
@interface NotificationCenterDelegate :
NSObject<NSUserNotificationCenterDelegate> {
@interface NotificationCenterDelegate
: NSObject <NSUserNotificationCenterDelegate> {
@private
brightray::NotificationPresenterMac* presenter_;
}
- (instancetype)initWithPresenter:(brightray::NotificationPresenterMac*)presenter;
- (instancetype)initWithPresenter:
(brightray::NotificationPresenterMac*)presenter;
@end
#endif // BROWSER_MAC_NOTIFICATION_DELEGATE_H_

View file

@ -127,11 +127,9 @@ void MediaCaptureDevicesDispatcher::DisableDeviceEnumerationForTesting() {
is_device_enumeration_disabled_ = true;
}
void MediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged() {
}
void MediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged() {}
void MediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged() {
}
void MediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged() {}
void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(
int render_process_id,
@ -139,20 +137,16 @@ void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(
int page_request_id,
const GURL& security_origin,
content::MediaStreamType stream_type,
content::MediaRequestState state) {
}
content::MediaRequestState state) {}
void MediaCaptureDevicesDispatcher::OnCreatingAudioStream(
int render_process_id,
int render_view_id) {
}
void MediaCaptureDevicesDispatcher::OnCreatingAudioStream(int render_process_id,
int render_view_id) {}
void MediaCaptureDevicesDispatcher::OnSetCapturingLinkSecured(
int render_process_id,
int render_frame_id,
int page_request_id,
content::MediaStreamType stream_type,
bool is_secure) {
}
bool is_secure) {}
} // namespace brightray

View file

@ -34,10 +34,10 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
// Helpers for picking particular requested devices, identified by raw id.
// If the device requested is not available it will return NULL.
const content::MediaStreamDevice*
GetRequestedAudioDevice(const std::string& requested_audio_device_id);
const content::MediaStreamDevice*
GetRequestedVideoDevice(const std::string& requested_video_device_id);
const content::MediaStreamDevice* GetRequestedAudioDevice(
const std::string& requested_audio_device_id);
const content::MediaStreamDevice* GetRequestedVideoDevice(
const std::string& requested_video_device_id);
// Returns the first available audio or video device, or NULL if no devices
// are available.
@ -52,8 +52,7 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
// Overridden from content::MediaObserver:
void OnAudioCaptureDevicesChanged() override;
void OnVideoCaptureDevicesChanged() override;
void OnMediaRequestStateChanged(
int render_process_id,
void OnMediaRequestStateChanged(int render_process_id,
int render_view_id,
int page_request_id,
const GURL& security_origin,

View file

@ -35,8 +35,7 @@ MediaStreamDevicesController::MediaStreamDevicesController(
request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY),
webcam_requested_(
request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE ||
request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) {
}
request.request_type == content::MEDIA_OPEN_DEVICE_PEPPER_ONLY) {}
MediaStreamDevicesController::~MediaStreamDevicesController() {
if (!callback_.is_null()) {
@ -76,35 +75,38 @@ void MediaStreamDevicesController::Accept() {
// For open device request pick the desired device or fall back to the
// first available of the given type.
if (request_.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE) {
device = MediaCaptureDevicesDispatcher::GetInstance()->
GetRequestedAudioDevice(request_.requested_audio_device_id);
device =
MediaCaptureDevicesDispatcher::GetInstance()
->GetRequestedAudioDevice(request_.requested_audio_device_id);
// TODO(wjia): Confirm this is the intended behavior.
if (!device) {
device = MediaCaptureDevicesDispatcher::GetInstance()->
GetFirstAvailableAudioDevice();
device = MediaCaptureDevicesDispatcher::GetInstance()
->GetFirstAvailableAudioDevice();
}
} else if (request_.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE) {
// Pepper API opens only one device at a time.
device = MediaCaptureDevicesDispatcher::GetInstance()->
GetRequestedVideoDevice(request_.requested_video_device_id);
device =
MediaCaptureDevicesDispatcher::GetInstance()
->GetRequestedVideoDevice(request_.requested_video_device_id);
// TODO(wjia): Confirm this is the intended behavior.
if (!device) {
device = MediaCaptureDevicesDispatcher::GetInstance()->
GetFirstAvailableVideoDevice();
device = MediaCaptureDevicesDispatcher::GetInstance()
->GetFirstAvailableVideoDevice();
}
}
if (device)
devices.push_back(*device);
break;
} case content::MEDIA_GENERATE_STREAM: {
}
case content::MEDIA_GENERATE_STREAM: {
bool needs_audio_device = microphone_requested_;
bool needs_video_device = webcam_requested_;
// Get the exact audio or video device if an id is specified.
if (!request_.requested_audio_device_id.empty()) {
const content::MediaStreamDevice* audio_device =
MediaCaptureDevicesDispatcher::GetInstance()->
GetRequestedAudioDevice(request_.requested_audio_device_id);
MediaCaptureDevicesDispatcher::GetInstance()
->GetRequestedAudioDevice(request_.requested_audio_device_id);
if (audio_device) {
devices.push_back(*audio_device);
needs_audio_device = false;
@ -112,8 +114,8 @@ void MediaStreamDevicesController::Accept() {
}
if (!request_.requested_video_device_id.empty()) {
const content::MediaStreamDevice* video_device =
MediaCaptureDevicesDispatcher::GetInstance()->
GetRequestedVideoDevice(request_.requested_video_device_id);
MediaCaptureDevicesDispatcher::GetInstance()
->GetRequestedVideoDevice(request_.requested_video_device_id);
if (video_device) {
devices.push_back(*video_device);
needs_video_device = false;
@ -123,18 +125,15 @@ void MediaStreamDevicesController::Accept() {
// If either or both audio and video devices were requested but not
// specified by id, get the default devices.
if (needs_audio_device || needs_video_device) {
MediaCaptureDevicesDispatcher::GetInstance()->
GetDefaultDevices(needs_audio_device,
needs_video_device,
&devices);
MediaCaptureDevicesDispatcher::GetInstance()->GetDefaultDevices(
needs_audio_device, needs_video_device, &devices);
}
break;
} case content::MEDIA_DEVICE_ACCESS:
}
case content::MEDIA_DEVICE_ACCESS:
// Get the default devices for the request.
MediaCaptureDevicesDispatcher::GetInstance()->
GetDefaultDevices(microphone_requested_,
webcam_requested_,
&devices);
MediaCaptureDevicesDispatcher::GetInstance()->GetDefaultDevices(
microphone_requested_, webcam_requested_, &devices);
break;
}
}
@ -149,8 +148,7 @@ void MediaStreamDevicesController::Deny(
content::MediaStreamRequestResult result) {
content::MediaResponseCallback cb = callback_;
callback_.Reset();
cb.Run(content::MediaStreamDevices(),
result,
cb.Run(content::MediaStreamDevices(), result,
std::unique_ptr<content::MediaStreamUI>());
}
@ -158,12 +156,12 @@ void MediaStreamDevicesController::HandleUserMediaRequest() {
content::MediaStreamDevices devices;
if (request_.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE) {
devices.push_back(content::MediaStreamDevice(
content::MEDIA_TAB_AUDIO_CAPTURE, "", ""));
devices.push_back(
content::MediaStreamDevice(content::MEDIA_TAB_AUDIO_CAPTURE, "", ""));
}
if (request_.video_type == content::MEDIA_TAB_VIDEO_CAPTURE) {
devices.push_back(content::MediaStreamDevice(
content::MEDIA_TAB_VIDEO_CAPTURE, "", ""));
devices.push_back(
content::MediaStreamDevice(content::MEDIA_TAB_VIDEO_CAPTURE, "", ""));
}
if (request_.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE) {
devices.push_back(content::MediaStreamDevice(
@ -181,16 +179,15 @@ void MediaStreamDevicesController::HandleUserMediaRequest() {
content::DesktopMediaID::Parse(request_.requested_video_device_id);
}
devices.push_back(
content::MediaStreamDevice(content::MEDIA_DESKTOP_VIDEO_CAPTURE,
screen_id.ToString(), "Screen"));
devices.push_back(content::MediaStreamDevice(
content::MEDIA_DESKTOP_VIDEO_CAPTURE, screen_id.ToString(), "Screen"));
}
content::MediaResponseCallback cb = callback_;
callback_.Reset();
cb.Run(devices,
devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE :
content::MEDIA_DEVICE_OK,
devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE
: content::MEDIA_DEVICE_OK,
std::unique_ptr<content::MediaStreamUI>());
}

View file

@ -33,8 +33,7 @@ std::unique_ptr<base::DictionaryValue> GetConstants() {
} // namespace
NetLog::NetLog() {
}
NetLog::NetLog() {}
NetLog::~NetLog() {
if (file_net_log_observer_) {

View file

@ -32,11 +32,9 @@ NetworkDelegate::NetworkDelegate() {
}
}
NetworkDelegate::~NetworkDelegate() {
}
NetworkDelegate::~NetworkDelegate() {}
int NetworkDelegate::OnBeforeURLRequest(
net::URLRequest* request,
int NetworkDelegate::OnBeforeURLRequest(net::URLRequest* request,
const net::CompletionCallback& callback,
GURL* new_url) {
for (const auto& domain : ignore_connections_limit_domains_) {
@ -60,15 +58,13 @@ int NetworkDelegate::OnBeforeStartTransaction(
void NetworkDelegate::OnStartTransaction(
net::URLRequest* request,
const net::HttpRequestHeaders& headers) {
}
const net::HttpRequestHeaders& headers) {}
void NetworkDelegate::OnBeforeSendHeaders(
net::URLRequest* request,
const net::ProxyInfo& proxy_info,
const net::ProxyRetryInfoMap& proxy_retry_info,
net::HttpRequestHeaders* headers) {
}
net::HttpRequestHeaders* headers) {}
int NetworkDelegate::OnHeadersReceived(
net::URLRequest* request,
@ -80,29 +76,22 @@ int NetworkDelegate::OnHeadersReceived(
}
void NetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
const GURL& new_location) {
}
const GURL& new_location) {}
void NetworkDelegate::OnResponseStarted(net::URLRequest* request) {
}
void NetworkDelegate::OnResponseStarted(net::URLRequest* request) {}
void NetworkDelegate::OnNetworkBytesReceived(net::URLRequest* request,
int64_t bytes_read) {
}
int64_t bytes_read) {}
void NetworkDelegate::OnNetworkBytesSent(net::URLRequest* request,
int64_t bytes_sent) {
}
int64_t bytes_sent) {}
void NetworkDelegate::OnCompleted(net::URLRequest* request, bool started) {
}
void NetworkDelegate::OnCompleted(net::URLRequest* request, bool started) {}
void NetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {
}
void NetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {}
void NetworkDelegate::OnPACScriptError(int line_number,
const base::string16& error) {
}
const base::string16& error) {}
NetworkDelegate::AuthRequiredResponse NetworkDelegate::OnAuthRequired(
net::URLRequest* request,
@ -159,14 +148,12 @@ bool NetworkDelegate::OnCanSendReportingReport(
return false;
}
bool NetworkDelegate::OnCanSetReportingClient(
const url::Origin& origin,
bool NetworkDelegate::OnCanSetReportingClient(const url::Origin& origin,
const GURL& endpoint) const {
return false;
}
bool NetworkDelegate::OnCanUseReportingClient(
const url::Origin& origin,
bool NetworkDelegate::OnCanUseReportingClient(const url::Origin& origin,
const GURL& endpoint) const {
return false;
}

View file

@ -45,8 +45,7 @@ class NetworkDelegate : public net::NetworkDelegate {
int64_t bytes_sent) override;
void OnCompleted(net::URLRequest* request, bool started) override;
void OnURLRequestDestroyed(net::URLRequest* request) override;
void OnPACScriptError(int line_number,
const base::string16& error) override;
void OnPACScriptError(int line_number, const base::string16& error) override;
AuthRequiredResponse OnAuthRequired(
net::URLRequest* request,
const net::AuthChallengeInfo& auth_info,

View file

@ -11,10 +11,7 @@ namespace brightray {
Notification::Notification(NotificationDelegate* delegate,
NotificationPresenter* presenter)
: delegate_(delegate),
presenter_(presenter),
weak_factory_(this) {
}
: delegate_(delegate), presenter_(presenter), weak_factory_(this) {}
Notification::~Notification() {
if (delegate())

View file

@ -8,8 +8,7 @@
namespace brightray {
NotificationPresenter::NotificationPresenter() {
}
NotificationPresenter::NotificationPresenter() {}
NotificationPresenter::~NotificationPresenter() {
for (Notification* notification : notifications_)

View file

@ -12,11 +12,9 @@
namespace brightray {
PermissionManager::PermissionManager() {
}
PermissionManager::PermissionManager() {}
PermissionManager::~PermissionManager() {
}
PermissionManager::~PermissionManager() {}
int PermissionManager::RequestPermission(
content::PermissionType permission,
@ -25,8 +23,8 @@ int PermissionManager::RequestPermission(
bool user_gesture,
const base::Callback<void(blink::mojom::PermissionStatus)>& callback) {
if (permission == content::PermissionType::MIDI_SYSEX) {
content::ChildProcessSecurityPolicy::GetInstance()->
GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
content::ChildProcessSecurityPolicy::GetInstance()
->GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
}
callback.Run(blink::mojom::PermissionStatus::GRANTED);
return kNoPendingOperation;
@ -37,14 +35,14 @@ int PermissionManager::RequestPermissions(
content::RenderFrameHost* render_frame_host,
const GURL& requesting_origin,
bool user_gesture,
const base::Callback<void(
const std::vector<blink::mojom::PermissionStatus>&)>& callback) {
const base::Callback<
void(const std::vector<blink::mojom::PermissionStatus>&)>& callback) {
std::vector<blink::mojom::PermissionStatus> permissionStatuses;
for (auto permission : permissions) {
if (permission == content::PermissionType::MIDI_SYSEX) {
content::ChildProcessSecurityPolicy::GetInstance()->
GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
content::ChildProcessSecurityPolicy::GetInstance()
->GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
}
permissionStatuses.push_back(blink::mojom::PermissionStatus::GRANTED);
@ -54,14 +52,11 @@ int PermissionManager::RequestPermissions(
return kNoPendingOperation;
}
void PermissionManager::CancelPermissionRequest(int request_id) {
}
void PermissionManager::CancelPermissionRequest(int request_id) {}
void PermissionManager::ResetPermission(
content::PermissionType permission,
void PermissionManager::ResetPermission(content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) {
}
const GURL& embedding_origin) {}
blink::mojom::PermissionStatus PermissionManager::GetPermissionStatus(
content::PermissionType permission,

View file

@ -77,9 +77,7 @@ class NotificationDelegateImpl final : public brightray::NotificationDelegate {
PlatformNotificationService::PlatformNotificationService(
BrowserClient* browser_client)
: browser_client_(browser_client),
render_process_id_(-1) {
}
: browser_client_(browser_client), render_process_id_(-1) {}
PlatformNotificationService::~PlatformNotificationService() {}
@ -128,17 +126,14 @@ void PlatformNotificationService::DisplayPersistentNotification(
const GURL& service_worker_scope,
const GURL& origin,
const content::PlatformNotificationData& notification_data,
const content::NotificationResources& notification_resources) {
}
const content::NotificationResources& notification_resources) {}
void PlatformNotificationService::ClosePersistentNotification(
content::BrowserContext* browser_context,
const std::string& notification_id) {
}
const std::string& notification_id) {}
void PlatformNotificationService::GetDisplayedNotifications(
content::BrowserContext* browser_context,
const DisplayedNotificationsCallback& callback) {
}
const DisplayedNotificationsCallback& callback) {}
} // namespace brightray

View file

@ -6,11 +6,9 @@
namespace brightray {
SpecialStoragePolicy::SpecialStoragePolicy() {
}
SpecialStoragePolicy::SpecialStoragePolicy() {}
SpecialStoragePolicy::~SpecialStoragePolicy() {
}
SpecialStoragePolicy::~SpecialStoragePolicy() {}
bool SpecialStoragePolicy::IsStorageProtected(const GURL& origin) {
return true;

View file

@ -67,8 +67,8 @@ URLRequestContextGetter::Delegate::CreateURLRequestJobFactory(
new net::URLRequestJobFactoryImpl);
for (auto& it : *protocol_handlers) {
job_factory->SetProtocolHandler(
it.first, base::WrapUnique(it.second.release()));
job_factory->SetProtocolHandler(it.first,
base::WrapUnique(it.second.release()));
}
protocol_handlers->clear();
@ -94,10 +94,7 @@ URLRequestContextGetter::Delegate::CreateHttpCacheBackendFactory(
base::FilePath cache_path = base_path.Append(FILE_PATH_LITERAL("Cache"));
return new net::HttpCache::DefaultBackend(
net::DISK_CACHE,
net::CACHE_BACKEND_DEFAULT,
cache_path,
max_size);
net::DISK_CACHE, net::CACHE_BACKEND_DEFAULT, cache_path, max_size);
}
std::unique_ptr<net::CertVerifier>
@ -113,7 +110,7 @@ URLRequestContextGetter::Delegate::CreateSSLConfigService() {
std::vector<std::string>
URLRequestContextGetter::Delegate::GetCookieableSchemes() {
return { "http", "https", "ws", "wss" };
return {"http", "https", "ws", "wss"};
}
URLRequestContextGetter::URLRequestContextGetter(
@ -144,12 +141,11 @@ URLRequestContextGetter::URLRequestContextGetter(
// We must create the proxy config service on the UI loop on Linux because it
// must synchronously run on the glib message loop. This will be passed to
// the URLRequestContextStorage on the IO thread in GetURLRequestContext().
proxy_config_service_ = net::ProxyService::CreateSystemProxyConfigService(
io_task_runner_);
proxy_config_service_ =
net::ProxyService::CreateSystemProxyConfigService(io_task_runner_);
}
URLRequestContextGetter::~URLRequestContextGetter() {
}
URLRequestContextGetter::~URLRequestContextGetter() {}
void URLRequestContextGetter::NotifyContextShutdownOnIO() {
context_shutting_down_ = true;
@ -204,11 +200,11 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
storage_->set_network_delegate(delegate_->CreateNetworkDelegate());
auto cookie_path = in_memory_ ?
base::FilePath() : base_path_.Append(FILE_PATH_LITERAL("Cookies"));
auto cookie_path = in_memory_
? base::FilePath()
: base_path_.Append(FILE_PATH_LITERAL("Cookies"));
auto cookie_config = content::CookieStoreConfig(
cookie_path,
content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
cookie_path, content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
nullptr);
cookie_config.cookieable_schemes = delegate_->GetCookieableSchemes();
std::unique_ptr<net::CookieStore> cookie_store =
@ -255,13 +251,11 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
auto proxy_config = net::ProxyConfig::CreateFromCustomPacURL(
GURL(command_line.GetSwitchValueASCII(switches::kProxyPacUrl)));
proxy_config.set_pac_mandatory(true);
storage_->set_proxy_service(net::ProxyService::CreateFixed(
proxy_config));
storage_->set_proxy_service(net::ProxyService::CreateFixed(proxy_config));
} else {
storage_->set_proxy_service(
net::ProxyService::CreateUsingSystemProxyResolver(
std::move(proxy_config_service_),
net_log_));
std::move(proxy_config_service_), net_log_));
}
std::vector<std::string> schemes;
@ -270,8 +264,8 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
schemes.push_back(std::string("ntlm"));
schemes.push_back(std::string("negotiate"));
#if defined(OS_POSIX)
http_auth_preferences_.reset(new net::HttpAuthPreferences(schemes,
std::string()));
http_auth_preferences_.reset(
new net::HttpAuthPreferences(schemes, std::string()));
#else
http_auth_preferences_.reset(new net::HttpAuthPreferences(schemes));
#endif
@ -289,8 +283,7 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
switches::kAuthNegotiateDelegateWhitelist));
}
auto auth_handler_factory =
net::HttpAuthHandlerRegistryFactory::Create(
auto auth_handler_factory = net::HttpAuthHandlerRegistryFactory::Create(
http_auth_preferences_.get(), host_resolver.get());
std::unique_ptr<net::TransportSecurityState> transport_security_state =

View file

@ -34,7 +34,7 @@ class NetworkDelegate;
class ProxyConfigService;
class URLRequestContextStorage;
class URLRequestJobFactory;
}
} // namespace net
namespace brightray {

View file

@ -87,8 +87,8 @@ InspectableWebContentsViewViews::InspectableWebContentsViewViews(
inspectable_web_contents_->GetWebContents());
contents_web_view_ = contents_web_view;
} else {
contents_web_view_ = new views::Label(
base::ASCIIToUTF16("No content under offscreen mode"));
contents_web_view_ =
new views::Label(base::ASCIIToUTF16("No content under offscreen mode"));
}
devtools_web_view_->SetVisible(false);
@ -168,9 +168,7 @@ void InspectableWebContentsViewViews::SetIsDocked(bool docked) {
devtools_window_.reset(new views::Widget);
devtools_window_web_view_ = new views::WebView(NULL);
devtools_window_delegate_ = new DevToolsWindowDelegate(
this,
devtools_window_web_view_,
devtools_window_.get());
this, devtools_window_web_view_, devtools_window_.get());
views::Widget::InitParams params;
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
@ -213,8 +211,8 @@ void InspectableWebContentsViewViews::Layout() {
gfx::Size container_size(width(), height());
gfx::Rect new_devtools_bounds;
gfx::Rect new_contents_bounds;
ApplyDevToolsContentsResizingStrategy(strategy_, container_size,
&new_devtools_bounds, &new_contents_bounds);
ApplyDevToolsContentsResizingStrategy(
strategy_, container_size, &new_devtools_bounds, &new_contents_bounds);
// DevTools cares about the specific position, so we have to compensate RTL
// layout here.

View file

@ -10,7 +10,7 @@ namespace views {
class WebView;
class Widget;
class WidgetDelegate;
}
} // namespace views
namespace brightray {

View file

@ -30,17 +30,14 @@ bool IsDesktopEnvironmentUnity() {
namespace brightray {
ViewsDelegate::ViewsDelegate() {
}
ViewsDelegate::ViewsDelegate() {}
ViewsDelegate::~ViewsDelegate() {
}
ViewsDelegate::~ViewsDelegate() {}
void ViewsDelegate::SaveWindowPlacement(const views::Widget* window,
const std::string& window_name,
const gfx::Rect& bounds,
ui::WindowShowState show_state) {
}
ui::WindowShowState show_state) {}
bool ViewsDelegate::GetSavedWindowPlacement(
const views::Widget* widget,
@ -50,17 +47,14 @@ bool ViewsDelegate::GetSavedWindowPlacement(
return false;
}
void ViewsDelegate::NotifyAccessibilityEvent(
views::View* view, ui::AXEvent event_type) {
}
void ViewsDelegate::NotifyAccessibilityEvent(views::View* view,
ui::AXEvent event_type) {}
void ViewsDelegate::NotifyMenuItemFocused(
const base::string16& menu_name,
void ViewsDelegate::NotifyMenuItemFocused(const base::string16& menu_name,
const base::string16& menu_item_name,
int item_index,
int item_count,
bool has_submenu) {
}
bool has_submenu) {}
#if defined(OS_WIN)
HICON ViewsDelegate::GetDefaultWindowIcon() const {
@ -88,11 +82,9 @@ views::NonClientFrameView* ViewsDelegate::CreateDefaultNonClientFrameView(
return NULL;
}
void ViewsDelegate::AddRef() {
}
void ViewsDelegate::AddRef() {}
void ViewsDelegate::ReleaseRef() {
}
void ViewsDelegate::ReleaseRef() {}
content::WebContents* ViewsDelegate::CreateWebContents(
content::BrowserContext* browser_context,
@ -108,8 +100,7 @@ void ViewsDelegate::OnBeforeWidgetInit(
if (params->native_widget)
return;
if (params->parent &&
params->type != views::Widget::InitParams::TYPE_MENU &&
if (params->parent && params->type != views::Widget::InitParams::TYPE_MENU &&
params->type != views::Widget::InitParams::TYPE_TOOLTIP) {
params->native_widget = new views::NativeWidgetAura(delegate);
} else {

View file

@ -23,13 +23,12 @@ class ViewsDelegate : public views::ViewsDelegate {
const std::string& window_name,
const gfx::Rect& bounds,
ui::WindowShowState show_state) override;
bool GetSavedWindowPlacement(
const views::Widget* widget,
bool GetSavedWindowPlacement(const views::Widget* widget,
const std::string& window_name,
gfx::Rect* bounds,
ui::WindowShowState* show_state) const override;
void NotifyAccessibilityEvent(
views::View* view, ui::AXEvent event_type) override;
void NotifyAccessibilityEvent(views::View* view,
ui::AXEvent event_type) override;
void NotifyMenuItemFocused(const base::string16& menu_name,
const base::string16& menu_item_name,
int item_index,

View file

@ -23,14 +23,13 @@ WebUIControllerFactory* WebUIControllerFactory::GetInstance() {
return base::Singleton<WebUIControllerFactory>::get();
}
WebUIControllerFactory::WebUIControllerFactory() {
}
WebUIControllerFactory::WebUIControllerFactory() {}
WebUIControllerFactory::~WebUIControllerFactory() {
}
WebUIControllerFactory::~WebUIControllerFactory() {}
content::WebUI::TypeID WebUIControllerFactory::GetWebUIType(
content::BrowserContext* browser_context, const GURL& url) const {
content::BrowserContext* browser_context,
const GURL& url) const {
if (url.host() == kChromeUIDevToolsBundledHost) {
return const_cast<WebUIControllerFactory*>(this);
}
@ -39,17 +38,20 @@ content::WebUI::TypeID WebUIControllerFactory::GetWebUIType(
}
bool WebUIControllerFactory::UseWebUIForURL(
content::BrowserContext* browser_context, const GURL& url) const {
content::BrowserContext* browser_context,
const GURL& url) const {
return GetWebUIType(browser_context, url) != content::WebUI::kNoWebUI;
}
bool WebUIControllerFactory::UseWebUIBindingsForURL(
content::BrowserContext* browser_context, const GURL& url) const {
content::BrowserContext* browser_context,
const GURL& url) const {
return UseWebUIForURL(browser_context, url);
}
content::WebUIController* WebUIControllerFactory::CreateWebUIControllerForURL(
content::WebUI* web_ui, const GURL& url) const {
content::WebUI* web_ui,
const GURL& url) const {
if (url.host() == kChromeUIDevToolsBundledHost) {
auto browser_context = web_ui->GetWebContents()->GetBrowserContext();
return new DevToolsUI(browser_context, web_ui);

View file

@ -10,7 +10,8 @@
#include "content/public/browser/web_ui_controller_factory.h"
namespace base {
template <typename T> struct DefaultSingletonTraits;
template <typename T>
struct DefaultSingletonTraits;
}
namespace brightray {
@ -24,8 +25,8 @@ class WebUIControllerFactory : public content::WebUIControllerFactory {
WebUIControllerFactory();
virtual ~WebUIControllerFactory();
content::WebUI::TypeID GetWebUIType(
content::BrowserContext* browser_context, const GURL& url) const override;
content::WebUI::TypeID GetWebUIType(content::BrowserContext* browser_context,
const GURL& url) const override;
bool UseWebUIForURL(content::BrowserContext* browser_context,
const GURL& url) const override;
bool UseWebUIBindingsForURL(content::BrowserContext* browser_context,

View file

@ -62,11 +62,9 @@ NotificationPresenter* NotificationPresenter::Create() {
return presenter.release();
}
NotificationPresenterWin::NotificationPresenterWin() {
}
NotificationPresenterWin::NotificationPresenterWin() {}
NotificationPresenterWin::~NotificationPresenterWin() {
}
NotificationPresenterWin::~NotificationPresenterWin() {}
bool NotificationPresenterWin::Init() {
base::ThreadRestrictions::ScopedAllowIO allow_io;
@ -74,7 +72,8 @@ bool NotificationPresenterWin::Init() {
}
base::string16 NotificationPresenterWin::SaveIconToFilesystem(
const SkBitmap& icon, const GURL& origin) {
const SkBitmap& icon,
const GURL& origin) {
std::string filename;
if (origin.is_valid()) {

View file

@ -36,13 +36,15 @@ Win32Notification* NotificationPresenterWin7::GetNotificationObjectByTag(
void NotificationPresenterWin7::OnNotificationClicked(
Notification& notification) {
auto n = GetNotificationObjectByRef(notification);
if (n) n->NotificationClicked();
if (n)
n->NotificationClicked();
}
void NotificationPresenterWin7::OnNotificationDismissed(
Notification& notification) {
auto n = GetNotificationObjectByRef(notification);
if (n) n->NotificationDismissed();
if (n)
n->NotificationDismissed();
}
} // namespace brightray

View file

@ -6,8 +6,7 @@ namespace brightray {
class Win32Notification;
class NotificationPresenterWin7 :
public NotificationPresenter,
class NotificationPresenterWin7 : public NotificationPresenter,
public DesktopNotificationController {
public:
NotificationPresenterWin7() = default;

View file

@ -6,18 +6,15 @@
#include <winstring.h>
ScopedHString::ScopedHString(const wchar_t* source)
: str_(nullptr) {
ScopedHString::ScopedHString(const wchar_t* source) : str_(nullptr) {
Reset(source);
}
ScopedHString::ScopedHString(const std::wstring& source)
: str_(nullptr) {
ScopedHString::ScopedHString(const std::wstring& source) : str_(nullptr) {
Reset(source);
}
ScopedHString::ScopedHString() : str_(nullptr) {
}
ScopedHString::ScopedHString() : str_(nullptr) {}
ScopedHString::~ScopedHString() {
Reset();

View file

@ -13,14 +13,15 @@ struct NotificationData {
NotificationData() = default;
~NotificationData() {
if (image) DeleteObject(image);
if (image)
DeleteObject(image);
}
NotificationData(const NotificationData& other) = delete;
NotificationData& operator=(const NotificationData& other) = delete;
};
template<typename T>
template <typename T>
constexpr T ScaleForDpi(T value, unsigned dpi, unsigned source_dpi = 96) {
return value * dpi / source_dpi;
}
@ -32,8 +33,7 @@ struct ScreenMetrics {
typedef HRESULT WINAPI GetDpiForMonitor_t(HMONITOR, int, UINT*, UINT*);
auto GetDpiForMonitor = reinterpret_cast<GetDpiForMonitor_t*>(
GetProcAddress(GetModuleHandle(TEXT("shcore")),
"GetDpiForMonitor"));
GetProcAddress(GetModuleHandle(TEXT("shcore")), "GetDpiForMonitor"));
if (GetDpiForMonitor) {
auto monitor = MonitorFromPoint({}, MONITOR_DEFAULTTOPRIMARY);
@ -47,8 +47,14 @@ struct ScreenMetrics {
ReleaseDC(NULL, hdc);
}
template<class T> T X(T value) const { return ScaleForDpi(value, dpi_x); }
template<class T> T Y(T value) const { return ScaleForDpi(value, dpi_y); }
template <class T>
T X(T value) const {
return ScaleForDpi(value, dpi_x);
}
template <class T>
T Y(T value) const {
return ScaleForDpi(value, dpi_y);
}
};
} // namespace brightray

View file

@ -26,8 +26,7 @@ HBITMAP CopyBitmap(HBITMAP bitmap) {
HDC hdc_dst = CreateCompatibleDC(NULL);
SelectBitmap(hdc_src, bitmap);
SelectBitmap(hdc_dst, ret);
BitBlt(hdc_dst, 0, 0, bm.bmWidth, bm.bmHeight,
hdc_src, 0, 0, SRCCOPY);
BitBlt(hdc_dst, 0, 0, bm.bmWidth, bm.bmHeight, hdc_src, 0, 0, SRCCOPY);
DeleteDC(hdc_dst);
DeleteDC(hdc_src);
}
@ -52,7 +51,7 @@ HINSTANCE DesktopNotificationController::RegisterWndClasses() {
&module)) {
Toast::Register(module);
WNDCLASSEX wc = { sizeof(wc) };
WNDCLASSEX wc = {sizeof(wc)};
wc.lpfnWndProc = &WndProc;
wc.lpszClassName = class_name_;
wc.cbWndExtra = sizeof(DesktopNotificationController*);
@ -71,20 +70,22 @@ DesktopNotificationController::DesktopNotificationController(
}
DesktopNotificationController::~DesktopNotificationController() {
for (auto&& inst : instances_) DestroyToast(inst);
if (hwnd_controller_) DestroyWindow(hwnd_controller_);
for (auto&& inst : instances_)
DestroyToast(inst);
if (hwnd_controller_)
DestroyWindow(hwnd_controller_);
ClearAssets();
}
LRESULT CALLBACK DesktopNotificationController::WndProc(
HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
LRESULT CALLBACK DesktopNotificationController::WndProc(HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam) {
switch (message) {
case WM_CREATE:
{
case WM_CREATE: {
auto& cs = reinterpret_cast<const CREATESTRUCT*&>(lparam);
SetWindowLongPtr(hwnd, 0, (LONG_PTR)cs->lpCreateParams);
}
break;
} break;
case WM_TIMER:
if (wparam == TimerID_Animate) {
@ -92,13 +93,11 @@ LRESULT CALLBACK DesktopNotificationController::WndProc(
}
return 0;
case WM_DISPLAYCHANGE:
{
case WM_DISPLAYCHANGE: {
auto inst = Get(hwnd);
inst->ClearAssets();
inst->AnimateAll();
}
break;
} break;
case WM_SETTINGCHANGE:
if (wparam == SPI_SETWORKAREA) {
@ -135,7 +134,7 @@ HFONT DesktopNotificationController::GetBodyFont() {
void DesktopNotificationController::InitializeFonts() {
if (!body_font_) {
NONCLIENTMETRICS metrics = { sizeof(metrics) };
NONCLIENTMETRICS metrics = {sizeof(metrics)};
if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &metrics, 0)) {
auto base_height = metrics.lfMessageFont.lfHeight;
@ -149,7 +148,8 @@ void DesktopNotificationController::InitializeFonts() {
(LONG)ScaleForDpi(base_height * 1.1f, scr.dpi_y, base_dpi_y);
body_font_ = CreateFontIndirect(&metrics.lfMessageFont);
if (caption_font_) DeleteFont(caption_font_);
if (caption_font_)
DeleteFont(caption_font_);
metrics.lfMessageFont.lfHeight =
(LONG)ScaleForDpi(base_height * 1.4f, scr.dpi_y, base_dpi_y);
caption_font_ = CreateFontIndirect(&metrics.lfMessageFont);
@ -158,8 +158,14 @@ void DesktopNotificationController::InitializeFonts() {
}
void DesktopNotificationController::ClearAssets() {
if (caption_font_) { DeleteFont(caption_font_); caption_font_ = NULL; }
if (body_font_) { DeleteFont(body_font_); body_font_ = NULL; }
if (caption_font_) {
DeleteFont(caption_font_);
caption_font_ = NULL;
}
if (body_font_) {
DeleteFont(body_font_);
body_font_ = NULL;
}
}
void DesktopNotificationController::AnimateAll() {
@ -173,28 +179,31 @@ void DesktopNotificationController::AnimateAll() {
RECT work_area;
if (SystemParametersInfo(SPI_GETWORKAREA, 0, &work_area, 0)) {
ScreenMetrics metrics;
POINT origin = { work_area.right,
work_area.bottom - metrics.Y(toast_margin_) };
POINT origin = {work_area.right,
work_area.bottom - metrics.Y(toast_margin_)};
auto hdwp =
BeginDeferWindowPos(static_cast<int>(instances_.size()));
auto hdwp = BeginDeferWindowPos(static_cast<int>(instances_.size()));
for (auto&& inst : instances_) {
if (!inst.hwnd) continue;
if (!inst.hwnd)
continue;
auto notification = Toast::Get(inst.hwnd);
hdwp = notification->Animate(hdwp, origin);
if (!hdwp) break;
if (!hdwp)
break;
keep_animating |= notification->IsAnimationActive();
}
if (hdwp) EndDeferWindowPos(hdwp);
if (hdwp)
EndDeferWindowPos(hdwp);
}
}
if (!keep_animating) {
_ASSERT(hwnd_controller_);
if (hwnd_controller_) KillTimer(hwnd_controller_, TimerID_Animate);
if (hwnd_controller_)
KillTimer(hwnd_controller_, TimerID_Animate);
is_animating_ = false;
}
@ -253,8 +262,9 @@ void DesktopNotificationController::AnimateAll() {
}
DesktopNotificationController::Notification
DesktopNotificationController::AddNotification(
std::wstring caption, std::wstring body_text, HBITMAP image) {
DesktopNotificationController::AddNotification(std::wstring caption,
std::wstring body_text,
HBITMAP image) {
NotificationLink data(this);
data->caption = move(caption);
@ -262,7 +272,7 @@ DesktopNotificationController::Notification
data->image = CopyBitmap(image);
// Enqueue new notification
Notification ret { *queue_.insert(queue_.end(), move(data)) };
Notification ret{*queue_.insert(queue_.end(), move(data))};
CheckQueue();
return ret;
}
@ -303,19 +313,17 @@ void DesktopNotificationController::CreateToast(NotificationLink&& data) {
ScreenMetrics scr;
auto toast = Toast::Get(item.hwnd);
toast_pos = toast->GetVerticalPosition() +
toast->GetHeight() +
toast_pos = toast->GetVerticalPosition() + toast->GetHeight() +
scr.Y(toast_margin_);
}
instances_.push_back({ hwnd, move(data) });
instances_.push_back({hwnd, move(data)});
if (!hwnd_controller_) {
// NOTE: We cannot use a message-only window because we need to
// receive system notifications
hwnd_controller_ = CreateWindow(class_name_, nullptr, 0,
0, 0, 0, 0,
NULL, NULL, hinstance, this);
hwnd_controller_ = CreateWindow(class_name_, nullptr, 0, 0, 0, 0, 0, NULL,
NULL, hinstance, this);
}
auto toast = Toast::Get(hwnd);
@ -325,9 +333,10 @@ void DesktopNotificationController::CreateToast(NotificationLink&& data) {
HWND DesktopNotificationController::GetToast(
const NotificationData* data) const {
auto it = find_if(instances_.cbegin(), instances_.cend(),
[data](auto&& inst) {
if (!inst.hwnd) return false;
auto it =
find_if(instances_.cbegin(), instances_.cend(), [data](auto&& inst) {
if (!inst.hwnd)
return false;
auto toast = Toast::Get(inst.hwnd);
return data == toast->GetNotification().get();
});
@ -348,8 +357,8 @@ void DesktopNotificationController::DestroyToast(ToastInstance& inst) {
}
DesktopNotificationController::Notification::Notification(
const shared_ptr<NotificationData>& data) :
data_(data) {
const shared_ptr<NotificationData>& data)
: data_(data) {
_ASSERT(data != nullptr);
}
@ -366,8 +375,9 @@ void DesktopNotificationController::Notification::Close() {
data_->controller->CloseNotification(*this);
}
void DesktopNotificationController::Notification::Set(
std::wstring caption, std::wstring body_text, HBITMAP image) {
void DesktopNotificationController::Notification::Set(std::wstring caption,
std::wstring body_text,
HBITMAP image) {
// No business calling this when not pointing to a valid instance
_ASSERT(data_);
@ -375,7 +385,8 @@ void DesktopNotificationController::Notification::Set(
if (!data_->controller)
return;
if (data_->image) DeleteBitmap(data_->image);
if (data_->image)
DeleteBitmap(data_->image);
data_->caption = move(caption);
data_->body_text = move(body_text);
@ -392,14 +403,15 @@ void DesktopNotificationController::Notification::Set(
}
DesktopNotificationController::NotificationLink::NotificationLink(
DesktopNotificationController* controller) :
shared_ptr(make_shared<NotificationData>()) {
DesktopNotificationController* controller)
: shared_ptr(make_shared<NotificationData>()) {
get()->controller = controller;
}
DesktopNotificationController::NotificationLink::~NotificationLink() {
auto p = get();
if (p) p->controller = nullptr;
if (p)
p->controller = nullptr;
}
} // namespace brightray

View file

@ -1,9 +1,9 @@
#pragma once
#include <Windows.h>
#include <deque>
#include <memory>
#include <string>
#include <vector>
#include <Windows.h>
namespace brightray {
@ -15,7 +15,8 @@ class DesktopNotificationController {
~DesktopNotificationController();
class Notification;
Notification AddNotification(std::wstring caption, std::wstring body_text,
Notification AddNotification(std::wstring caption,
std::wstring body_text,
HBITMAP image);
void CloseNotification(Notification& notification);
@ -32,9 +33,7 @@ class DesktopNotificationController {
HFONT GetBodyFont();
private:
enum TimerID {
TimerID_Animate = 1
};
enum TimerID { TimerID_Animate = 1 };
static constexpr int toast_margin_ = 20;
@ -57,15 +56,16 @@ class DesktopNotificationController {
class Toast;
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam);
static LRESULT CALLBACK WndProc(HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam);
static DesktopNotificationController* Get(HWND hwnd) {
return reinterpret_cast<DesktopNotificationController*>(
GetWindowLongPtr(hwnd, 0));
}
DesktopNotificationController(
const DesktopNotificationController&) = delete;
DesktopNotificationController(const DesktopNotificationController&) = delete;
void InitializeFonts();
void ClearAssets();

View file

@ -22,32 +22,26 @@ static COLORREF GetAccentColor() {
KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) {
COLORREF color;
DWORD type, size;
if (RegQueryValueEx(hkey, TEXT("AccentColor"), nullptr,
&type,
if (RegQueryValueEx(hkey, TEXT("AccentColor"), nullptr, &type,
reinterpret_cast<BYTE*>(&color),
&(size = sizeof(color))) == ERROR_SUCCESS &&
type == REG_DWORD) {
// convert from RGBA
color = RGB(GetRValue(color),
GetGValue(color),
GetBValue(color));
color = RGB(GetRValue(color), GetGValue(color), GetBValue(color));
success = true;
} else if (
RegQueryValueEx(hkey, TEXT("ColorizationColor"), nullptr,
&type,
reinterpret_cast<BYTE*>(&color),
} else if (RegQueryValueEx(hkey, TEXT("ColorizationColor"), nullptr,
&type, reinterpret_cast<BYTE*>(&color),
&(size = sizeof(color))) == ERROR_SUCCESS &&
type == REG_DWORD) {
// convert from BGRA
color = RGB(GetBValue(color),
GetGValue(color),
GetRValue(color));
color = RGB(GetBValue(color), GetGValue(color), GetRValue(color));
success = true;
}
RegCloseKey(hkey);
if (success) return color;
if (success)
return color;
}
}
@ -73,7 +67,7 @@ static HBITMAP StretchBitmap(HBITMAP bitmap, unsigned width, unsigned height) {
HBITMAP alpha_src_bitmap;
{
BITMAPINFOHEADER bmi = { sizeof(BITMAPINFOHEADER) };
BITMAPINFOHEADER bmi = {sizeof(BITMAPINFOHEADER)};
bmi.biWidth = bm.bmWidth;
bmi.biHeight = bm.bmHeight;
bmi.biPlanes = bm.bmPlanes;
@ -87,21 +81,17 @@ static HBITMAP StretchBitmap(HBITMAP bitmap, unsigned width, unsigned height) {
if (alpha_src_bitmap) {
if (GetDIBits(hdc_screen, bitmap, 0, 0, 0,
reinterpret_cast<BITMAPINFO*>(&bmi),
DIB_RGB_COLORS) &&
bmi.biSizeImage > 0 &&
(bmi.biSizeImage % 4) == 0) {
reinterpret_cast<BITMAPINFO*>(&bmi), DIB_RGB_COLORS) &&
bmi.biSizeImage > 0 && (bmi.biSizeImage % 4) == 0) {
auto buf = reinterpret_cast<BYTE*>(
_aligned_malloc(bmi.biSizeImage, sizeof(DWORD)));
if (buf) {
GetDIBits(hdc_screen, bitmap, 0, bm.bmHeight, buf,
reinterpret_cast<BITMAPINFO*>(&bmi),
DIB_RGB_COLORS);
reinterpret_cast<BITMAPINFO*>(&bmi), DIB_RGB_COLORS);
const DWORD *src = reinterpret_cast<DWORD*>(buf);
const DWORD *end =
reinterpret_cast<DWORD*>(buf + bmi.biSizeImage);
const DWORD* src = reinterpret_cast<DWORD*>(buf);
const DWORD* end = reinterpret_cast<DWORD*>(buf + bmi.biSizeImage);
BYTE* dest = reinterpret_cast<BYTE*>(alpha_src_bits);
@ -119,7 +109,7 @@ static HBITMAP StretchBitmap(HBITMAP bitmap, unsigned width, unsigned height) {
}
if (alpha_src_bitmap) {
BITMAPINFOHEADER bmi = { sizeof(BITMAPINFOHEADER) };
BITMAPINFOHEADER bmi = {sizeof(BITMAPINFOHEADER)};
bmi.biWidth = width;
bmi.biHeight = height;
bmi.biPlanes = 1;
@ -145,16 +135,14 @@ static HBITMAP StretchBitmap(HBITMAP bitmap, unsigned width, unsigned height) {
// resize color channels
SelectObject(hdc, color_bitmap);
SelectObject(hdc_src, bitmap);
StretchBlt(hdc, 0, 0, width, height,
hdc_src, 0, 0, bm.bmWidth, bm.bmHeight,
SRCCOPY);
StretchBlt(hdc, 0, 0, width, height, hdc_src, 0, 0, bm.bmWidth,
bm.bmHeight, SRCCOPY);
// resize alpha channel
SelectObject(hdc, alpha_bitmap);
SelectObject(hdc_src, alpha_src_bitmap);
StretchBlt(hdc, 0, 0, width, height,
hdc_src, 0, 0, bm.bmWidth, bm.bmHeight,
SRCCOPY);
StretchBlt(hdc, 0, 0, width, height, hdc_src, 0, 0, bm.bmWidth,
bm.bmHeight, SRCCOPY);
// flush before touching the bits
GdiFlush();
@ -170,17 +158,20 @@ static HBITMAP StretchBitmap(HBITMAP bitmap, unsigned width, unsigned height) {
}
// create the resulting bitmap
result_bitmap = CreateDIBitmap(hdc_screen, &bmi, CBM_INIT,
color_bits,
reinterpret_cast<BITMAPINFO*>(&bmi),
DIB_RGB_COLORS);
result_bitmap =
CreateDIBitmap(hdc_screen, &bmi, CBM_INIT, color_bits,
reinterpret_cast<BITMAPINFO*>(&bmi), DIB_RGB_COLORS);
}
if (hdc_src) DeleteDC(hdc_src);
if (hdc) DeleteDC(hdc);
if (hdc_src)
DeleteDC(hdc_src);
if (hdc)
DeleteDC(hdc);
if (alpha_bitmap) DeleteObject(alpha_bitmap);
if (color_bitmap) DeleteObject(color_bitmap);
if (alpha_bitmap)
DeleteObject(alpha_bitmap);
if (color_bitmap)
DeleteObject(color_bitmap);
DeleteObject(alpha_src_bitmap);
}
@ -190,9 +181,9 @@ static HBITMAP StretchBitmap(HBITMAP bitmap, unsigned width, unsigned height) {
return result_bitmap;
}
DesktopNotificationController::Toast::Toast(
HWND hwnd, shared_ptr<NotificationData>* data) :
hwnd_(hwnd), data_(*data) {
DesktopNotificationController::Toast::Toast(HWND hwnd,
shared_ptr<NotificationData>* data)
: hwnd_(hwnd), data_(*data) {
HDC hdc_screen = GetDC(NULL);
hdc_ = CreateCompatibleDC(hdc_screen);
ReleaseDC(NULL, hdc_screen);
@ -200,12 +191,14 @@ DesktopNotificationController::Toast::Toast(
DesktopNotificationController::Toast::~Toast() {
DeleteDC(hdc_);
if (bitmap_) DeleteBitmap(bitmap_);
if (scaled_image_) DeleteBitmap(scaled_image_);
if (bitmap_)
DeleteBitmap(bitmap_);
if (scaled_image_)
DeleteBitmap(scaled_image_);
}
void DesktopNotificationController::Toast::Register(HINSTANCE hinstance) {
WNDCLASSEX wc = { sizeof(wc) };
WNDCLASSEX wc = {sizeof(wc)};
wc.lpfnWndProc = &Toast::WndProc;
wc.lpszClassName = class_name_;
wc.cbWndExtra = sizeof(Toast*);
@ -215,18 +208,18 @@ void DesktopNotificationController::Toast::Register(HINSTANCE hinstance) {
RegisterClassEx(&wc);
}
LRESULT DesktopNotificationController::Toast::WndProc(
HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) {
LRESULT DesktopNotificationController::Toast::WndProc(HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam) {
switch (message) {
case WM_CREATE:
{
case WM_CREATE: {
auto& cs = reinterpret_cast<const CREATESTRUCT*&>(lparam);
auto data =
static_cast<shared_ptr<NotificationData>*>(cs->lpCreateParams);
auto inst = new Toast(hwnd, data);
SetWindowLongPtr(hwnd, 0, (LONG_PTR)inst);
}
break;
} break;
case WM_NCDESTROY:
delete Get(hwnd);
@ -242,8 +235,7 @@ LRESULT DesktopNotificationController::Toast::WndProc(
}
return 0;
case WM_LBUTTONDOWN:
{
case WM_LBUTTONDOWN: {
auto inst = Get(hwnd);
inst->Dismiss();
@ -256,17 +248,16 @@ LRESULT DesktopNotificationController::Toast::WndProc(
}
return 0;
case WM_MOUSEMOVE:
{
case WM_MOUSEMOVE: {
auto inst = Get(hwnd);
if (!inst->is_highlighted_) {
inst->is_highlighted_ = true;
TRACKMOUSEEVENT tme = { sizeof(tme), TME_LEAVE, hwnd };
TRACKMOUSEEVENT tme = {sizeof(tme), TME_LEAVE, hwnd};
TrackMouseEvent(&tme);
}
POINT cursor = { GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam) };
POINT cursor = {GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)};
inst->is_close_hot_ =
(PtInRect(&inst->close_button_rect_, cursor) != FALSE);
@ -277,8 +268,7 @@ LRESULT DesktopNotificationController::Toast::WndProc(
}
return 0;
case WM_MOUSELEAVE:
{
case WM_MOUSELEAVE: {
auto inst = Get(hwnd);
inst->is_highlighted_ = false;
inst->is_close_hot_ = false;
@ -292,25 +282,24 @@ LRESULT DesktopNotificationController::Toast::WndProc(
}
return 0;
case WM_WINDOWPOSCHANGED:
{
case WM_WINDOWPOSCHANGED: {
auto& wp = reinterpret_cast<WINDOWPOS*&>(lparam);
if (wp->flags & SWP_HIDEWINDOW) {
if (!IsWindowVisible(hwnd))
Get(hwnd)->is_highlighted_ = false;
}
}
break;
} break;
}
return DefWindowProc(hwnd, message, wparam, lparam);
}
HWND DesktopNotificationController::Toast::Create(
HINSTANCE hinstance, shared_ptr<NotificationData>& data) {
HINSTANCE hinstance,
shared_ptr<NotificationData>& data) {
return CreateWindowEx(WS_EX_LAYERED | WS_EX_NOACTIVATE | WS_EX_TOPMOST,
class_name_, nullptr, WS_POPUP, 0, 0, 0, 0,
NULL, NULL, hinstance, &data);
class_name_, nullptr, WS_POPUP, 0, 0, 0, 0, NULL, NULL,
hinstance, &data);
}
void DesktopNotificationController::Toast::Draw() {
@ -328,12 +317,13 @@ void DesktopNotificationController::Toast::Draw() {
min(0xff, (GetBValue(accent) * 2 / 3) + h));
}
const float back_luma =
(GetRValue(back_color) * 0.299f / 255) +
const float back_luma = (GetRValue(back_color) * 0.299f / 255) +
(GetGValue(back_color) * 0.587f / 255) +
(GetBValue(back_color) * 0.114f / 255);
const struct { float r, g, b; } back_f = {
const struct {
float r, g, b;
} back_f = {
GetRValue(back_color) / 255.0f,
GetGValue(back_color) / 255.0f,
GetBValue(back_color) / 255.0f,
@ -346,8 +336,8 @@ void DesktopNotificationController::Toast::Draw() {
// transparency to avoid sharp contrast
constexpr float alpha = 0.9f;
constexpr float intensity_light[] = { (1.0f * alpha), (0.8f * alpha) };
constexpr float intensity_dark[] = { (0.1f * alpha), (0.3f * alpha) };
constexpr float intensity_light[] = {(1.0f * alpha), (0.8f * alpha)};
constexpr float intensity_dark[] = {(0.1f * alpha), (0.3f * alpha)};
// select foreground intensity values (light or dark)
auto& i = (back_luma < 0.6f) ? intensity_light : intensity_dark;
@ -369,7 +359,7 @@ void DesktopNotificationController::Toast::Draw() {
{
auto brush = CreateSolidBrush(back_color);
RECT rc = { 0, 0, toast_size_.cx, toast_size_.cy };
RECT rc = {0, 0, toast_size_.cx, toast_size_.cy};
FillRect(hdc_, &rc, brush);
DeleteBrush(brush);
@ -414,53 +404,42 @@ void DesktopNotificationController::Toast::Draw() {
if (scaled_image_) {
HDC hdc_image = CreateCompatibleDC(NULL);
SelectBitmap(hdc_image, scaled_image_);
BLENDFUNCTION blend = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA };
AlphaBlend(hdc_, margin_.cx, margin_.cy,
image_info.bmWidth, image_info.bmHeight,
hdc_image, 0, 0,
image_info.bmWidth, image_info.bmHeight,
blend);
BLENDFUNCTION blend = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
AlphaBlend(hdc_, margin_.cx, margin_.cy, image_info.bmWidth,
image_info.bmHeight, hdc_image, 0, 0, image_info.bmWidth,
image_info.bmHeight, blend);
DeleteDC(hdc_image);
}
// caption
{
RECT rc = {
text_offset_x,
margin_.cy,
close_button_rect_.left,
toast_size_.cy
};
RECT rc = {text_offset_x, margin_.cy, close_button_rect_.left,
toast_size_.cy};
SelectFont(hdc_, caption_font);
SetTextColor(hdc_, fore_color);
DrawText(hdc_, data_->caption.data(), (UINT)data_->caption.length(),
&rc, DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX);
DrawText(hdc_, data_->caption.data(), (UINT)data_->caption.length(), &rc,
DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX);
}
// body text
if (!data_->body_text.empty()) {
RECT rc = {
text_offset_x,
2 * margin_.cy + tm_cap.tmAscent,
toast_size_.cx - margin_.cx,
toast_size_.cy - margin_.cy
};
RECT rc = {text_offset_x, 2 * margin_.cy + tm_cap.tmAscent,
toast_size_.cx - margin_.cx, toast_size_.cy - margin_.cy};
SelectFont(hdc_, body_font);
SetTextColor(hdc_, dimmed_color);
DrawText(hdc_, data_->body_text.data(), (UINT)data_->body_text.length(),
&rc,
DT_LEFT | DT_WORDBREAK | DT_NOPREFIX |
DT_END_ELLIPSIS | DT_EDITCONTROL);
DT_LEFT | DT_WORDBREAK | DT_NOPREFIX | DT_END_ELLIPSIS |
DT_EDITCONTROL);
}
// close button
{
SelectFont(hdc_, caption_font);
SetTextColor(hdc_, is_close_hot_ ? fore_color : dimmed_color);
ExtTextOut(hdc_, close_pos.x, close_pos.y, 0, nullptr,
&close, 1, nullptr);
ExtTextOut(hdc_, close_pos.x, close_pos.y, 0, nullptr, &close, 1, nullptr);
}
is_content_updated_ = true;
@ -482,22 +461,22 @@ void DesktopNotificationController::Toast::UpdateBufferSize() {
HFONT font = data_->controller->GetCaptionFont();
if (font) {
SelectFont(hdc_, font);
if (!GetTextMetrics(hdc_, &tm_cap)) return;
if (!GetTextMetrics(hdc_, &tm_cap))
return;
}
TEXTMETRIC tm_body = {};
font = data_->controller->GetBodyFont();
if (font) {
SelectFont(hdc_, font);
if (!GetTextMetrics(hdc_, &tm_body)) return;
if (!GetTextMetrics(hdc_, &tm_body))
return;
}
this->margin_ = { tm_cap.tmAveCharWidth * 2, tm_cap.tmAscent / 2 };
this->margin_ = {tm_cap.tmAveCharWidth * 2, tm_cap.tmAscent / 2};
new_size.cx =
margin_.cx + (32 * tm_cap.tmAveCharWidth) + margin_.cx;
new_size.cy =
margin_.cy + (tm_cap.tmHeight) + margin_.cy;
new_size.cx = margin_.cx + (32 * tm_cap.tmAveCharWidth) + margin_.cx;
new_size.cy = margin_.cy + (tm_cap.tmHeight) + margin_.cy;
if (!data_->body_text.empty())
new_size.cy += margin_.cy + (3 * tm_body.tmHeight);
@ -523,7 +502,7 @@ void DesktopNotificationController::Toast::UpdateBufferSize() {
}
ScreenMetrics scr;
SIZE image_draw_size = { scr.X(width), scr.Y(height) };
SIZE image_draw_size = {scr.X(width), scr.Y(height)};
new_size.cx += image_draw_size.cx + margin_.cx;
@ -541,23 +520,22 @@ void DesktopNotificationController::Toast::UpdateBufferSize() {
if (new_size.cx != this->toast_size_.cx ||
new_size.cy != this->toast_size_.cy) {
HDC hdc_screen = GetDC(NULL);
auto new_bitmap = CreateCompatibleBitmap(hdc_screen,
new_size.cx, new_size.cy);
auto new_bitmap =
CreateCompatibleBitmap(hdc_screen, new_size.cx, new_size.cy);
ReleaseDC(NULL, hdc_screen);
if (new_bitmap) {
if (SelectBitmap(hdc_, new_bitmap)) {
RECT dirty1 = {}, dirty2 = {};
if (toast_size_.cx < new_size.cx) {
dirty1 = { toast_size_.cx, 0,
new_size.cx, toast_size_.cy };
dirty1 = {toast_size_.cx, 0, new_size.cx, toast_size_.cy};
}
if (toast_size_.cy < new_size.cy) {
dirty2 = { 0, toast_size_.cy,
new_size.cx, new_size.cy };
dirty2 = {0, toast_size_.cy, new_size.cx, new_size.cy};
}
if (this->bitmap_) DeleteBitmap(this->bitmap_);
if (this->bitmap_)
DeleteBitmap(this->bitmap_);
this->bitmap_ = new_bitmap;
this->toast_size_ = new_size;
@ -567,7 +545,7 @@ void DesktopNotificationController::Toast::UpdateBufferSize() {
// window resizing. Make sure any existing data is not
// overwritten by marking the dirty region.
{
POINT origin = { 0, 0 };
POINT origin = {0, 0};
UPDATELAYEREDWINDOWINFO ulw;
ulw.cbSize = sizeof(ulw);
@ -597,10 +575,10 @@ void DesktopNotificationController::Toast::UpdateBufferSize() {
void DesktopNotificationController::Toast::UpdateScaledImage(const SIZE& size) {
BITMAP bm;
if (!GetObject(scaled_image_, sizeof(bm), &bm) ||
bm.bmWidth != size.cx ||
if (!GetObject(scaled_image_, sizeof(bm), &bm) || bm.bmWidth != size.cx ||
bm.bmHeight != size.cy) {
if (scaled_image_) DeleteBitmap(scaled_image_);
if (scaled_image_)
DeleteBitmap(scaled_image_);
scaled_image_ = StretchBitmap(data_->image, size.cx, size.cy);
}
}
@ -611,10 +589,10 @@ void DesktopNotificationController::Toast::UpdateContents() {
if (IsWindowVisible(hwnd_)) {
RECT rc;
GetWindowRect(hwnd_, &rc);
POINT origin = { 0, 0 };
SIZE size = { rc.right - rc.left, rc.bottom - rc.top };
UpdateLayeredWindow(hwnd_, NULL, nullptr, &size,
hdc_, &origin, 0, nullptr, 0);
POINT origin = {0, 0};
SIZE size = {rc.right - rc.left, rc.bottom - rc.top};
UpdateLayeredWindow(hwnd_, NULL, nullptr, &size, hdc_, &origin, 0, nullptr,
0);
}
}
@ -668,8 +646,8 @@ void DesktopNotificationController::Toast::SetVerticalPosition(int y) {
return;
// Make sure the new animation's origin is at the current position
vertical_pos_ += static_cast<int>(
(vertical_pos_target_ - vertical_pos_) * stack_collapse_pos_);
vertical_pos_ += static_cast<int>((vertical_pos_target_ - vertical_pos_) *
stack_collapse_pos_);
// Set new target position and start the animation
vertical_pos_target_ = y;
@ -677,14 +655,14 @@ void DesktopNotificationController::Toast::SetVerticalPosition(int y) {
data_->controller->StartAnimation();
}
HDWP DesktopNotificationController::Toast::Animate(
HDWP hdwp, const POINT& origin) {
HDWP DesktopNotificationController::Toast::Animate(HDWP hdwp,
const POINT& origin) {
UpdateBufferSize();
if (IsRedrawNeeded())
Draw();
POINT src_origin = { 0, 0 };
POINT src_origin = {0, 0};
UPDATELAYEREDWINDOWINFO ulw;
ulw.cbSize = sizeof(ulw);
@ -698,11 +676,11 @@ HDWP DesktopNotificationController::Toast::Animate(
ulw.dwFlags = 0;
ulw.prcDirty = nullptr;
POINT pt = { 0, 0 };
SIZE size = { 0, 0 };
POINT pt = {0, 0};
SIZE size = {0, 0};
BLENDFUNCTION blend;
UINT dwpFlags = SWP_NOACTIVATE | SWP_SHOWWINDOW |
SWP_NOREDRAW | SWP_NOCOPYBITS;
UINT dwpFlags =
SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOREDRAW | SWP_NOCOPYBITS;
auto ease_in_pos = AnimateEaseIn();
auto ease_out_pos = AnimateEaseOut();
@ -756,8 +734,8 @@ HDWP DesktopNotificationController::Toast::Animate(
// at the beginning of ease-in).
auto ulw_result = UpdateLayeredWindowIndirect(hwnd_, &ulw);
hdwp = DeferWindowPos(hdwp, hwnd_, HWND_TOPMOST,
pt.x, pt.y, size.cx, size.cy, dwpFlags);
hdwp = DeferWindowPos(hdwp, hwnd_, HWND_TOPMOST, pt.x, pt.y, size.cx, size.cy,
dwpFlags);
return hdwp;
}

View file

@ -12,8 +12,10 @@ class DesktopNotificationController::Toast {
return reinterpret_cast<Toast*>(GetWindowLongPtr(hwnd, 0));
}
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam);
static LRESULT CALLBACK WndProc(HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam);
const std::shared_ptr<NotificationData>& GetNotification() const {
return data_;
@ -25,12 +27,8 @@ class DesktopNotificationController::Toast {
void PopUp(int y);
void SetVerticalPosition(int y);
int GetVerticalPosition() const {
return vertical_pos_target_;
}
int GetHeight() const {
return toast_size_.cy;
}
int GetVerticalPosition() const { return vertical_pos_target_; }
int GetHeight() const { return toast_size_.cy; }
HDWP Animate(HDWP hdwp, const POINT& origin);
bool IsAnimationActive() const {
return ease_in_active_ || ease_out_active_ || IsStackCollapseActive();
@ -41,9 +39,7 @@ class DesktopNotificationController::Toast {
}
private:
enum TimerID {
TimerID_AutoDismiss = 1
};
enum TimerID { TimerID_AutoDismiss = 1 };
Toast(HWND hwnd, std::shared_ptr<NotificationData>* data);
~Toast();
@ -68,8 +64,7 @@ class DesktopNotificationController::Toast {
float AnimateStackCollapse();
private:
static constexpr const TCHAR class_name_[] =
TEXT("DesktopNotificationToast");
static constexpr const TCHAR class_name_[] = TEXT("DesktopNotificationToast");
const HWND hwnd_;
HDC hdc_;

View file

@ -12,13 +12,14 @@ namespace brightray {
void Win32Notification::Show(const NotificationOptions& options) {
auto presenter = static_cast<NotificationPresenterWin7*>(this->presenter());
if (!presenter) return;
if (!presenter)
return;
HBITMAP image = NULL;
if (!options.icon.drawsNothing()) {
if (options.icon.colorType() == kBGRA_8888_SkColorType) {
BITMAPINFOHEADER bmi = { sizeof(BITMAPINFOHEADER) };
BITMAPINFOHEADER bmi = {sizeof(BITMAPINFOHEADER)};
bmi.biWidth = options.icon.width();
bmi.biHeight = -options.icon.height();
bmi.biPlanes = 1;
@ -26,10 +27,9 @@ void Win32Notification::Show(const NotificationOptions& options) {
bmi.biCompression = BI_RGB;
HDC hdcScreen = GetDC(NULL);
image = CreateDIBitmap(hdcScreen, &bmi, CBM_INIT,
options.icon.getPixels(),
reinterpret_cast<BITMAPINFO*>(&bmi),
DIB_RGB_COLORS);
image =
CreateDIBitmap(hdcScreen, &bmi, CBM_INIT, options.icon.getPixels(),
reinterpret_cast<BITMAPINFO*>(&bmi), DIB_RGB_COLORS);
ReleaseDC(NULL, hdcScreen);
}
}
@ -43,14 +43,14 @@ void Win32Notification::Show(const NotificationOptions& options) {
this->notification_ref_ = std::move(existing->notification_ref_);
this->notification_ref_.Set(options.title, options.msg, image);
} else {
this->notification_ref_ = presenter->AddNotification(options.title,
options.msg,
image);
this->notification_ref_ =
presenter->AddNotification(options.title, options.msg, image);
}
this->tag_ = options.tag;
if (image) DeleteObject(image);
if (image)
DeleteObject(image);
}
void Win32Notification::Dismiss() {

View file

@ -7,9 +7,8 @@ namespace brightray {
class Win32Notification : public brightray::Notification {
public:
Win32Notification(NotificationDelegate* delegate,
NotificationPresenterWin7* presenter) :
Notification(delegate, presenter) {
}
NotificationPresenterWin7* presenter)
: Notification(delegate, presenter) {}
void Show(const NotificationOptions& options) override;
void Dismiss() override;
@ -17,9 +16,7 @@ class Win32Notification : public brightray::Notification {
return notification_ref_;
}
const std::string& GetTag() const {
return tag_;
}
const std::string& GetTag() const { return tag_; }
private:
DesktopNotificationController::Notification notification_ref_;

View file

@ -81,9 +81,8 @@ WindowsToastNotification::~WindowsToastNotification() {
void WindowsToastNotification::Show(const NotificationOptions& options) {
auto presenter_win = static_cast<NotificationPresenterWin*>(presenter());
std::wstring icon_path = presenter_win->SaveIconToFilesystem(
options.icon,
options.icon_url);
std::wstring icon_path =
presenter_win->SaveIconToFilesystem(options.icon, options.icon_url);
ComPtr<IXmlDocument> toast_xml;
if (FAILED(GetToastXml(toast_manager_.Get(), options.title, options.msg,
@ -123,14 +122,16 @@ void WindowsToastNotification::Show(const NotificationOptions& options) {
return;
}
if (IsDebuggingNotifications()) LOG(INFO) << "Notification created";
if (IsDebuggingNotifications())
LOG(INFO) << "Notification created";
if (delegate())
delegate()->NotificationDisplayed();
}
void WindowsToastNotification::Dismiss() {
if (IsDebuggingNotifications()) LOG(INFO) << "Hiding notification";
if (IsDebuggingNotifications())
LOG(INFO) << "Hiding notification";
toast_notifier_->Hide(toast_notification_.Get());
}
@ -407,7 +408,8 @@ IFACEMETHODIMP ToastEventHandler::Invoke(
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(&Notification::NotificationClicked, notification_));
if (IsDebuggingNotifications()) LOG(INFO) << "Notification clicked";
if (IsDebuggingNotifications())
LOG(INFO) << "Notification clicked";
return S_OK;
}
@ -418,7 +420,8 @@ IFACEMETHODIMP ToastEventHandler::Invoke(
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(&Notification::NotificationDismissed, notification_));
if (IsDebuggingNotifications()) LOG(INFO) << "Notification dismissed";
if (IsDebuggingNotifications())
LOG(INFO) << "Notification dismissed";
return S_OK;
}
@ -429,7 +432,8 @@ IFACEMETHODIMP ToastEventHandler::Invoke(
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(&Notification::NotificationFailed, notification_));
if (IsDebuggingNotifications()) LOG(INFO) << "Notification failed";
if (IsDebuggingNotifications())
LOG(INFO) << "Notification failed";
return S_OK;
}

View file

@ -17,7 +17,6 @@ namespace brightray {
namespace {
base::string16 g_app_user_model_id;
}
const wchar_t kAppUserModelIDFormat[] = L"electron.app.$1";

View file

@ -16,19 +16,17 @@ namespace brightray {
std::string GetProductInternal() {
auto name = GetApplicationName();
base::RemoveChars(name, base::kWhitespaceASCII, &name);
return base::StringPrintf("%s/%s",
name.c_str(), GetApplicationVersion().c_str());
return base::StringPrintf("%s/%s", name.c_str(),
GetApplicationVersion().c_str());
}
std::string GetBrightrayUserAgent() {
return content::BuildUserAgentFromProduct(GetProductInternal());
}
ContentClient::ContentClient() {
}
ContentClient::ContentClient() {}
ContentClient::~ContentClient() {
}
ContentClient::~ContentClient() {}
std::string ContentClient::GetProduct() const {
return GetProductInternal();
@ -43,7 +41,8 @@ base::string16 ContentClient::GetLocalizedString(int message_id) const {
}
base::StringPiece ContentClient::GetDataResource(
int resource_id, ui::ScaleFactor scale_factor) const {
int resource_id,
ui::ScaleFactor scale_factor) const {
return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
resource_id, scale_factor);
}

View file

@ -82,11 +82,9 @@ void LoadResourceBundle(const std::string& locale) {
#endif
}
MainDelegate::MainDelegate() {
}
MainDelegate::MainDelegate() {}
MainDelegate::~MainDelegate() {
}
MainDelegate::~MainDelegate() {}
std::unique_ptr<ContentClient> MainDelegate::CreateContentClient() {
return std::unique_ptr<ContentClient>(new ContentClient);