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

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

Issue 11724002: Move ContentScripts out of Extension (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_unref_browser_action
Patch Set: Latest master for CQ Created 7 years, 9 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
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 <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/pickle.h" 14 #include "base/pickle.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "base/version.h" 18 #include "base/version.h"
19 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/extensions/extension_system.h" 20 #include "chrome/browser/extensions/extension_system.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/common/chrome_notification_types.h" 22 #include "chrome/common/chrome_notification_types.h"
23 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" 23 #include "chrome/common/extensions/api/i18n/default_locale_handler.h"
24 #include "chrome/common/extensions/extension.h" 24 #include "chrome/common/extensions/extension.h"
25 #include "chrome/common/extensions/extension_file_util.h" 25 #include "chrome/common/extensions/extension_file_util.h"
26 #include "chrome/common/extensions/extension_set.h" 26 #include "chrome/common/extensions/extension_set.h"
27 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
27 #include "chrome/common/extensions/message_bundle.h" 28 #include "chrome/common/extensions/message_bundle.h"
28 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
29 #include "content/public/browser/render_process_host.h" 30 #include "content/public/browser/render_process_host.h"
30 #include "extensions/common/extension_resource.h" 31 #include "extensions/common/extension_resource.h"
31 32
32 using content::BrowserThread; 33 using content::BrowserThread;
33 34
34 namespace extensions { 35 namespace extensions {
35 36
36 // Helper function to parse greasesmonkey headers 37 // Helper function to parse greasesmonkey headers
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 break; 357 break;
357 case chrome::NOTIFICATION_EXTENSION_LOADED: { 358 case chrome::NOTIFICATION_EXTENSION_LOADED: {
358 // Add any content scripts inside the extension. 359 // Add any content scripts inside the extension.
359 const Extension* extension = 360 const Extension* extension =
360 content::Details<const Extension>(details).ptr(); 361 content::Details<const Extension>(details).ptr();
361 extensions_info_[extension->id()] = 362 extensions_info_[extension->id()] =
362 ExtensionSet::ExtensionPathAndDefaultLocale( 363 ExtensionSet::ExtensionPathAndDefaultLocale(
363 extension->path(), LocaleInfo::GetDefaultLocale(extension)); 364 extension->path(), LocaleInfo::GetDefaultLocale(extension));
364 bool incognito_enabled = extensions::ExtensionSystem::Get(profile_)-> 365 bool incognito_enabled = extensions::ExtensionSystem::Get(profile_)->
365 extension_service()->IsIncognitoEnabled(extension->id()); 366 extension_service()->IsIncognitoEnabled(extension->id());
366 const UserScriptList& scripts = extension->content_scripts(); 367 const UserScriptList& scripts =
368 ContentScriptsInfo::GetContentScripts(extension);
367 for (UserScriptList::const_iterator iter = scripts.begin(); 369 for (UserScriptList::const_iterator iter = scripts.begin();
368 iter != scripts.end(); ++iter) { 370 iter != scripts.end(); ++iter) {
369 user_scripts_.push_back(*iter); 371 user_scripts_.push_back(*iter);
370 user_scripts_.back().set_incognito_enabled(incognito_enabled); 372 user_scripts_.back().set_incognito_enabled(incognito_enabled);
371 } 373 }
372 if (extensions_service_ready_) 374 if (extensions_service_ready_)
373 should_start_load = true; 375 should_start_load = true;
374 break; 376 break;
375 } 377 }
376 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { 378 case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 436
435 base::SharedMemoryHandle handle_for_process; 437 base::SharedMemoryHandle handle_for_process;
436 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) 438 if (!shared_memory->ShareToProcess(handle, &handle_for_process))
437 return; // This can legitimately fail if the renderer asserts at startup. 439 return; // This can legitimately fail if the renderer asserts at startup.
438 440
439 if (base::SharedMemory::IsHandleValid(handle_for_process)) 441 if (base::SharedMemory::IsHandleValid(handle_for_process))
440 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process)); 442 process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process));
441 } 443 }
442 444
443 } // namespace extensions 445 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/user_script_listener.cc ('k') | chrome/browser/profiles/profile_dependency_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698