Index: chrome/browser/chromeos/note_taking_app_utils.cc |
diff --git a/chrome/browser/chromeos/note_taking_app_utils.cc b/chrome/browser/chromeos/note_taking_app_utils.cc |
index 7f12a8da4081447fc6d397c1fde54acc820fe55b..e56cb018d1824feced2b2cac29eda74c4ebbc6b8 100644 |
--- a/chrome/browser/chromeos/note_taking_app_utils.cc |
+++ b/chrome/browser/chromeos/note_taking_app_utils.cc |
@@ -15,6 +15,7 @@ |
#include "base/strings/string_split.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chromeos/chromeos_switches.h" |
+#include "extensions/browser/app_window/app_window.h" |
#include "extensions/browser/extension_registry.h" |
#include "extensions/common/api/app_runtime.h" |
#include "extensions/common/extension.h" |
@@ -32,16 +33,10 @@ const char* const kExtensionIds[] = { |
"hmjkmjkepdijhoojdojkdfohbdgmmhki", // Google Keep app (Web Store) |
}; |
-// Returns the first installed and enabled whitelisted note-taking app, or null |
-// if none is installed. |
-const extensions::Extension* GetApp(Profile* profile) { |
- // TODO(derat): Check the to-be-added "note-taking app enabled" pref here and |
- // return null if it's disabled. |
- |
+// Returns a list of app IDs. |
+std::vector<std::string> GetAppIds() { |
std::vector<std::string> ids; |
- // TODO(derat): Instead of a using hardcoded list of IDs, use an app |
- // designated by a to-be-added pref. |
const std::string switch_value = |
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
switches::kNoteTakingAppIds); |
@@ -51,6 +46,18 @@ const extensions::Extension* GetApp(Profile* profile) { |
} else { |
ids.assign(kExtensionIds, kExtensionIds + arraysize(kExtensionIds)); |
} |
+ return ids; |
+} |
+ |
+// Returns the first installed and enabled whitelisted note-taking app, or null |
+// if none is installed. |
+const extensions::Extension* GetApp(Profile* profile) { |
+ // TODO(derat): Check the to-be-added "note-taking app enabled" pref here and |
+ // return null if it's disabled. |
+ |
+ // TODO(derat): Instead of a using hardcoded list of IDs, use an app |
+ // designated by a to-be-added pref. |
+ std::vector<std::string> ids = GetAppIds(); |
sky
2016/09/16 23:20:16
Move into for loop (see comment below).
xiaoyinh(OOO Sep 11-29)
2016/09/19 21:19:52
Done.
|
const extensions::ExtensionRegistry* extension_registry = |
extensions::ExtensionRegistry::Get(profile); |
@@ -86,4 +93,13 @@ void LaunchNoteTakingAppForNewNote(Profile* profile, |
apps::LaunchPlatformAppWithAction(profile, app, std::move(action_data), path); |
} |
+bool IsNoteTakingApp(extensions::AppWindow* app_window) { |
+ std::vector<std::string> ids = GetAppIds(); |
sky
2016/09/16 23:20:16
move into for loop, e.g. for (const auto& id : Get
xiaoyinh(OOO Sep 11-29)
2016/09/19 21:19:52
Done.
|
+ for (const auto& id : ids) { |
+ if (id == app_window->extension_id()) |
+ return true; |
+ } |
+ return false; |
+} |
+ |
} // namespace chromeos |