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

Side by Side Diff: chrome/browser/extensions/api/media_galleries/media_galleries_api.cc

Issue 12091054: Media Galleries: Always call MediaFileSystemRegistry::GetMediaFileSystemsForExtension() before show… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 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
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 <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 20 matching lines...) Expand all
31 #include "content/public/browser/render_process_host.h" 31 #include "content/public/browser/render_process_host.h"
32 #include "content/public/browser/render_view_host.h" 32 #include "content/public/browser/render_view_host.h"
33 #include "content/public/browser/web_contents.h" 33 #include "content/public/browser/web_contents.h"
34 34
35 #if defined(OS_WIN) 35 #if defined(OS_WIN)
36 #include "base/sys_string_conversions.h" 36 #include "base/sys_string_conversions.h"
37 #endif 37 #endif
38 38
39 using chrome::MediaFileSystemInfo; 39 using chrome::MediaFileSystemInfo;
40 using chrome::MediaFileSystemRegistry; 40 using chrome::MediaFileSystemRegistry;
41 using chrome::MediaFileSystemsCallback;
41 using content::ChildProcessSecurityPolicy; 42 using content::ChildProcessSecurityPolicy;
42 using content::WebContents; 43 using content::WebContents;
43 44
44 namespace MediaGalleries = extensions::api::media_galleries; 45 namespace MediaGalleries = extensions::api::media_galleries;
45 namespace GetMediaFileSystems = MediaGalleries::GetMediaFileSystems; 46 namespace GetMediaFileSystems = MediaGalleries::GetMediaFileSystems;
46 47
47 namespace extensions { 48 namespace extensions {
48 49
49 namespace { 50 namespace {
50 51
(...skipping 29 matching lines...) Expand all
80 GetMediaFileSystems::Params::Create(*args_)); 81 GetMediaFileSystems::Params::Create(*args_));
81 EXTENSION_FUNCTION_VALIDATE(params.get()); 82 EXTENSION_FUNCTION_VALIDATE(params.get());
82 MediaGalleries::GetMediaFileSystemsInteractivity interactive = 83 MediaGalleries::GetMediaFileSystemsInteractivity interactive =
83 MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NO; 84 MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NO;
84 if (params->details.get() && params->details->interactive != MediaGalleries:: 85 if (params->details.get() && params->details->interactive != MediaGalleries::
85 GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NONE) { 86 GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NONE) {
86 interactive = params->details->interactive; 87 interactive = params->details->interactive;
87 } 88 }
88 89
89 switch (interactive) { 90 switch (interactive) {
90 case MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_YES: 91 case MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_YES: {
91 ShowDialog(); 92 MediaFileSystemsCallback cb = base::Bind(
92 return true; 93 &MediaGalleriesGetMediaFileSystemsFunction::AlwaysShowDialog, this);
93 case MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_IF_NEEDED: {
94 MediaFileSystemRegistry* registry = 94 MediaFileSystemRegistry* registry =
95 g_browser_process->media_file_system_registry(); 95 g_browser_process->media_file_system_registry();
96 registry->GetMediaFileSystemsForExtension( 96 registry->GetMediaFileSystemsForExtension(
vandebo (ex-Chrome) 2013/01/30 17:47:30 Since this isn't strictly required, add a comment
Lei Zhang 2013/01/30 21:00:47 Done.
97 render_view_host(), GetExtension(), base::Bind( 97 render_view_host(), GetExtension(), cb);
98 &MediaGalleriesGetMediaFileSystemsFunction:: 98 return true;
99 ShowDialogIfNoGalleries, 99 }
100 this)); 100 case MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_IF_NEEDED: {
101 MediaFileSystemsCallback cb = base::Bind(
102 &MediaGalleriesGetMediaFileSystemsFunction::ShowDialogIfNoGalleries,
vandebo (ex-Chrome) 2013/01/30 17:47:30 Can you rearrange this code to eliminate the code
Lei Zhang 2013/01/30 21:00:47 Done.
103 this);
104 MediaFileSystemRegistry* registry =
105 g_browser_process->media_file_system_registry();
106 registry->GetMediaFileSystemsForExtension(
107 render_view_host(), GetExtension(), cb);
101 return true; 108 return true;
102 } 109 }
103 case MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NO: 110 case MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NO:
104 GetAndReturnGalleries(); 111 GetAndReturnGalleries();
105 return true; 112 return true;
106 case MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NONE: 113 case MediaGalleries::GET_MEDIA_FILE_SYSTEMS_INTERACTIVITY_NONE:
107 NOTREACHED(); 114 NOTREACHED();
108 } 115 }
109 error_ = kInvalidInteractive; 116 error_ = kInvalidInteractive;
110 return false; 117 return false;
111 } 118 }
112 119
120 void MediaGalleriesGetMediaFileSystemsFunction::AlwaysShowDialog(
121 const std::vector<MediaFileSystemInfo>& /*filesystems*/) {
122 ShowDialog();
vandebo (ex-Chrome) 2013/01/30 17:47:30 Or maybe the comment should go here.
123 }
124
113 void MediaGalleriesGetMediaFileSystemsFunction::ShowDialogIfNoGalleries( 125 void MediaGalleriesGetMediaFileSystemsFunction::ShowDialogIfNoGalleries(
114 const std::vector<MediaFileSystemInfo>& filesystems) { 126 const std::vector<MediaFileSystemInfo>& filesystems) {
115 if (filesystems.empty()) 127 if (filesystems.empty())
116 ShowDialog(); 128 ShowDialog();
117 else 129 else
118 ReturnGalleries(filesystems); 130 ReturnGalleries(filesystems);
119 } 131 }
120 132
121 void MediaGalleriesGetMediaFileSystemsFunction::GetAndReturnGalleries() { 133 void MediaGalleriesGetMediaFileSystemsFunction::GetAndReturnGalleries() {
122 MediaFileSystemRegistry* registry = 134 MediaFileSystemRegistry* registry =
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { 241 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() {
230 if (!ApiIsAccessible(&error_)) 242 if (!ApiIsAccessible(&error_))
231 return false; 243 return false;
232 244
233 // TODO(vandebo) Update the metadata and return the new file. 245 // TODO(vandebo) Update the metadata and return the new file.
234 SetResult(base::Value::CreateNullValue()); 246 SetResult(base::Value::CreateNullValue());
235 return true; 247 return true;
236 } 248 }
237 249
238 } // namespace extensions 250 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698