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

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: fix / remove component_extension_resource_manager 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"
23 #include "extensions/browser/content_verifier.h" 22 #include "extensions/browser/content_verifier.h"
24 #include "extensions/browser/extension_registry.h" 23 #include "extensions/browser/extension_registry.h"
25 #include "extensions/browser/extension_system.h" 24 #include "extensions/browser/extension_system.h"
25 #include "extensions/browser/extensions_browser_client.h"
26 #include "extensions/common/file_util.h" 26 #include "extensions/common/file_util.h"
27 #include "extensions/common/message_bundle.h" 27 #include "extensions/common/message_bundle.h"
28 #include "ui/base/resource/resource_bundle.h" 28 #include "ui/base/resource/resource_bundle.h"
29 29
30 using content::BrowserThread; 30 using content::BrowserThread;
31 using extensions::ExtensionsBrowserClient;
31 32
32 namespace extensions { 33 namespace extensions {
33 34
34 // Helper function to parse greasesmonkey headers 35 // Helper function to parse greasesmonkey headers
35 static bool GetDeclarationValue(const base::StringPiece& line, 36 static bool GetDeclarationValue(const base::StringPiece& line,
36 const base::StringPiece& prefix, 37 const base::StringPiece& prefix,
37 std::string* value) { 38 std::string* value) {
38 base::StringPiece::size_type index = line.find(prefix); 39 base::StringPiece::size_type index = line.find(prefix);
39 if (index == base::StringPiece::npos) 40 if (index == base::StringPiece::npos)
40 return false; 41 return false;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 static bool LoadScriptContent(const std::string& extension_id, 195 static bool LoadScriptContent(const std::string& extension_id,
195 UserScript::File* script_file, 196 UserScript::File* script_file,
196 const SubstitutionMap* localization_messages, 197 const SubstitutionMap* localization_messages,
197 ContentVerifier* verifier) { 198 ContentVerifier* verifier) {
198 std::string content; 199 std::string content;
199 const base::FilePath& path = ExtensionResource::GetFilePath( 200 const base::FilePath& path = ExtensionResource::GetFilePath(
200 script_file->extension_root(), script_file->relative_path(), 201 script_file->extension_root(), script_file->relative_path(),
201 ExtensionResource::SYMLINKS_MUST_RESOLVE_WITHIN_ROOT); 202 ExtensionResource::SYMLINKS_MUST_RESOLVE_WITHIN_ROOT);
202 if (path.empty()) { 203 if (path.empty()) {
203 int resource_id; 204 int resource_id;
204 if (extensions::ImageLoader::IsComponentExtensionResource( 205 if (ExtensionsBrowserClient::Get()->IsComponentExtensionResource(
205 script_file->extension_root(), script_file->relative_path(), 206 script_file->extension_root(), script_file->relative_path(),
206 &resource_id)) { 207 &resource_id)) {
207 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 208 const ResourceBundle& rb = ResourceBundle::GetSharedInstance();
208 content = rb.GetRawDataResource(resource_id).as_string(); 209 content = rb.GetRawDataResource(resource_id).as_string();
209 } else { 210 } else {
210 LOG(WARNING) << "Failed to get file path to " 211 LOG(WARNING) << "Failed to get file path to "
211 << script_file->relative_path().value() << " from " 212 << script_file->relative_path().value() << " from "
212 << script_file->extension_root().value(); 213 << script_file->extension_root().value();
213 return false; 214 return false;
214 } 215 }
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) 522 if (!shared_memory->ShareToProcess(handle, &handle_for_process))
522 return; // This can legitimately fail if the renderer asserts at startup. 523 return; // This can legitimately fail if the renderer asserts at startup.
523 524
524 if (base::SharedMemory::IsHandleValid(handle_for_process)) { 525 if (base::SharedMemory::IsHandleValid(handle_for_process)) {
525 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process, 526 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process,
526 changed_extensions)); 527 changed_extensions));
527 } 528 }
528 } 529 }
529 530
530 } // namespace extensions 531 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698