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

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

Issue 2618493002: Chrome app manifest support for action handlers. (Closed)
Patch Set: Address comments 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..0db7e9b05f9da0fcfd3c27895b9fb26d4556f770 100644
--- a/chrome/browser/chromeos/note_taking_helper.cc
+++ b/chrome/browser/chromeos/note_taking_helper.cc
@@ -16,6 +16,7 @@
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
#include "base/strings/string_split.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
@@ -33,6 +34,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;
@@ -261,9 +263,7 @@ NoteTakingHelper::~NoteTakingHelper() {
bool NoteTakingHelper::IsWhitelistedChromeApp(
const extensions::Extension* extension) const {
DCHECK(extension);
- return std::find(whitelisted_chrome_app_ids_.begin(),
- whitelisted_chrome_app_ids_.end(),
- extension->id()) != whitelisted_chrome_app_ids_.end();
+ return base::ContainsValue(whitelisted_chrome_app_ids_, extension->id());
}
std::vector<const extensions::Extension*> NoteTakingHelper::GetChromeApps(
@@ -274,8 +274,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 +281,19 @@ 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 (base::ContainsValue(extensions, extension.get()))
+ continue;
+
+ if (extensions::ActionHandlersInfo::HasActionHandler(
+ extension.get(), app_runtime::ACTION_TYPE_NEW_NOTE)) {
+ extensions.push_back(extension.get());
+ }
+ }
+
return extensions;
}
@@ -383,7 +394,9 @@ void NoteTakingHelper::Observe(int type,
void NoteTakingHelper::OnExtensionLoaded(
content::BrowserContext* browser_context,
const extensions::Extension* extension) {
- if (IsWhitelistedChromeApp(extension)) {
+ if (IsWhitelistedChromeApp(extension) ||
+ extensions::ActionHandlersInfo::HasActionHandler(
+ extension, app_runtime::ACTION_TYPE_NEW_NOTE)) {
for (auto& observer : observers_)
observer.OnAvailableNoteTakingAppsUpdated();
}
@@ -393,7 +406,9 @@ void NoteTakingHelper::OnExtensionUnloaded(
content::BrowserContext* browser_context,
const extensions::Extension* extension,
extensions::UnloadedExtensionInfo::Reason reason) {
- if (IsWhitelistedChromeApp(extension)) {
+ if (IsWhitelistedChromeApp(extension) ||
+ extensions::ActionHandlersInfo::HasActionHandler(
+ extension, app_runtime::ACTION_TYPE_NEW_NOTE)) {
for (auto& observer : observers_)
observer.OnAvailableNoteTakingAppsUpdated();
}

Powered by Google App Engine
This is Rietveld 408576698