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

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

Issue 2618493002: Chrome app manifest support for action handlers. (Closed)
Patch Set: Make //components/version_info:version_info dep explicit Created 3 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/note_taking_helper_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5e5b54832eafa4b31048368fda4fcaed145bd666..d39ca6cf5f6406d2e048eb4384144e268db61a02 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"
@@ -34,6 +35,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;
@@ -262,9 +264,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(
@@ -275,8 +275,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)) {
@@ -284,6 +282,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;
}
@@ -384,7 +395,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();
}
@@ -394,7 +407,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();
}
« no previous file with comments | « no previous file | chrome/browser/chromeos/note_taking_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698