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

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: dusalliw media galleries altogether 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 61aead53c0a9fc7c0bc62c1cc4a498b3481c36bc..1c4cf00a6df3a532ede89e2d4b9cc924101505f1 100644
--- a/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
+++ b/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
@@ -13,6 +13,7 @@
#include "base/values.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/tab_contents/tab_contents.h"
#include "chrome/common/extensions/api/experimental_media_galleries.h"
#include "content/public/browser/child_process_security_policy.h"
@@ -32,6 +33,17 @@ namespace {
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 = kDisallowedByPolicy;
vandebo (ex-Chrome) 2012/08/21 23:24:20 Is this constant defined somewhere?
Evan Stade 2012/08/21 23:56:17 Done. Do you think we should call out the explicit
vandebo (ex-Chrome) 2012/08/22 00:01:51 That might be nice.
Evan Stade 2012/08/22 00:31:53 Done.
+ return false;
+ }
+
+ return true;
+}
+
} // namespace
using chrome::MediaFileSystemRegistry;
@@ -44,6 +56,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());
@@ -122,6 +137,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