Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/note_taking_helper.h" | 5 #include "chrome/browser/chromeos/note_taking_helper.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "apps/launcher.h" | 10 #include "apps/launcher.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 #include "chromeos/chromeos_switches.h" | 25 #include "chromeos/chromeos_switches.h" |
| 26 #include "components/arc/arc_bridge_service.h" | 26 #include "components/arc/arc_bridge_service.h" |
| 27 #include "components/arc/arc_service_manager.h" | 27 #include "components/arc/arc_service_manager.h" |
| 28 #include "components/arc/common/intent_helper.mojom.h" | 28 #include "components/arc/common/intent_helper.mojom.h" |
| 29 #include "components/prefs/pref_service.h" | 29 #include "components/prefs/pref_service.h" |
| 30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
| 31 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
| 32 #include "extensions/browser/extension_registry.h" | 32 #include "extensions/browser/extension_registry.h" |
| 33 #include "extensions/common/api/app_runtime.h" | 33 #include "extensions/common/api/app_runtime.h" |
| 34 #include "extensions/common/extension.h" | 34 #include "extensions/common/extension.h" |
| 35 #include "extensions/common/manifest_constants.h" | |
| 35 #include "url/gurl.h" | 36 #include "url/gurl.h" |
| 36 | 37 |
| 37 namespace app_runtime = extensions::api::app_runtime; | 38 namespace app_runtime = extensions::api::app_runtime; |
| 38 | 39 |
| 39 namespace chromeos { | 40 namespace chromeos { |
| 40 namespace { | 41 namespace { |
| 41 | 42 |
| 42 // Pointer to singleton instance. | 43 // Pointer to singleton instance. |
| 43 NoteTakingHelper* g_helper = nullptr; | 44 NoteTakingHelper* g_helper = nullptr; |
| 44 | 45 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 63 arc::mojom::IntentInfoPtr CreateIntentInfo(const GURL& clip_data_uri) { | 64 arc::mojom::IntentInfoPtr CreateIntentInfo(const GURL& clip_data_uri) { |
| 64 arc::mojom::IntentInfoPtr intent = arc::mojom::IntentInfo::New(); | 65 arc::mojom::IntentInfoPtr intent = arc::mojom::IntentInfo::New(); |
| 65 intent->action = NoteTakingHelper::kIntentAction; | 66 intent->action = NoteTakingHelper::kIntentAction; |
| 66 if (!clip_data_uri.is_empty()) | 67 if (!clip_data_uri.is_empty()) |
| 67 intent->clip_data_uri = clip_data_uri.spec(); | 68 intent->clip_data_uri = clip_data_uri.spec(); |
| 68 return intent; | 69 return intent; |
| 69 } | 70 } |
| 70 | 71 |
| 71 } // namespace | 72 } // namespace |
| 72 | 73 |
| 74 const char NoteTakingHelper::kChromeNewNoteAction[] = "new_note"; | |
| 73 const char NoteTakingHelper::kIntentAction[] = | 75 const char NoteTakingHelper::kIntentAction[] = |
| 74 "org.chromium.arc.intent.action.CREATE_NOTE"; | 76 "org.chromium.arc.intent.action.CREATE_NOTE"; |
| 75 const char NoteTakingHelper::kDevKeepExtensionId[] = | 77 const char NoteTakingHelper::kDevKeepExtensionId[] = |
| 76 "ogfjaccbdfhecploibfbhighmebiffla"; | 78 "ogfjaccbdfhecploibfbhighmebiffla"; |
| 77 const char NoteTakingHelper::kProdKeepExtensionId[] = | 79 const char NoteTakingHelper::kProdKeepExtensionId[] = |
| 78 "hmjkmjkepdijhoojdojkdfohbdgmmhki"; | 80 "hmjkmjkepdijhoojdojkdfohbdgmmhki"; |
| 79 | 81 |
| 80 // static | 82 // static |
| 81 void NoteTakingHelper::Initialize() { | 83 void NoteTakingHelper::Initialize() { |
| 82 DCHECK(!g_helper); | 84 DCHECK(!g_helper); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 } | 249 } |
| 248 | 250 |
| 249 std::vector<const extensions::Extension*> NoteTakingHelper::GetChromeApps( | 251 std::vector<const extensions::Extension*> NoteTakingHelper::GetChromeApps( |
| 250 Profile* profile) const { | 252 Profile* profile) const { |
| 251 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 253 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 252 const extensions::ExtensionRegistry* extension_registry = | 254 const extensions::ExtensionRegistry* extension_registry = |
| 253 extensions::ExtensionRegistry::Get(profile); | 255 extensions::ExtensionRegistry::Get(profile); |
| 254 const extensions::ExtensionSet& enabled_extensions = | 256 const extensions::ExtensionSet& enabled_extensions = |
| 255 extension_registry->enabled_extensions(); | 257 extension_registry->enabled_extensions(); |
| 256 | 258 |
| 257 // TODO(derat): Query for additional Chrome apps once http://crbug.com/657139 | |
| 258 // is resolved. | |
| 259 std::vector<const extensions::Extension*> extensions; | 259 std::vector<const extensions::Extension*> extensions; |
| 260 for (const auto& id : whitelisted_chrome_app_ids_) { | 260 for (const auto& id : whitelisted_chrome_app_ids_) { |
| 261 if (enabled_extensions.Contains(id)) { | 261 if (enabled_extensions.Contains(id)) { |
| 262 extensions.push_back(extension_registry->GetExtensionById( | 262 extensions.push_back(extension_registry->GetExtensionById( |
| 263 id, extensions::ExtensionRegistry::ENABLED)); | 263 id, extensions::ExtensionRegistry::ENABLED)); |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | |
| 267 // Add any extensions which have a "note" action in their manifest | |
| 268 // "action_handler" entry. | |
| 269 for (const auto& extension : enabled_extensions) { | |
| 270 // Find "action_handler" manifest entry. | |
| 271 const base::ListValue* action_handlers; | |
| 272 if (!extension->manifest()->GetList( | |
|
Devlin
2017/01/09 23:39:02
This shouldn't be handled here. Instead, we shoul
jdufault
2017/01/12 22:22:24
Done.
| |
| 273 extensions::manifest_keys::kActionHandlers, &action_handlers)) { | |
| 274 continue; | |
| 275 } | |
| 276 | |
| 277 // Check for "new_note" action. | |
| 278 for (const auto& wrapped_action_handler : *action_handlers) { | |
| 279 std::string action_handler; | |
| 280 if (!wrapped_action_handler->GetAsString(&action_handler)) | |
| 281 continue; | |
| 282 | |
| 283 if (action_handler == kChromeNewNoteAction) | |
| 284 extensions.push_back(extension.get()); | |
| 285 } | |
| 286 } | |
| 287 | |
| 266 return extensions; | 288 return extensions; |
| 267 } | 289 } |
| 268 | 290 |
| 269 void NoteTakingHelper::UpdateAndroidApps() { | 291 void NoteTakingHelper::UpdateAndroidApps() { |
| 270 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 292 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 271 auto* helper = ARC_GET_INSTANCE_FOR_METHOD( | 293 auto* helper = ARC_GET_INSTANCE_FOR_METHOD( |
| 272 arc::ArcServiceManager::Get()->arc_bridge_service()->intent_helper(), | 294 arc::ArcServiceManager::Get()->arc_bridge_service()->intent_helper(), |
| 273 RequestIntentHandlerList); | 295 RequestIntentHandlerList); |
| 274 if (!helper) | 296 if (!helper) |
| 275 return; | 297 return; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 for (auto& observer : observers_) | 395 for (auto& observer : observers_) |
| 374 observer.OnAvailableNoteTakingAppsUpdated(); | 396 observer.OnAvailableNoteTakingAppsUpdated(); |
| 375 } | 397 } |
| 376 } | 398 } |
| 377 | 399 |
| 378 void NoteTakingHelper::OnShutdown(extensions::ExtensionRegistry* registry) { | 400 void NoteTakingHelper::OnShutdown(extensions::ExtensionRegistry* registry) { |
| 379 extension_registry_observer_.Remove(registry); | 401 extension_registry_observer_.Remove(registry); |
| 380 } | 402 } |
| 381 | 403 |
| 382 } // namespace chromeos | 404 } // namespace chromeos |
| OLD | NEW |