build: define compile time features with buildflag header (#14840)

* build: define compile time features with buildflag header

* refactor: switch to BUILDFLAG(ENABLE_DESKTOP_CAPTURER)

* refactor: switch to BUILDFLAG(ENABLE_RUN_AS_NODE)

* refactor: switch to BUILDFLAG(ENABLE_OSR)

* refactor: switch to BUILDFLAG(ENABLE_VIEW_API)

* refactor: switch to BUILDFLAG(ENABLE_PEPPER_FLASH)

* refactor: switch to BUILDFLAG(OVERRIDE_LOCATION_PROVIDER)

* refactor: switch to BUILDFLAG(ENABLE_PDF_VIEWER)
This commit is contained in:
Robo 2018-10-02 01:30:53 +05:30 committed by John Kleinschmidt
parent 4af922c9a2
commit a24ad6bc14
31 changed files with 172 additions and 209 deletions

View file

@ -6,14 +6,16 @@
#include <string>
#if defined(ENABLE_PDF_VIEWER)
#include "electron/buildflags/buildflags.h"
#if BUILDFLAG(ENABLE_PDF_VIEWER)
#include "atom/browser/ui/webui/pdf_viewer_ui.h"
#include "atom/common/atom_constants.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "content/public/browser/web_contents.h"
#include "net/base/escape.h"
#endif // defined(ENABLE_PDF_VIEWER)
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
namespace atom {
@ -29,11 +31,11 @@ AtomWebUIControllerFactory::~AtomWebUIControllerFactory() {}
content::WebUI::TypeID AtomWebUIControllerFactory::GetWebUIType(
content::BrowserContext* browser_context,
const GURL& url) const {
#if defined(ENABLE_PDF_VIEWER)
#if BUILDFLAG(ENABLE_PDF_VIEWER)
if (url.host() == kPdfViewerUIHost) {
return const_cast<AtomWebUIControllerFactory*>(this);
}
#endif // defined(ENABLE_PDF_VIEWER)
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
return content::WebUI::kNoWebUI;
}
@ -53,7 +55,7 @@ bool AtomWebUIControllerFactory::UseWebUIBindingsForURL(
content::WebUIController*
AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
const GURL& url) const {
#if defined(ENABLE_PDF_VIEWER)
#if BUILDFLAG(ENABLE_PDF_VIEWER)
if (url.host() == kPdfViewerUIHost) {
base::StringPairs toplevel_params;
base::SplitStringIntoKeyValuePairs(url.query(), '=', '&', &toplevel_params);
@ -75,7 +77,7 @@ AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
auto browser_context = web_ui->GetWebContents()->GetBrowserContext();
return new PdfViewerUI(browser_context, web_ui, src);
}
#endif // defined(ENABLE_PDF_VIEWER)
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
return nullptr;
}