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

Side by Side Diff: chrome/browser/chromeos/extensions/file_handler_util.cc

Issue 11365181: Remove GetExtensionService from Profile. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: tweaks Created 8 years, 1 month 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
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 #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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 string16 utf16 = UTF8ToUTF16( 150 string16 utf16 = UTF8ToUTF16(
151 net::UnescapeURLComponent(str, net::UnescapeRule::NORMAL)); 151 net::UnescapeURLComponent(str, net::UnescapeRule::NORMAL));
152 return net::EscapeUrlEncodedData( 152 return net::EscapeUrlEncodedData(
153 UTF16ToUTF8(base::i18n::ToLower(utf16)), 153 UTF16ToUTF8(base::i18n::ToLower(utf16)),
154 false /* do not replace space with plus */); 154 false /* do not replace space with plus */);
155 } 155 }
156 156
157 bool GetFileBrowserHandlers(Profile* profile, 157 bool GetFileBrowserHandlers(Profile* profile,
158 const GURL& selected_file_url, 158 const GURL& selected_file_url,
159 FileBrowserHandlerSet* results) { 159 FileBrowserHandlerSet* results) {
160 ExtensionService* service = profile->GetExtensionService(); 160 ExtensionService* service =
161 extensions::ExtensionSystem::Get(profile)->extension_service();
161 if (!service) 162 if (!service)
162 return false; // In unit-tests, we may not have an ExtensionService. 163 return false; // In unit-tests, we may not have an ExtensionService.
163 164
164 // We need case-insensitive matching, and pattern in the handler is already 165 // We need case-insensitive matching, and pattern in the handler is already
165 // in lower case. 166 // in lower case.
166 const GURL lowercase_url(EscapedUtf8ToLower(selected_file_url.spec())); 167 const GURL lowercase_url(EscapedUtf8ToLower(selected_file_url.spec()));
167 168
168 for (ExtensionSet::const_iterator iter = service->extensions()->begin(); 169 for (ExtensionSet::const_iterator iter = service->extensions()->begin();
169 iter != service->extensions()->end(); 170 iter != service->extensions()->end();
170 ++iter) { 171 ++iter) {
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 // only place where it is used (DriveTaskExecutor::OnAppAuthorized) 610 // only place where it is used (DriveTaskExecutor::OnAppAuthorized)
610 Browser* FileTaskExecutor::GetBrowser() const { 611 Browser* FileTaskExecutor::GetBrowser() const {
611 return browser::FindOrCreateTabbedBrowser( 612 return browser::FindOrCreateTabbedBrowser(
612 profile_ ? profile_ : ProfileManager::GetDefaultProfileOrOffTheRecord(), 613 profile_ ? profile_ : ProfileManager::GetDefaultProfileOrOffTheRecord(),
613 chrome::HOST_DESKTOP_TYPE_ASH); 614 chrome::HOST_DESKTOP_TYPE_ASH);
614 } 615 }
615 616
616 const Extension* FileTaskExecutor::GetExtension() { 617 const Extension* FileTaskExecutor::GetExtension() {
617 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 618 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
618 619
619 ExtensionService* service = profile()->GetExtensionService(); 620 ExtensionService* service =
621 extensions::ExtensionSystem::Get(profile())->extension_service();
620 return service ? service->GetExtensionById(extension_id_, false) : 622 return service ? service->GetExtensionById(extension_id_, false) :
621 NULL; 623 NULL;
622 } 624 }
623 625
624 ExtensionTaskExecutor::FileDefinition::FileDefinition() : is_directory(false) { 626 ExtensionTaskExecutor::FileDefinition::FileDefinition() : is_directory(false) {
625 } 627 }
626 628
627 ExtensionTaskExecutor::FileDefinition::~FileDefinition() { 629 ExtensionTaskExecutor::FileDefinition::~FileDefinition() {
628 } 630 }
629 631
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 // Make sure this url really being used by the right caller extension. 1062 // Make sure this url really being used by the right caller extension.
1061 if (source_url_.GetOrigin() != url.origin()) 1063 if (source_url_.GetOrigin() != url.origin())
1062 return false; 1064 return false;
1063 1065
1064 FilePath local_path = url.path(); 1066 FilePath local_path = url.path();
1065 extensions::LaunchPlatformAppWithPath(profile(), GetExtension(), local_path); 1067 extensions::LaunchPlatformAppWithPath(profile(), GetExtension(), local_path);
1066 return true; 1068 return true;
1067 } 1069 }
1068 1070
1069 } // namespace file_handler_util 1071 } // namespace file_handler_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698