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 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" | 5 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handle
r.h" | 24 #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handle
r.h" |
25 #include "chrome/common/extensions/api/file_manager_private.h" | 25 #include "chrome/common/extensions/api/file_manager_private.h" |
26 #include "chromeos/chromeos_switches.h" | 26 #include "chromeos/chromeos_switches.h" |
27 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/browser/child_process_security_policy.h" | 28 #include "content/public/browser/child_process_security_policy.h" |
29 #include "content/public/browser/render_process_host.h" | 29 #include "content/public/browser/render_process_host.h" |
30 #include "content/public/browser/site_instance.h" | 30 #include "content/public/browser/site_instance.h" |
31 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
32 #include "extensions/browser/event_router.h" | 32 #include "extensions/browser/event_router.h" |
33 #include "extensions/browser/extension_host.h" | 33 #include "extensions/browser/extension_host.h" |
| 34 #include "extensions/browser/extension_registry.h" |
34 #include "extensions/browser/extension_system.h" | 35 #include "extensions/browser/extension_system.h" |
35 #include "extensions/browser/extension_util.h" | 36 #include "extensions/browser/extension_util.h" |
36 #include "extensions/browser/lazy_background_task_queue.h" | 37 #include "extensions/browser/lazy_background_task_queue.h" |
37 #include "extensions/common/extension_set.h" | 38 #include "extensions/common/extension_set.h" |
38 #include "extensions/common/manifest_handlers/background_info.h" | 39 #include "extensions/common/manifest_handlers/background_info.h" |
39 #include "extensions/common/url_pattern.h" | 40 #include "extensions/common/url_pattern.h" |
40 #include "net/base/escape.h" | 41 #include "net/base/escape.h" |
41 #include "storage/browser/fileapi/file_system_context.h" | 42 #include "storage/browser/fileapi/file_system_context.h" |
42 #include "storage/browser/fileapi/file_system_url.h" | 43 #include "storage/browser/fileapi/file_system_url.h" |
43 #include "storage/common/fileapi/file_system_info.h" | 44 #include "storage/common/fileapi/file_system_info.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 net::UnescapeURLComponent(str, net::UnescapeRule::NORMAL)); | 97 net::UnescapeURLComponent(str, net::UnescapeRule::NORMAL)); |
97 return net::EscapeUrlEncodedData( | 98 return net::EscapeUrlEncodedData( |
98 base::UTF16ToUTF8(base::i18n::ToLower(utf16)), | 99 base::UTF16ToUTF8(base::i18n::ToLower(utf16)), |
99 false /* do not replace space with plus */); | 100 false /* do not replace space with plus */); |
100 } | 101 } |
101 | 102 |
102 // Finds file browser handlers that can handle the |selected_file_url|. | 103 // Finds file browser handlers that can handle the |selected_file_url|. |
103 FileBrowserHandlerList FindFileBrowserHandlersForURL( | 104 FileBrowserHandlerList FindFileBrowserHandlersForURL( |
104 Profile* profile, | 105 Profile* profile, |
105 const GURL& selected_file_url) { | 106 const GURL& selected_file_url) { |
106 ExtensionService* service = | 107 extensions::ExtensionRegistry* registry = |
107 extensions::ExtensionSystem::Get(profile)->extension_service(); | 108 extensions::ExtensionRegistry::Get(profile); |
108 // In unit-tests, we may not have an ExtensionService. | 109 // In unit-tests, we may not have an ExtensionRegistry. |
109 if (!service) | 110 if (!registry) |
110 return FileBrowserHandlerList(); | 111 return FileBrowserHandlerList(); |
111 | 112 |
112 // We need case-insensitive matching, and pattern in the handler is already | 113 // We need case-insensitive matching, and pattern in the handler is already |
113 // in lower case. | 114 // in lower case. |
114 const GURL lowercase_url(EscapedUtf8ToLower(selected_file_url.spec())); | 115 const GURL lowercase_url(EscapedUtf8ToLower(selected_file_url.spec())); |
115 | 116 |
116 FileBrowserHandlerList results; | 117 FileBrowserHandlerList results; |
117 for (extensions::ExtensionSet::const_iterator iter = | 118 for (const scoped_refptr<const Extension>& extension : |
118 service->extensions()->begin(); | 119 registry->enabled_extensions()) { |
119 iter != service->extensions()->end(); ++iter) { | |
120 const Extension* extension = iter->get(); | |
121 if (profile->IsOffTheRecord() && | 120 if (profile->IsOffTheRecord() && |
122 !extensions::util::IsIncognitoEnabled(extension->id(), profile)) | 121 !extensions::util::IsIncognitoEnabled(extension->id(), profile)) |
123 continue; | 122 continue; |
124 if (extensions::util::IsEphemeralApp(extension->id(), profile)) | 123 if (extensions::util::IsEphemeralApp(extension->id(), profile)) |
125 continue; | 124 continue; |
126 | 125 |
127 FileBrowserHandler::List* handler_list = | 126 FileBrowserHandler::List* handler_list = |
128 FileBrowserHandler::GetHandlers(extension); | 127 FileBrowserHandler::GetHandlers(extension.get()); |
129 if (!handler_list) | 128 if (!handler_list) |
130 continue; | 129 continue; |
131 for (FileBrowserHandler::List::const_iterator handler_iter = | 130 for (FileBrowserHandler::List::const_iterator handler_iter = |
132 handler_list->begin(); | 131 handler_list->begin(); |
133 handler_iter != handler_list->end(); | 132 handler_iter != handler_list->end(); |
134 ++handler_iter) { | 133 ++handler_iter) { |
135 const FileBrowserHandler* handler = handler_iter->get(); | 134 const FileBrowserHandler* handler = handler_iter->get(); |
136 if (!handler->MatchesURL(lowercase_url)) | 135 if (!handler->MatchesURL(lowercase_url)) |
137 continue; | 136 continue; |
138 // Filter out Files app from handling ZIP files via a handler, as it's | 137 // Filter out Files app from handling ZIP files via a handler, as it's |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 if (common_handlers.empty()) | 529 if (common_handlers.empty()) |
531 return FileBrowserHandlerList(); | 530 return FileBrowserHandlerList(); |
532 } | 531 } |
533 } | 532 } |
534 | 533 |
535 return common_handlers; | 534 return common_handlers; |
536 } | 535 } |
537 | 536 |
538 } // namespace file_browser_handlers | 537 } // namespace file_browser_handlers |
539 } // namespace file_manager | 538 } // namespace file_manager |
OLD | NEW |