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

Side by Side Diff: extensions/renderer/user_script_set_manager.cc

Issue 934763003: Refactoring: de-couple Extensions from "script injection System" [render side]:3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@decouple_brower_isolated_world_routingid_user_script_1
Patch Set: Created 5 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/renderer/user_script_set_manager.h" 5 #include "extensions/renderer/user_script_set_manager.h"
6 6
7 #include "components/crx_file/id_util.h" 7 #include "components/crx_file/id_util.h"
8 #include "content/public/renderer/render_thread.h" 8 #include "content/public/renderer/render_thread.h"
9 #include "extensions/common/extension_messages.h" 9 #include "extensions/common/extension_messages.h"
10 #include "extensions/renderer/dispatcher.h" 10 #include "extensions/renderer/dispatcher.h"
11 #include "extensions/renderer/injection_host.h"
11 #include "extensions/renderer/script_injection.h" 12 #include "extensions/renderer/script_injection.h"
12 #include "extensions/renderer/user_script_set.h" 13 #include "extensions/renderer/user_script_set.h"
13 #include "ipc/ipc_message.h" 14 #include "ipc/ipc_message.h"
14 #include "ipc/ipc_message_macros.h" 15 #include "ipc/ipc_message_macros.h"
15 #include "third_party/WebKit/public/web/WebFrame.h" 16 #include "third_party/WebKit/public/web/WebFrame.h"
16 17
17 namespace extensions { 18 namespace extensions {
18 19
19 UserScriptSetManager::UserScriptSetManager(const ExtensionSet* extensions) 20 UserScriptSetManager::UserScriptSetManager(const ExtensionSet* extensions)
20 : static_scripts_(extensions), extensions_(extensions) { 21 : static_scripts_(extensions), extensions_(extensions) {
(...skipping 10 matching lines...) Expand all
31 void UserScriptSetManager::RemoveObserver(Observer* observer) { 32 void UserScriptSetManager::RemoveObserver(Observer* observer) {
32 observers_.RemoveObserver(observer); 33 observers_.RemoveObserver(observer);
33 } 34 }
34 35
35 scoped_ptr<ScriptInjection> 36 scoped_ptr<ScriptInjection>
36 UserScriptSetManager::GetInjectionForDeclarativeScript( 37 UserScriptSetManager::GetInjectionForDeclarativeScript(
37 int script_id, 38 int script_id,
38 blink::WebFrame* web_frame, 39 blink::WebFrame* web_frame,
39 int tab_id, 40 int tab_id,
40 const GURL& url, 41 const GURL& url,
41 const Extension* extension) { 42 const InjectionHost* injection_host) {
42 UserScriptSet* user_script_set = 43 UserScriptSet* user_script_set =
43 GetProgrammaticScriptsByExtension(extension->id()); 44 GetProgrammaticScriptsByExtension(injection_host->id().id());
44 if (!user_script_set) 45 if (!user_script_set)
45 return scoped_ptr<ScriptInjection>(); 46 return scoped_ptr<ScriptInjection>();
46 47
47 return user_script_set->GetDeclarativeScriptInjection( 48 return user_script_set->GetDeclarativeScriptInjection(
48 script_id, 49 script_id,
49 web_frame, 50 web_frame,
50 tab_id, 51 tab_id,
51 UserScript::BROWSER_DRIVEN, 52 UserScript::BROWSER_DRIVEN,
52 url, 53 url,
53 extension); 54 injection_host);
54 } 55 }
55 56
56 bool UserScriptSetManager::OnControlMessageReceived( 57 bool UserScriptSetManager::OnControlMessageReceived(
57 const IPC::Message& message) { 58 const IPC::Message& message) {
58 bool handled = true; 59 bool handled = true;
59 IPC_BEGIN_MESSAGE_MAP(UserScriptSetManager, message) 60 IPC_BEGIN_MESSAGE_MAP(UserScriptSetManager, message)
60 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateUserScripts, OnUpdateUserScripts) 61 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateUserScripts, OnUpdateUserScripts)
61 IPC_MESSAGE_UNHANDLED(handled = false) 62 IPC_MESSAGE_UNHANDLED(handled = false)
62 IPC_END_MESSAGE_MAP() 63 IPC_END_MESSAGE_MAP()
63 return handled; 64 return handled;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 150
150 if (scripts->UpdateUserScripts(shared_memory, *effective_extensions)) { 151 if (scripts->UpdateUserScripts(shared_memory, *effective_extensions)) {
151 FOR_EACH_OBSERVER( 152 FOR_EACH_OBSERVER(
152 Observer, 153 Observer,
153 observers_, 154 observers_,
154 OnUserScriptsUpdated(*effective_extensions, scripts->scripts())); 155 OnUserScriptsUpdated(*effective_extensions, scripts->scripts()));
155 } 156 }
156 } 157 }
157 158
158 } // namespace extensions 159 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698