Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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) { | |
| 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 } | |
|
Avi (use Gerrit)
2012/10/14 18:26:53
This code made no sense. Shell windows have TabCon
jennb
2012/10/15 16:42:33
ShellWindows aren't supposed to have TabContents.
Avi (use Gerrit)
2012/10/15 16:45:06
Oh, so this code predates that.
Does this look re
jennb
2012/10/15 17:08:17
Looks reasonable to me as no TabContents are neede
Avi (use Gerrit)
2012/10/15 17:39:48
That's exactly the point ;)
| |
| 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 |
| OLD | NEW |