| OLD | NEW |
| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 } | 23 } |
| 24 | 24 |
| 25 void UserScriptSetManager::AddObserver(Observer* observer) { | 25 void UserScriptSetManager::AddObserver(Observer* observer) { |
| 26 observers_.AddObserver(observer); | 26 observers_.AddObserver(observer); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void UserScriptSetManager::RemoveObserver(Observer* observer) { | 29 void UserScriptSetManager::RemoveObserver(Observer* observer) { |
| 30 observers_.RemoveObserver(observer); | 30 observers_.RemoveObserver(observer); |
| 31 } | 31 } |
| 32 | 32 |
| 33 scoped_ptr<ScriptInjection> | 33 std::unique_ptr<ScriptInjection> |
| 34 UserScriptSetManager::GetInjectionForDeclarativeScript( | 34 UserScriptSetManager::GetInjectionForDeclarativeScript( |
| 35 int script_id, | 35 int script_id, |
| 36 content::RenderFrame* render_frame, | 36 content::RenderFrame* render_frame, |
| 37 int tab_id, | 37 int tab_id, |
| 38 const GURL& url, | 38 const GURL& url, |
| 39 const std::string& extension_id) { | 39 const std::string& extension_id) { |
| 40 UserScriptSet* user_script_set = | 40 UserScriptSet* user_script_set = |
| 41 GetProgrammaticScriptsByHostID(HostID(HostID::EXTENSIONS, extension_id)); | 41 GetProgrammaticScriptsByHostID(HostID(HostID::EXTENSIONS, extension_id)); |
| 42 if (!user_script_set) | 42 if (!user_script_set) |
| 43 return scoped_ptr<ScriptInjection>(); | 43 return std::unique_ptr<ScriptInjection>(); |
| 44 | 44 |
| 45 return user_script_set->GetDeclarativeScriptInjection( | 45 return user_script_set->GetDeclarativeScriptInjection( |
| 46 script_id, | 46 script_id, |
| 47 render_frame, | 47 render_frame, |
| 48 tab_id, | 48 tab_id, |
| 49 UserScript::BROWSER_DRIVEN, | 49 UserScript::BROWSER_DRIVEN, |
| 50 url); | 50 url); |
| 51 } | 51 } |
| 52 | 52 |
| 53 bool UserScriptSetManager::OnControlMessageReceived( | 53 bool UserScriptSetManager::OnControlMessageReceived( |
| 54 const IPC::Message& message) { | 54 const IPC::Message& message) { |
| 55 bool handled = true; | 55 bool handled = true; |
| 56 IPC_BEGIN_MESSAGE_MAP(UserScriptSetManager, message) | 56 IPC_BEGIN_MESSAGE_MAP(UserScriptSetManager, message) |
| 57 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateUserScripts, OnUpdateUserScripts) | 57 IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateUserScripts, OnUpdateUserScripts) |
| 58 IPC_MESSAGE_UNHANDLED(handled = false) | 58 IPC_MESSAGE_UNHANDLED(handled = false) |
| 59 IPC_END_MESSAGE_MAP() | 59 IPC_END_MESSAGE_MAP() |
| 60 return handled; | 60 return handled; |
| 61 } | 61 } |
| 62 | 62 |
| 63 void UserScriptSetManager::GetAllInjections( | 63 void UserScriptSetManager::GetAllInjections( |
| 64 std::vector<scoped_ptr<ScriptInjection>>* injections, | 64 std::vector<std::unique_ptr<ScriptInjection>>* injections, |
| 65 content::RenderFrame* render_frame, | 65 content::RenderFrame* render_frame, |
| 66 int tab_id, | 66 int tab_id, |
| 67 UserScript::RunLocation run_location) { | 67 UserScript::RunLocation run_location) { |
| 68 static_scripts_.GetInjections(injections, render_frame, tab_id, run_location); | 68 static_scripts_.GetInjections(injections, render_frame, tab_id, run_location); |
| 69 for (UserScriptSetMap::iterator it = programmatic_scripts_.begin(); | 69 for (UserScriptSetMap::iterator it = programmatic_scripts_.begin(); |
| 70 it != programmatic_scripts_.end(); | 70 it != programmatic_scripts_.end(); |
| 71 ++it) { | 71 ++it) { |
| 72 it->second->GetInjections(injections, render_frame, tab_id, run_location); | 72 it->second->GetInjections(injections, render_frame, tab_id, run_location); |
| 73 } | 73 } |
| 74 } | 74 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 *effective_hosts, | 150 *effective_hosts, |
| 151 whitelisted_only)) { | 151 whitelisted_only)) { |
| 152 FOR_EACH_OBSERVER( | 152 FOR_EACH_OBSERVER( |
| 153 Observer, | 153 Observer, |
| 154 observers_, | 154 observers_, |
| 155 OnUserScriptsUpdated(*effective_hosts, scripts->scripts())); | 155 OnUserScriptsUpdated(*effective_hosts, scripts->scripts())); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace extensions | 159 } // namespace extensions |
| OLD | NEW |