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

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

Issue 11138010: Remove TabContents from media galleries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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.h » ('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 <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/platform_file.h" 14 #include "base/platform_file.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/browser/extensions/shell_window_registry.h"
18 #include "chrome/browser/media_gallery/media_file_system_registry.h" 17 #include "chrome/browser/media_gallery/media_file_system_registry.h"
19 #include "chrome/browser/media_gallery/media_galleries_dialog_controller.h" 18 #include "chrome/browser/media_gallery/media_galleries_dialog_controller.h"
20 #include "chrome/browser/ui/chrome_select_file_policy.h" 19 #include "chrome/browser/ui/chrome_select_file_policy.h"
21 #include "chrome/browser/ui/extensions/shell_window.h"
22 #include "chrome/browser/ui/tab_contents/tab_contents.h"
23 #include "chrome/common/extensions/api/experimental_media_galleries.h" 20 #include "chrome/common/extensions/api/experimental_media_galleries.h"
24 #include "chrome/common/extensions/api/media_galleries.h" 21 #include "chrome/common/extensions/api/media_galleries.h"
25 #include "chrome/common/extensions/permissions/media_galleries_permission.h" 22 #include "chrome/common/extensions/permissions/media_galleries_permission.h"
26 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
27 #include "content/public/browser/child_process_security_policy.h" 24 #include "content/public/browser/child_process_security_policy.h"
28 #include "content/public/browser/render_process_host.h" 25 #include "content/public/browser/render_process_host.h"
29 #include "content/public/browser/render_view_host.h" 26 #include "content/public/browser/render_view_host.h"
30 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
31 28
32 #if defined(OS_WIN) 29 #if defined(OS_WIN)
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 151 }
155 // TODO(vandebo) Handle write permission. 152 // TODO(vandebo) Handle write permission.
156 } 153 }
157 154
158 SetResult(list); 155 SetResult(list);
159 SendResponse(true); 156 SendResponse(true);
160 } 157 }
161 158
162 void MediaGalleriesGetMediaFileSystemsFunction::ShowDialog() { 159 void MediaGalleriesGetMediaFileSystemsFunction::ShowDialog() {
163 WebContents* contents = WebContents::FromRenderViewHost(render_view_host()); 160 WebContents* contents = WebContents::FromRenderViewHost(render_view_host());
164 TabContents* tab_contents =
165 contents ? TabContents::FromWebContents(contents) : NULL;
166 if (!tab_contents) {
Evan Stade 2012/10/15 21:34:06 this code was here in case the API was called from
Avi (use Gerrit) 2012/10/15 22:10:01 Question: Suppose that the background page doesn't
Evan Stade 2012/10/15 22:51:33 the background page does not have a tab contents.
Avi (use Gerrit) 2012/10/17 22:15:42 I have a fix, but found a related crash at the sam
Evan Stade 2012/10/17 22:18:59 might that be fixed by r162402?
Avi (use Gerrit) 2012/10/17 22:28:48 This appears to be different. I'm verifying with a
Evan Stade 2012/10/17 22:35:11 thanks.
167 ShellWindow* window = ShellWindowRegistry::Get(profile())->
168 GetCurrentShellWindowForApp(GetExtension()->id());
169 if (window) {
170 tab_contents = window->tab_contents();
171 } else {
172 // Abort showing the dialog. TODO(estade) Perhaps return an error instead.
173 GetAndReturnGalleries();
174 return;
175 }
176 }
177 161
178 // Controller will delete itself. 162 // Controller will delete itself.
179 base::Closure cb = base::Bind( 163 base::Closure cb = base::Bind(
180 &MediaGalleriesGetMediaFileSystemsFunction::GetAndReturnGalleries, this); 164 &MediaGalleriesGetMediaFileSystemsFunction::GetAndReturnGalleries, this);
181 new chrome::MediaGalleriesDialogController(tab_contents, *GetExtension(), cb); 165 new chrome::MediaGalleriesDialogController(contents, *GetExtension(), cb);
182 } 166 }
183 167
184 // MediaGalleriesAssembleMediaFileFunction ------------------------------------- 168 // MediaGalleriesAssembleMediaFileFunction -------------------------------------
185 169
186 MediaGalleriesAssembleMediaFileFunction:: 170 MediaGalleriesAssembleMediaFileFunction::
187 ~MediaGalleriesAssembleMediaFileFunction() {} 171 ~MediaGalleriesAssembleMediaFileFunction() {}
188 172
189 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { 173 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() {
190 if (!ApiIsAccessible(&error_)) 174 if (!ApiIsAccessible(&error_))
191 return false; 175 return false;
192 176
193 // TODO(vandebo) Update the metadata and return the new file. 177 // TODO(vandebo) Update the metadata and return the new file.
194 SetResult(Value::CreateNullValue()); 178 SetResult(Value::CreateNullValue());
195 return true; 179 return true;
196 } 180 }
197 181
198 } // namespace extensions 182 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media_gallery/media_galleries_dialog_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698