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

Unified Diff: chrome/browser/extensions/api/media_galleries/media_galleries_api.cc

Issue 10832330: disable [add folder] button for media galleries dialog if (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 4 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/media_gallery/media_galleries_dialog_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
diff --git a/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc b/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
index 36dfecf7eb69c51fdfecd8621549ee4216581b8b..ee8160241bcf78fcc4356b17f4b8bb89b6f1f93b 100644
--- a/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
+++ b/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
@@ -14,9 +14,11 @@
#include "chrome/browser/extensions/shell_window_registry.h"
#include "chrome/browser/media_gallery/media_file_system_registry.h"
#include "chrome/browser/media_gallery/media_galleries_dialog_controller.h"
+#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/browser/ui/extensions/shell_window.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/extensions/api/experimental_media_galleries.h"
+#include "chrome/common/pref_names.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
@@ -32,8 +34,22 @@ namespace extensions {
namespace {
+const char kDisallowedByPolicy[] =
+ "Media Galleries API is disallowed by policy: ";
const char kInvalidInteractive[] = "Unknown value for interactive.";
+// Checks whether the MediaGalleries API is currently accessible (it may be
+// disallowed even if an extension has the requisite permission).
+bool ApiIsAccessible(std::string* error) {
+ if (!ChromeSelectFilePolicy::FileSelectDialogsAllowed()) {
+ *error = std::string(kDisallowedByPolicy) +
+ prefs::kAllowFileSelectionDialogs;
+ return false;
+ }
+
+ return true;
+}
+
} // namespace
using chrome::MediaFileSystemRegistry;
@@ -46,6 +62,9 @@ MediaGalleriesGetMediaFileSystemsFunction::
~MediaGalleriesGetMediaFileSystemsFunction() {}
bool MediaGalleriesGetMediaFileSystemsFunction::RunImpl() {
+ if (!ApiIsAccessible(&error_))
+ return false;
+
scoped_ptr<GetMediaFileSystems::Params> params(
GetMediaFileSystems::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
@@ -129,6 +148,9 @@ MediaGalleriesAssembleMediaFileFunction::
~MediaGalleriesAssembleMediaFileFunction() {}
bool MediaGalleriesAssembleMediaFileFunction::RunImpl() {
+ if (!ApiIsAccessible(&error_))
+ return false;
+
// TODO(vandebo) Update the metadata and return the new file.
SetResult(Value::CreateNullValue());
return true;
« no previous file with comments | « no previous file | chrome/browser/media_gallery/media_galleries_dialog_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698