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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/media_gallery/media_galleries_dialog_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Implements the Chrome Extensions Media Galleries API. 5 // Implements the Chrome Extensions Media Galleries API.
6 6
7 #include "chrome/browser/extensions/api/media_galleries/media_galleries_api.h" 7 #include "chrome/browser/extensions/api/media_galleries/media_galleries_api.h"
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/platform_file.h" 12 #include "base/platform_file.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/media_gallery/media_file_system_registry.h" 14 #include "chrome/browser/media_gallery/media_file_system_registry.h"
15 #include "chrome/browser/media_gallery/media_galleries_dialog_controller.h" 15 #include "chrome/browser/media_gallery/media_galleries_dialog_controller.h"
16 #include "chrome/browser/ui/chrome_select_file_policy.h"
16 #include "chrome/browser/ui/tab_contents/tab_contents.h" 17 #include "chrome/browser/ui/tab_contents/tab_contents.h"
17 #include "chrome/common/extensions/api/experimental_media_galleries.h" 18 #include "chrome/common/extensions/api/experimental_media_galleries.h"
18 #include "content/public/browser/child_process_security_policy.h" 19 #include "content/public/browser/child_process_security_policy.h"
19 #include "content/public/browser/render_process_host.h" 20 #include "content/public/browser/render_process_host.h"
20 #include "content/public/browser/render_view_host.h" 21 #include "content/public/browser/render_view_host.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 23
23 #if defined(OS_WIN) 24 #if defined(OS_WIN)
24 #include "base/sys_string_conversions.h" 25 #include "base/sys_string_conversions.h"
25 #endif 26 #endif
26 27
27 using content::WebContents; 28 using content::WebContents;
28 29
29 namespace extensions { 30 namespace extensions {
30 31
31 namespace { 32 namespace {
32 33
33 const char kInvalidInteractive[] = "Unknown value for interactive."; 34 const char kInvalidInteractive[] = "Unknown value for interactive.";
34 35
36 // Checks whether the MediaGalleries API is currently accessible (it may be
37 // disallowed even if an extension has the requisite permission).
38 bool ApiIsAccessible(std::string* error) {
39 if (!ChromeSelectFilePolicy::FileSelectDialogsAllowed()) {
40 *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.
41 return false;
42 }
43
44 return true;
45 }
46
35 } // namespace 47 } // namespace
36 48
37 using chrome::MediaFileSystemRegistry; 49 using chrome::MediaFileSystemRegistry;
38 using content::ChildProcessSecurityPolicy; 50 using content::ChildProcessSecurityPolicy;
39 51
40 namespace MediaGalleries = extensions::api::experimental_media_galleries; 52 namespace MediaGalleries = extensions::api::experimental_media_galleries;
41 namespace GetMediaFileSystems = MediaGalleries::GetMediaFileSystems; 53 namespace GetMediaFileSystems = MediaGalleries::GetMediaFileSystems;
42 54
43 MediaGalleriesGetMediaFileSystemsFunction:: 55 MediaGalleriesGetMediaFileSystemsFunction::
44 ~MediaGalleriesGetMediaFileSystemsFunction() {} 56 ~MediaGalleriesGetMediaFileSystemsFunction() {}
45 57
46 bool MediaGalleriesGetMediaFileSystemsFunction::RunImpl() { 58 bool MediaGalleriesGetMediaFileSystemsFunction::RunImpl() {
59 if (!ApiIsAccessible(&error_))
60 return false;
61
47 scoped_ptr<GetMediaFileSystems::Params> params( 62 scoped_ptr<GetMediaFileSystems::Params> params(
48 GetMediaFileSystems::Params::Create(*args_)); 63 GetMediaFileSystems::Params::Create(*args_));
49 EXTENSION_FUNCTION_VALIDATE(params.get()); 64 EXTENSION_FUNCTION_VALIDATE(params.get());
50 MediaGalleries::GetMediaFileSystemsInteractivity interactive = "no"; 65 MediaGalleries::GetMediaFileSystemsInteractivity interactive = "no";
51 if (params->details.get() && params->details->interactive.get()) 66 if (params->details.get() && params->details->interactive.get())
52 interactive = *params->details->interactive; 67 interactive = *params->details->interactive;
53 68
54 if (interactive == "yes") { 69 if (interactive == "yes") {
55 ShowDialog(); 70 ShowDialog();
56 return true; 71 return true;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 base::Bind(&MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries, 130 base::Bind(&MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries,
116 this)); 131 this));
117 } 132 }
118 133
119 // MediaGalleriesAssembleMediaFileFunction ------------------------------------- 134 // MediaGalleriesAssembleMediaFileFunction -------------------------------------
120 135
121 MediaGalleriesAssembleMediaFileFunction:: 136 MediaGalleriesAssembleMediaFileFunction::
122 ~MediaGalleriesAssembleMediaFileFunction() {} 137 ~MediaGalleriesAssembleMediaFileFunction() {}
123 138
124 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { 139 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() {
140 if (!ApiIsAccessible(&error_))
141 return false;
142
125 // TODO(vandebo) Update the metadata and return the new file. 143 // TODO(vandebo) Update the metadata and return the new file.
126 SetResult(Value::CreateNullValue()); 144 SetResult(Value::CreateNullValue());
127 return true; 145 return true;
128 } 146 }
129 147
130 } // namespace extensions 148 } // namespace extensions
OLDNEW
« 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