Put common constants in atom_constants
This commit is contained in:
parent
a2f1390b0d
commit
0f17a0163d
8 changed files with 35 additions and 9 deletions
|
@ -11,8 +11,6 @@
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
const std::string kCorsHeader("Access-Control-Allow-Origin: *");
|
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
#ifndef ATOM_BROWSER_NET_JS_ASKER_H_
|
#ifndef ATOM_BROWSER_NET_JS_ASKER_H_
|
||||||
#define ATOM_BROWSER_NET_JS_ASKER_H_
|
#define ATOM_BROWSER_NET_JS_ASKER_H_
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "base/callback.h"
|
#include "base/callback.h"
|
||||||
#include "base/memory/ref_counted.h"
|
#include "base/memory/ref_counted.h"
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
|
@ -19,7 +17,6 @@
|
||||||
#include "v8/include/v8.h"
|
#include "v8/include/v8.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
extern const std::string kCorsHeader;
|
|
||||||
|
|
||||||
using JavaScriptHandler =
|
using JavaScriptHandler =
|
||||||
base::Callback<void(const net::URLRequest*, v8::Local<v8::Value>)>;
|
base::Callback<void(const net::URLRequest*, v8::Local<v8::Value>)>;
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "atom/common/atom_constants.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
URLRequestAsyncAsarJob::URLRequestAsyncAsarJob(
|
URLRequestAsyncAsarJob::URLRequestAsyncAsarJob(
|
||||||
|
@ -36,12 +38,11 @@ void URLRequestAsyncAsarJob::StartAsync(scoped_ptr<base::Value> options) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void URLRequestAsyncAsarJob::GetResponseInfo(net::HttpResponseInfo* info) {
|
void URLRequestAsyncAsarJob::GetResponseInfo(net::HttpResponseInfo* info) {
|
||||||
std::string status("HTTP/1.1 200 OK");
|
std::string status("HTTP/1.1 200 OK");
|
||||||
net::HttpResponseHeaders* headers = new net::HttpResponseHeaders(status);
|
net::HttpResponseHeaders* headers = new net::HttpResponseHeaders(status);
|
||||||
|
|
||||||
headers->AddHeader(kCorsHeader);
|
headers->AddHeader(kCORSHeader);
|
||||||
info->headers = headers;
|
info->headers = headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "atom/common/atom_constants.h"
|
||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "net/base/net_errors.h"
|
#include "net/base/net_errors.h"
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ void URLRequestBufferJob::GetResponseInfo(net::HttpResponseInfo* info) {
|
||||||
status.append("\0\0", 2);
|
status.append("\0\0", 2);
|
||||||
net::HttpResponseHeaders* headers = new net::HttpResponseHeaders(status);
|
net::HttpResponseHeaders* headers = new net::HttpResponseHeaders(status);
|
||||||
|
|
||||||
headers->AddHeader(kCorsHeader);
|
headers->AddHeader(kCORSHeader);
|
||||||
|
|
||||||
if (!mime_type_.empty()) {
|
if (!mime_type_.empty()) {
|
||||||
std::string content_type_header(net::HttpRequestHeaders::kContentType);
|
std::string content_type_header(net::HttpRequestHeaders::kContentType);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "atom/common/atom_constants.h"
|
||||||
#include "net/base/net_errors.h"
|
#include "net/base/net_errors.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
@ -32,7 +33,7 @@ void URLRequestStringJob::GetResponseInfo(net::HttpResponseInfo* info) {
|
||||||
std::string status("HTTP/1.1 200 OK");
|
std::string status("HTTP/1.1 200 OK");
|
||||||
net::HttpResponseHeaders* headers = new net::HttpResponseHeaders(status);
|
net::HttpResponseHeaders* headers = new net::HttpResponseHeaders(status);
|
||||||
|
|
||||||
headers->AddHeader(kCorsHeader);
|
headers->AddHeader(kCORSHeader);
|
||||||
|
|
||||||
if (!mime_type_.empty()) {
|
if (!mime_type_.empty()) {
|
||||||
std::string content_type_header(net::HttpRequestHeaders::kContentType);
|
std::string content_type_header(net::HttpRequestHeaders::kContentType);
|
||||||
|
|
11
atom/common/atom_constants.cc
Normal file
11
atom/common/atom_constants.cc
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "atom/common/atom_constants.h"
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
const char* kCORSHeader = "Access-Control-Allow-Origin: *";
|
||||||
|
|
||||||
|
} // namespace atom
|
15
atom/common/atom_constants.h
Normal file
15
atom/common/atom_constants.h
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ATOM_COMMON_ATOM_CONSTANTS_H_
|
||||||
|
#define ATOM_COMMON_ATOM_CONSTANTS_H_
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
// Header to ignore CORS.
|
||||||
|
extern const char* kCORSHeader;
|
||||||
|
|
||||||
|
} // namespace atom
|
||||||
|
|
||||||
|
#endif // ATOM_COMMON_ATOM_CONSTANTS_H_
|
|
@ -286,6 +286,8 @@
|
||||||
'atom/common/asar/scoped_temporary_file.h',
|
'atom/common/asar/scoped_temporary_file.h',
|
||||||
'atom/common/atom_command_line.cc',
|
'atom/common/atom_command_line.cc',
|
||||||
'atom/common/atom_command_line.h',
|
'atom/common/atom_command_line.h',
|
||||||
|
'atom/common/atom_constants.cc',
|
||||||
|
'atom/common/atom_constants.h',
|
||||||
'atom/common/common_message_generator.cc',
|
'atom/common/common_message_generator.cc',
|
||||||
'atom/common/common_message_generator.h',
|
'atom/common/common_message_generator.h',
|
||||||
'atom/common/crash_reporter/crash_reporter.cc',
|
'atom/common/crash_reporter/crash_reporter.cc',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue