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 "apps/app_window.h" | |
14 #include "apps/app_window_registry.h" | |
15 #include "base/callback.h" | 13 #include "base/callback.h" |
16 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
17 #include "base/numerics/safe_conversions.h" | 15 #include "base/numerics/safe_conversions.h" |
18 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
19 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
21 #include "base/values.h" | 19 #include "base/values.h" |
22 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 21 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
24 #include "chrome/browser/extensions/blob_reader.h" | 22 #include "chrome/browser/extensions/blob_reader.h" |
(...skipping 14 matching lines...) Expand all Loading... |
39 #include "chrome/grit/generated_resources.h" | 37 #include "chrome/grit/generated_resources.h" |
40 #include "components/storage_monitor/storage_info.h" | 38 #include "components/storage_monitor/storage_info.h" |
41 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 39 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
42 #include "content/public/browser/blob_handle.h" | 40 #include "content/public/browser/blob_handle.h" |
43 #include "content/public/browser/browser_context.h" | 41 #include "content/public/browser/browser_context.h" |
44 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
45 #include "content/public/browser/child_process_security_policy.h" | 43 #include "content/public/browser/child_process_security_policy.h" |
46 #include "content/public/browser/render_process_host.h" | 44 #include "content/public/browser/render_process_host.h" |
47 #include "content/public/browser/render_view_host.h" | 45 #include "content/public/browser/render_view_host.h" |
48 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
| 47 #include "extensions/browser/app_window/app_window.h" |
| 48 #include "extensions/browser/app_window/app_window_registry.h" |
49 #include "extensions/browser/blob_holder.h" | 49 #include "extensions/browser/blob_holder.h" |
50 #include "extensions/browser/extension_prefs.h" | 50 #include "extensions/browser/extension_prefs.h" |
51 #include "extensions/browser/extension_system.h" | 51 #include "extensions/browser/extension_system.h" |
52 #include "extensions/common/extension.h" | 52 #include "extensions/common/extension.h" |
53 #include "extensions/common/permissions/api_permission.h" | 53 #include "extensions/common/permissions/api_permission.h" |
54 #include "extensions/common/permissions/media_galleries_permission.h" | 54 #include "extensions/common/permissions/media_galleries_permission.h" |
55 #include "extensions/common/permissions/permissions_data.h" | 55 #include "extensions/common/permissions/permissions_data.h" |
56 #include "net/base/mime_sniffer.h" | 56 #include "net/base/mime_sniffer.h" |
57 #include "ui/base/l10n/l10n_util.h" | 57 #include "ui/base/l10n/l10n_util.h" |
58 #include "webkit/browser/blob/blob_data_handle.h" | 58 #include "webkit/browser/blob/blob_data_handle.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 WebContents* GetWebContents(content::RenderViewHost* rvh, | 150 WebContents* GetWebContents(content::RenderViewHost* rvh, |
151 Profile* profile, | 151 Profile* profile, |
152 const std::string& app_id) { | 152 const std::string& app_id) { |
153 WebContents* contents = WebContents::FromRenderViewHost(rvh); | 153 WebContents* contents = WebContents::FromRenderViewHost(rvh); |
154 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 154 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
155 WebContentsModalDialogManager::FromWebContents(contents); | 155 WebContentsModalDialogManager::FromWebContents(contents); |
156 if (!web_contents_modal_dialog_manager) { | 156 if (!web_contents_modal_dialog_manager) { |
157 // If there is no WebContentsModalDialogManager, then this contents is | 157 // If there is no WebContentsModalDialogManager, then this contents is |
158 // probably the background page for an app. Try to find a app window to | 158 // probably the background page for an app. Try to find a app window to |
159 // host the dialog. | 159 // host the dialog. |
160 apps::AppWindow* window = apps::AppWindowRegistry::Get(profile) | 160 AppWindow* window = AppWindowRegistry::Get(profile) |
161 ->GetCurrentAppWindowForApp(app_id); | 161 ->GetCurrentAppWindowForApp(app_id); |
162 contents = window ? window->web_contents() : NULL; | 162 contents = window ? window->web_contents() : NULL; |
163 } | 163 } |
164 return contents; | 164 return contents; |
165 } | 165 } |
166 | 166 |
167 base::ListValue* ConstructFileSystemList( | 167 base::ListValue* ConstructFileSystemList( |
168 content::RenderViewHost* rvh, | 168 content::RenderViewHost* rvh, |
169 const Extension* extension, | 169 const Extension* extension, |
170 const std::vector<MediaFileSystemInfo>& filesystems) { | 170 const std::vector<MediaFileSystemInfo>& filesystems) { |
171 if (!rvh) | 171 if (!rvh) |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 &MediaGalleriesRemoveAllGalleryWatchFunction::OnPreferencesInit, this)); | 1269 &MediaGalleriesRemoveAllGalleryWatchFunction::OnPreferencesInit, this)); |
1270 return true; | 1270 return true; |
1271 } | 1271 } |
1272 | 1272 |
1273 void MediaGalleriesRemoveAllGalleryWatchFunction::OnPreferencesInit() { | 1273 void MediaGalleriesRemoveAllGalleryWatchFunction::OnPreferencesInit() { |
1274 gallery_watch_manager()->RemoveAllWatches(GetProfile(), extension_id()); | 1274 gallery_watch_manager()->RemoveAllWatches(GetProfile(), extension_id()); |
1275 SendResponse(true); | 1275 SendResponse(true); |
1276 } | 1276 } |
1277 | 1277 |
1278 } // namespace extensions | 1278 } // namespace extensions |
OLD | NEW |