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

Side by Side Diff: chrome/browser/extensions/user_script_master.cc

Issue 334053003: Moves extension_icon_image and image_loader to extensions/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: include fail Created 6 years, 6 months 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 | Annotate | Revision Log
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/extensions/user_script_master.h" 5 #include "chrome/browser/extensions/user_script_master.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/version.h" 13 #include "base/version.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/extensions/extension_util.h" 16 #include "chrome/browser/extensions/extension_util.h"
17 #include "chrome/browser/extensions/image_loader.h"
18 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" 18 #include "chrome/common/extensions/api/i18n/default_locale_handler.h"
20 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" 19 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
21 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
22 #include "content/public/browser/render_process_host.h" 21 #include "content/public/browser/render_process_host.h"
22 #include "extensions/browser/component_extension_resource_manager.h"
23 #include "extensions/browser/content_verifier.h" 23 #include "extensions/browser/content_verifier.h"
24 #include "extensions/browser/extension_registry.h" 24 #include "extensions/browser/extension_registry.h"
25 #include "extensions/browser/extension_system.h" 25 #include "extensions/browser/extension_system.h"
26 #include "extensions/browser/extensions_browser_client.h"
26 #include "extensions/common/file_util.h" 27 #include "extensions/common/file_util.h"
27 #include "extensions/common/message_bundle.h" 28 #include "extensions/common/message_bundle.h"
28 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
29 30
30 using content::BrowserThread; 31 using content::BrowserThread;
32 using extensions::ExtensionsBrowserClient;
31 33
32 namespace extensions { 34 namespace extensions {
33 35
34 // Helper function to parse greasesmonkey headers 36 // Helper function to parse greasesmonkey headers
35 static bool GetDeclarationValue(const base::StringPiece& line, 37 static bool GetDeclarationValue(const base::StringPiece& line,
36 const base::StringPiece& prefix, 38 const base::StringPiece& prefix,
37 std::string* value) { 39 std::string* value) {
38 base::StringPiece::size_type index = line.find(prefix); 40 base::StringPiece::size_type index = line.find(prefix);
39 if (index == base::StringPiece::npos) 41 if (index == base::StringPiece::npos)
40 return false; 42 return false;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 static bool LoadScriptContent(const std::string& extension_id, 196 static bool LoadScriptContent(const std::string& extension_id,
195 UserScript::File* script_file, 197 UserScript::File* script_file,
196 const SubstitutionMap* localization_messages, 198 const SubstitutionMap* localization_messages,
197 ContentVerifier* verifier) { 199 ContentVerifier* verifier) {
198 std::string content; 200 std::string content;
199 const base::FilePath& path = ExtensionResource::GetFilePath( 201 const base::FilePath& path = ExtensionResource::GetFilePath(
200 script_file->extension_root(), script_file->relative_path(), 202 script_file->extension_root(), script_file->relative_path(),
201 ExtensionResource::SYMLINKS_MUST_RESOLVE_WITHIN_ROOT); 203 ExtensionResource::SYMLINKS_MUST_RESOLVE_WITHIN_ROOT);
202 if (path.empty()) { 204 if (path.empty()) {
203 int resource_id; 205 int resource_id;
204 if (extensions::ImageLoader::IsComponentExtensionResource( 206 if (ExtensionsBrowserClient::Get()->GetComponentExtensionResourceManager()->
207 IsComponentExtensionResource(
205 script_file->extension_root(), script_file->relative_path(), 208 script_file->extension_root(), script_file->relative_path(),
206 &resource_id)) { 209 &resource_id)) {
207 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 210 const ResourceBundle& rb = ResourceBundle::GetSharedInstance();
208 content = rb.GetRawDataResource(resource_id).as_string(); 211 content = rb.GetRawDataResource(resource_id).as_string();
209 } else { 212 } else {
210 LOG(WARNING) << "Failed to get file path to " 213 LOG(WARNING) << "Failed to get file path to "
211 << script_file->relative_path().value() << " from " 214 << script_file->relative_path().value() << " from "
212 << script_file->extension_root().value(); 215 << script_file->extension_root().value();
213 return false; 216 return false;
214 } 217 }
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) 524 if (!shared_memory->ShareToProcess(handle, &handle_for_process))
522 return; // This can legitimately fail if the renderer asserts at startup. 525 return; // This can legitimately fail if the renderer asserts at startup.
523 526
524 if (base::SharedMemory::IsHandleValid(handle_for_process)) { 527 if (base::SharedMemory::IsHandleValid(handle_for_process)) {
525 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process, 528 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process,
526 changed_extensions)); 529 changed_extensions));
527 } 530 }
528 } 531 }
529 532
530 } // namespace extensions 533 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/url_request_util.cc ('k') | chrome/browser/ui/app_list/extension_app_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698