This repository has been archived by the owner on Jan 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
Add cryptotokenPrivate and device support (hid and usb) for U2F #268
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b39c033
add cryptotokenPrivate, windows.get for u2f
evq 9cd49b4
Allow loading cryptotoken extension from pak via brave extension API
evq efa647b
address review comments
evq 6180b4a
Merge remote-tracking branch 'origin/master' into evq/u2f
evq 1c56f2f
add data_dep for brave_resources
evq 50cd559
deps not data_deps
evq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "atom/browser/extensions/atom_component_extensions.h" | ||
|
||
#include <map> | ||
|
||
#include "base/files/file_path.h" | ||
#include "base/path_service.h" | ||
#include "brave/grit/brave_resources.h" | ||
#include "chrome/common/chrome_paths.h" | ||
|
||
static const std::map<base::FilePath, int> componentExtensionManifests = { | ||
{base::FilePath("cryptotoken"), IDR_CRYPTOTOKEN_MANIFEST}, | ||
}; | ||
|
||
bool IsComponentExtension(const base::FilePath& extension_path, int* resource_id) { | ||
base::FilePath directory_path = extension_path; | ||
base::FilePath resources_dir; | ||
base::FilePath relative_path; | ||
|
||
if (!PathService::Get(chrome::DIR_RESOURCES, &resources_dir) || | ||
!resources_dir.AppendRelativePath(directory_path, &relative_path)) { | ||
return false; | ||
} | ||
relative_path = relative_path.NormalizePathSeparators(); | ||
|
||
std::map<base::FilePath, int>::const_iterator entry = | ||
componentExtensionManifests.find(relative_path); | ||
|
||
if (entry != componentExtensionManifests.end()) | ||
*resource_id = entry->second; | ||
|
||
return entry != componentExtensionManifests.end(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** @file atom_component_extensions.h | ||
* @brief FIXME | ||
* | ||
* @author Evey Quirk | ||
*/ | ||
#ifndef _ATOM_COMPONENT_EXTENSIONS_H | ||
#define _ATOM_COMPONENT_EXTENSIONS_H | ||
|
||
#include "base/files/file_path.h" | ||
|
||
bool IsComponentExtension(const base::FilePath& extension_path, int* resource_id); | ||
|
||
#endif /* _ATOM_COMPONENT_EXTENSIONS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,16 +9,19 @@ | |
#include <string> | ||
#include <vector> | ||
|
||
#include "atom/browser/extensions/atom_component_extensions.h" | ||
#include "atom/browser/extensions/atom_extension_system.h" | ||
#include "atom/browser/extensions/tab_helper.h" | ||
#include "atom/common/api/event_emitter_caller.h" | ||
#include "brave/common/converters/callback_converter.h" | ||
#include "brave/common/converters/gurl_converter.h" | ||
#include "brave/common/converters/file_path_converter.h" | ||
#include "brave/common/converters/value_converter.h" | ||
#include "atom/common/node_includes.h" | ||
#include "base/files/file_path.h" | ||
#include "base/json/json_string_value_serializer.h" | ||
#include "base/strings/string_util.h" | ||
#include "brave/common/converters/callback_converter.h" | ||
#include "brave/common/converters/file_path_converter.h" | ||
#include "brave/common/converters/gurl_converter.h" | ||
#include "brave/common/converters/value_converter.h" | ||
#include "chrome/common/chrome_paths.h" | ||
#include "components/prefs/pref_service.h" | ||
#include "components/user_prefs/user_prefs.h" | ||
#include "content/public/browser/browser_thread.h" | ||
|
@@ -28,6 +31,7 @@ | |
#include "content/public/browser/web_contents.h" | ||
#include "content/public/child/v8_value_converter.h" | ||
#include "content/public/common/url_constants.h" | ||
#include "extensions/browser/component_extension_resource_manager.h" | ||
#include "extensions/browser/extension_host.h" | ||
#include "extensions/browser/extension_registry.h" | ||
#include "extensions/browser/extension_system.h" | ||
|
@@ -37,9 +41,14 @@ | |
#include "extensions/common/extension.h" | ||
#include "extensions/common/disable_reason.h" | ||
#include "extensions/common/file_util.h" | ||
#include "extensions/common/manifest_constants.h" | ||
#include "extensions/common/manifest_handlers/background_info.h" | ||
#include "extensions/common/one_shot_event.h" | ||
#include "extensions/strings/grit/extensions_strings.h" | ||
#include "gin/dictionary.h" | ||
#include "ui/base/l10n/l10n_util.h" | ||
#include "ui/base/resource/resource_bundle.h" | ||
|
||
|
||
using base::Callback; | ||
using content::BrowserURLHandler; | ||
|
@@ -98,10 +107,17 @@ scoped_refptr<extensions::Extension> LoadExtension(const base::FilePath& path, | |
return NULL; | ||
|
||
std::vector<extensions::InstallWarning> warnings; | ||
if (!extensions::file_util::ValidateExtension(extension.get(), | ||
error, | ||
&warnings)) | ||
return NULL; | ||
|
||
int resource_id; | ||
if (!IsComponentExtension(path, &resource_id)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we use IsComponentExtensionResource here instead? |
||
// Component extensions contained inside the resources pak fail manifest validation | ||
// so we skip validation. | ||
if (!extensions::file_util::ValidateExtension(extension.get(), | ||
error, | ||
&warnings)) { | ||
return NULL; | ||
} | ||
} | ||
extension->AddInstallWarnings(warnings); | ||
|
||
return extension; | ||
|
@@ -155,6 +171,41 @@ Extension::~Extension() { | |
} | ||
} | ||
|
||
std::unique_ptr<base::DictionaryValue> Extension::LoadManifest( | ||
const base::FilePath& extension_root, | ||
std::string* error) { | ||
int resource_id; | ||
if (IsComponentExtension(extension_root, &resource_id)) { | ||
const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | ||
base::StringPiece manifest_contents = rb.GetRawDataResource(resource_id); | ||
|
||
JSONStringValueDeserializer deserializer(manifest_contents); | ||
std::unique_ptr<base::Value> root(deserializer.Deserialize(NULL, error)); | ||
if (!root.get()) { | ||
if (error->empty()) { | ||
// If |error| is empty, than the file could not be read. | ||
// It would be cleaner to have the JSON reader give a specific error | ||
// in this case, but other code tests for a file error with | ||
// error->empty(). For now, be consistent. | ||
*error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_UNREADABLE); | ||
} else { | ||
*error = base::StringPrintf( | ||
"%s %s", extensions::manifest_errors::kManifestParseError, error->c_str()); | ||
} | ||
return NULL; | ||
} | ||
|
||
if (!root->IsType(base::Value::Type::DICTIONARY)) { | ||
*error = l10n_util::GetStringUTF8(IDS_EXTENSION_MANIFEST_INVALID); | ||
return NULL; | ||
} | ||
|
||
return base::DictionaryValue::From(std::move(root)); | ||
} else { | ||
return extensions::file_util::LoadManifest(extension_root, error); | ||
} | ||
} | ||
|
||
void Extension::LoadOnFILEThread(const base::FilePath path, | ||
std::unique_ptr<base::DictionaryValue> manifest, | ||
extensions::Manifest::Location manifest_location, | ||
|
@@ -163,7 +214,7 @@ void Extension::LoadOnFILEThread(const base::FilePath path, | |
|
||
std::string error; | ||
if (manifest->empty()) { | ||
manifest = extensions::file_util::LoadManifest(path, &error); | ||
manifest = LoadManifest(path, &error); | ||
} | ||
|
||
if (!manifest || !error.empty()) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
chromium_src/chrome/browser/extensions/chrome_extension_function_details.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/extensions/chrome_extension_function_details.h" | ||
|
||
#include "extensions/browser/extension_function.h" | ||
|
||
ChromeExtensionFunctionDetails::ChromeExtensionFunctionDetails( | ||
UIThreadExtensionFunction* function) | ||
: function_(function) { | ||
} | ||
|
||
ChromeExtensionFunctionDetails::~ChromeExtensionFunctionDetails() { | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this uses brave_resources.h we need to add a dep for
brave_resources
here too