Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3580)

Unified Diff: chrome/browser/chromeos/note_taking_helper.cc

Issue 2618493002: Chrome app manifest support for action handlers. (Closed)
Patch Set: Rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/note_taking_helper.cc
diff --git a/chrome/browser/chromeos/note_taking_helper.cc b/chrome/browser/chromeos/note_taking_helper.cc
index 95c7594d6d2d14368abd0235351ca5e1bd413718..f27a7ca285154965d5c35149a1d524c04f1ad819 100644
--- a/chrome/browser/chromeos/note_taking_helper.cc
+++ b/chrome/browser/chromeos/note_taking_helper.cc
@@ -33,6 +33,7 @@
#include "extensions/browser/extension_registry.h"
#include "extensions/common/api/app_runtime.h"
#include "extensions/common/extension.h"
+#include "extensions/common/manifest_handlers/action_handlers_handler.h"
#include "url/gurl.h"
namespace app_runtime = extensions::api::app_runtime;
@@ -69,6 +70,13 @@ arc::mojom::IntentInfoPtr CreateIntentInfo(const GURL& clip_data_uri) {
return intent;
}
+// Returns true if the given extension has a new note action handler.
+bool HasNewNoteActionHandler(const extensions::Extension* extension) {
+ std::set<app_runtime::ActionType> action_handlers =
+ extensions::ActionHandlersInfo::GetActionHandlers(extension);
+ return action_handlers.count(app_runtime::ACTION_TYPE_NEW_NOTE) > 0;
+}
+
} // namespace
const char NoteTakingHelper::kIntentAction[] =
@@ -274,8 +282,6 @@ std::vector<const extensions::Extension*> NoteTakingHelper::GetChromeApps(
const extensions::ExtensionSet& enabled_extensions =
extension_registry->enabled_extensions();
- // TODO(derat): Query for additional Chrome apps once http://crbug.com/657139
- // is resolved.
std::vector<const extensions::Extension*> extensions;
for (const auto& id : whitelisted_chrome_app_ids_) {
if (enabled_extensions.Contains(id)) {
@@ -283,6 +289,14 @@ std::vector<const extensions::Extension*> NoteTakingHelper::GetChromeApps(
id, extensions::ExtensionRegistry::ENABLED));
}
}
+
+ // Add any extensions which have a "note" action in their manifest
+ // "action_handler" entry.
+ for (const auto& extension : enabled_extensions) {
+ if (HasNewNoteActionHandler(extension.get()))
Daniel Erat 2017/01/12 23:55:03 we should probably skip whitelisted apps here to m
jdufault 2017/01/14 00:30:42 Done, nice catch.
+ extensions.push_back(extension.get());
+ }
+
return extensions;
}
@@ -383,7 +397,7 @@ void NoteTakingHelper::Observe(int type,
void NoteTakingHelper::OnExtensionLoaded(
content::BrowserContext* browser_context,
const extensions::Extension* extension) {
- if (IsWhitelistedChromeApp(extension)) {
+ if (IsWhitelistedChromeApp(extension) || HasNewNoteActionHandler(extension)) {
for (auto& observer : observers_)
observer.OnAvailableNoteTakingAppsUpdated();
}
@@ -393,7 +407,7 @@ void NoteTakingHelper::OnExtensionUnloaded(
content::BrowserContext* browser_context,
const extensions::Extension* extension,
extensions::UnloadedExtensionInfo::Reason reason) {
- if (IsWhitelistedChromeApp(extension)) {
+ if (IsWhitelistedChromeApp(extension) || HasNewNoteActionHandler(extension)) {
for (auto& observer : observers_)
observer.OnAvailableNoteTakingAppsUpdated();
}

Powered by Google App Engine
This is Rietveld 408576698