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/extensions/file_handler_util.h" | 5 #include "chrome/browser/chromeos/extensions/file_handler_util.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 string16 utf16 = UTF8ToUTF16( | 151 string16 utf16 = UTF8ToUTF16( |
152 net::UnescapeURLComponent(str, net::UnescapeRule::NORMAL)); | 152 net::UnescapeURLComponent(str, net::UnescapeRule::NORMAL)); |
153 return net::EscapeUrlEncodedData( | 153 return net::EscapeUrlEncodedData( |
154 UTF16ToUTF8(base::i18n::ToLower(utf16)), | 154 UTF16ToUTF8(base::i18n::ToLower(utf16)), |
155 false /* do not replace space with plus */); | 155 false /* do not replace space with plus */); |
156 } | 156 } |
157 | 157 |
158 bool GetFileBrowserHandlers(Profile* profile, | 158 bool GetFileBrowserHandlers(Profile* profile, |
159 const GURL& selected_file_url, | 159 const GURL& selected_file_url, |
160 FileBrowserHandlerSet* results) { | 160 FileBrowserHandlerSet* results) { |
161 ExtensionService* service = profile->GetExtensionService(); | 161 ExtensionService* service = |
| 162 extensions::ExtensionSystem::Get(profile)->extension_service(); |
162 if (!service) | 163 if (!service) |
163 return false; // In unit-tests, we may not have an ExtensionService. | 164 return false; // In unit-tests, we may not have an ExtensionService. |
164 | 165 |
165 // We need case-insensitive matching, and pattern in the handler is already | 166 // We need case-insensitive matching, and pattern in the handler is already |
166 // in lower case. | 167 // in lower case. |
167 const GURL lowercase_url(EscapedUtf8ToLower(selected_file_url.spec())); | 168 const GURL lowercase_url(EscapedUtf8ToLower(selected_file_url.spec())); |
168 | 169 |
169 for (ExtensionSet::const_iterator iter = service->extensions()->begin(); | 170 for (ExtensionSet::const_iterator iter = service->extensions()->begin(); |
170 iter != service->extensions()->end(); | 171 iter != service->extensions()->end(); |
171 ++iter) { | 172 ++iter) { |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 // only place where it is used (DriveTaskExecutor::OnAppAuthorized) | 639 // only place where it is used (DriveTaskExecutor::OnAppAuthorized) |
639 Browser* FileTaskExecutor::GetBrowser() const { | 640 Browser* FileTaskExecutor::GetBrowser() const { |
640 return browser::FindOrCreateTabbedBrowser( | 641 return browser::FindOrCreateTabbedBrowser( |
641 profile_ ? profile_ : ProfileManager::GetDefaultProfileOrOffTheRecord(), | 642 profile_ ? profile_ : ProfileManager::GetDefaultProfileOrOffTheRecord(), |
642 chrome::HOST_DESKTOP_TYPE_ASH); | 643 chrome::HOST_DESKTOP_TYPE_ASH); |
643 } | 644 } |
644 | 645 |
645 const Extension* FileTaskExecutor::GetExtension() { | 646 const Extension* FileTaskExecutor::GetExtension() { |
646 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 647 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
647 | 648 |
648 ExtensionService* service = profile()->GetExtensionService(); | 649 ExtensionService* service = |
| 650 extensions::ExtensionSystem::Get(profile())->extension_service(); |
649 return service ? service->GetExtensionById(extension_id_, false) : | 651 return service ? service->GetExtensionById(extension_id_, false) : |
650 NULL; | 652 NULL; |
651 } | 653 } |
652 | 654 |
653 ExtensionTaskExecutor::FileDefinition::FileDefinition() : is_directory(false) { | 655 ExtensionTaskExecutor::FileDefinition::FileDefinition() : is_directory(false) { |
654 } | 656 } |
655 | 657 |
656 ExtensionTaskExecutor::FileDefinition::~FileDefinition() { | 658 ExtensionTaskExecutor::FileDefinition::~FileDefinition() { |
657 } | 659 } |
658 | 660 |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 if (!external_provider || !external_provider->IsAccessAllowed(url)) | 1137 if (!external_provider || !external_provider->IsAccessAllowed(url)) |
1136 return false; | 1138 return false; |
1137 | 1139 |
1138 FilePath local_path = url.path(); | 1140 FilePath local_path = url.path(); |
1139 extensions::LaunchPlatformAppWithFileHandler(profile(), GetExtension(), | 1141 extensions::LaunchPlatformAppWithFileHandler(profile(), GetExtension(), |
1140 action_id_, local_path); | 1142 action_id_, local_path); |
1141 return true; | 1143 return true; |
1142 } | 1144 } |
1143 | 1145 |
1144 } // namespace file_handler_util | 1146 } // namespace file_handler_util |
OLD | NEW |