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

Unified Diff: chrome/browser/chromeos/file_manager/file_tasks_unittest.cc

Issue 381583007: Ephemeral apps should not appear in ChromeOS file manager menus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 | « chrome/browser/chromeos/file_manager/file_tasks.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/file_manager/file_tasks_unittest.cc
diff --git a/chrome/browser/chromeos/file_manager/file_tasks_unittest.cc b/chrome/browser/chromeos/file_manager/file_tasks_unittest.cc
index d6c17dd2d16ca05afc9f74cfc3694570a4358ef2..d4c2d949aeb241a3b7a1f848561b748ec755d00c 100644
--- a/chrome/browser/chromeos/file_manager/file_tasks_unittest.cc
+++ b/chrome/browser/chromeos/file_manager/file_tasks_unittest.cc
@@ -22,6 +22,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread_bundle.h"
+#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension_builder.h"
#include "google_apis/drive/drive_api_parser.h"
@@ -379,6 +380,7 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTasks) {
// % ruby -le 'print (0...32).to_a.map{(?a + rand(16)).chr}.join'
const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph";
const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca";
+ const char kEphemeralId[] = "opoomfdlbjcbjinalcjdjfoiikdeaoel";
// Foo.app can handle "text/plain" and "text/html".
extensions::ExtensionBuilder foo_app;
@@ -429,6 +431,38 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTasks) {
bar_app.SetID(kBarId);
extension_service_->AddExtension(bar_app.Build().get());
+ // Ephemeral.app is an ephemeral app that can handle "text/plain".
+ // It should not ever be found as ephemeral apps cannot be file handlers.
+ extensions::ExtensionBuilder ephemeral_app;
+ ephemeral_app.SetManifest(
+ extensions::DictionaryBuilder()
+ .Set("name", "Ephemeral")
+ .Set("version", "1.0.0")
+ .Set("manifest_version", 2)
+ .Set("app",
+ extensions::DictionaryBuilder().Set(
+ "background",
+ extensions::DictionaryBuilder().Set(
+ "scripts",
+ extensions::ListBuilder().Append("background.js"))))
+ .Set("file_handlers",
+ extensions::DictionaryBuilder().Set(
+ "text",
+ extensions::DictionaryBuilder().Set("title", "Text").Set(
+ "types",
+ extensions::ListBuilder().Append("text/plain")))));
+ ephemeral_app.SetID(kEphemeralId);
+ scoped_refptr<extensions::Extension> built_ephemeral_app(
+ ephemeral_app.Build());
+ extension_service_->AddExtension(built_ephemeral_app.get());
+ extensions::ExtensionPrefs* extension_prefs =
+ extensions::ExtensionPrefs::Get(&test_profile_);
+ extension_prefs->OnExtensionInstalled(built_ephemeral_app.get(),
+ extensions::Extension::ENABLED,
+ syncer::StringOrdinal(),
+ extensions::kInstallFlagIsEphemeral,
+ std::string());
+
// Find apps for a "text/plain" file. Foo.app and Bar.app should be found.
PathAndMimeTypeSet path_mime_set;
path_mime_set.insert(
@@ -483,6 +517,7 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileBrowserHandlerTasks) {
// Copied from FindFileHandlerTasks test above.
const char kFooId[] = "hhgbjpmdppecanaaogonaigmmifgpaph";
const char kBarId[] = "odlhccgofgkadkkhcmhgnhgahonahoca";
+ const char kEphemeralId[] = "opoomfdlbjcbjinalcjdjfoiikdeaoel";
// Foo.app can handle ".txt" and ".html".
// This one is an extension, and has "file_browser_handlers"
@@ -520,6 +555,35 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileBrowserHandlerTasks) {
bar_app.SetID(kBarId);
extension_service_->AddExtension(bar_app.Build().get());
+ // Ephemeral.app is an ephemeral app that can handle ".txt".
+ // It should not ever be found as ephemeral apps cannot be file browser
+ // handlers.
+ extensions::ExtensionBuilder ephemeral_app;
+ ephemeral_app.SetManifest(
+ extensions::DictionaryBuilder()
+ .Set("name", "Ephemeral")
+ .Set("version", "1.0.0")
+ .Set("manifest_version", 2)
+ .Set("file_browser_handlers",
+ extensions::ListBuilder().Append(
+ extensions::DictionaryBuilder()
+ .Set("id", "open")
+ .Set("default_title", "open")
+ .Set("file_filters",
+ extensions::ListBuilder().Append(
+ "filesystem:*.txt")))));
+ ephemeral_app.SetID(kEphemeralId);
+ scoped_refptr<extensions::Extension> built_ephemeral_app(
+ ephemeral_app.Build());
+ extension_service_->AddExtension(built_ephemeral_app.get());
+ extensions::ExtensionPrefs* extension_prefs =
+ extensions::ExtensionPrefs::Get(&test_profile_);
+ extension_prefs->OnExtensionInstalled(built_ephemeral_app.get(),
+ extensions::Extension::ENABLED,
+ syncer::StringOrdinal(),
+ extensions::kInstallFlagIsEphemeral,
+ std::string());
+
// Find apps for a ".txt" file. Foo.app and Bar.app should be found.
std::vector<GURL> file_urls;
file_urls.push_back(GURL("filesystem:chrome-extension://id/dir/foo.txt"));
« no previous file with comments | « chrome/browser/chromeos/file_manager/file_tasks.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698