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

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: 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 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/extensions/shell_window_registry.h" 14 #include "chrome/browser/extensions/shell_window_registry.h"
15 #include "chrome/browser/media_gallery/media_file_system_registry.h" 15 #include "chrome/browser/media_gallery/media_file_system_registry.h"
16 #include "chrome/browser/media_gallery/media_galleries_dialog_controller.h" 16 #include "chrome/browser/media_gallery/media_galleries_dialog_controller.h"
17 #include "chrome/browser/ui/chrome_select_file_policy.h"
17 #include "chrome/browser/ui/extensions/shell_window.h" 18 #include "chrome/browser/ui/extensions/shell_window.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents.h" 19 #include "chrome/browser/ui/tab_contents/tab_contents.h"
19 #include "chrome/common/extensions/api/experimental_media_galleries.h" 20 #include "chrome/common/extensions/api/experimental_media_galleries.h"
21 #include "chrome/common/pref_names.h"
20 #include "content/public/browser/child_process_security_policy.h" 22 #include "content/public/browser/child_process_security_policy.h"
21 #include "content/public/browser/render_process_host.h" 23 #include "content/public/browser/render_process_host.h"
22 #include "content/public/browser/render_view_host.h" 24 #include "content/public/browser/render_view_host.h"
23 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
24 26
25 #if defined(OS_WIN) 27 #if defined(OS_WIN)
26 #include "base/sys_string_conversions.h" 28 #include "base/sys_string_conversions.h"
27 #endif 29 #endif
28 30
29 using content::WebContents; 31 using content::WebContents;
30 32
31 namespace extensions { 33 namespace extensions {
32 34
33 namespace { 35 namespace {
34 36
37 const char kDisallowedByPolicy[] =
38 "Media Galleries API is disallowed by policy: ";
35 const char kInvalidInteractive[] = "Unknown value for interactive."; 39 const char kInvalidInteractive[] = "Unknown value for interactive.";
36 40
41 // Checks whether the MediaGalleries API is currently accessible (it may be
42 // disallowed even if an extension has the requisite permission).
43 bool ApiIsAccessible(std::string* error) {
44 if (!ChromeSelectFilePolicy::FileSelectDialogsAllowed()) {
45 *error = std::string(kDisallowedByPolicy) +
46 prefs::kAllowFileSelectionDialogs;
47 return false;
48 }
49
50 return true;
51 }
52
37 } // namespace 53 } // namespace
38 54
39 using chrome::MediaFileSystemRegistry; 55 using chrome::MediaFileSystemRegistry;
40 using content::ChildProcessSecurityPolicy; 56 using content::ChildProcessSecurityPolicy;
41 57
42 namespace MediaGalleries = extensions::api::experimental_media_galleries; 58 namespace MediaGalleries = extensions::api::experimental_media_galleries;
43 namespace GetMediaFileSystems = MediaGalleries::GetMediaFileSystems; 59 namespace GetMediaFileSystems = MediaGalleries::GetMediaFileSystems;
44 60
45 MediaGalleriesGetMediaFileSystemsFunction:: 61 MediaGalleriesGetMediaFileSystemsFunction::
46 ~MediaGalleriesGetMediaFileSystemsFunction() {} 62 ~MediaGalleriesGetMediaFileSystemsFunction() {}
47 63
48 bool MediaGalleriesGetMediaFileSystemsFunction::RunImpl() { 64 bool MediaGalleriesGetMediaFileSystemsFunction::RunImpl() {
65 if (!ApiIsAccessible(&error_))
66 return false;
67
49 scoped_ptr<GetMediaFileSystems::Params> params( 68 scoped_ptr<GetMediaFileSystems::Params> params(
50 GetMediaFileSystems::Params::Create(*args_)); 69 GetMediaFileSystems::Params::Create(*args_));
51 EXTENSION_FUNCTION_VALIDATE(params.get()); 70 EXTENSION_FUNCTION_VALIDATE(params.get());
52 MediaGalleries::GetMediaFileSystemsInteractivity interactive = "no"; 71 MediaGalleries::GetMediaFileSystemsInteractivity interactive = "no";
53 if (params->details.get() && params->details->interactive.get()) 72 if (params->details.get() && params->details->interactive.get())
54 interactive = *params->details->interactive; 73 interactive = *params->details->interactive;
55 74
56 if (interactive == "yes") { 75 if (interactive == "yes") {
57 ShowDialog(); 76 ShowDialog();
58 return true; 77 return true;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 base::Bind(&MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries, 141 base::Bind(&MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries,
123 this)); 142 this));
124 } 143 }
125 144
126 // MediaGalleriesAssembleMediaFileFunction ------------------------------------- 145 // MediaGalleriesAssembleMediaFileFunction -------------------------------------
127 146
128 MediaGalleriesAssembleMediaFileFunction:: 147 MediaGalleriesAssembleMediaFileFunction::
129 ~MediaGalleriesAssembleMediaFileFunction() {} 148 ~MediaGalleriesAssembleMediaFileFunction() {}
130 149
131 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { 150 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() {
151 if (!ApiIsAccessible(&error_))
152 return false;
153
132 // TODO(vandebo) Update the metadata and return the new file. 154 // TODO(vandebo) Update the metadata and return the new file.
133 SetResult(Value::CreateNullValue()); 155 SetResult(Value::CreateNullValue());
134 return true; 156 return true;
135 } 157 }
136 158
137 } // namespace extensions 159 } // 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