OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/api/execute_code_function.h" | 5 #include "chrome/browser/extensions/api/execute_code_function.h" |
6 | 6 |
7 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 7 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
8 #include "chrome/browser/extensions/image_loader.h" | 8 #include "chrome/browser/extensions/image_loader.h" |
9 #include "chrome/browser/extensions/script_executor.h" | 9 #include "chrome/browser/extensions/script_executor.h" |
10 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" | 10 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 ScriptExecutor::ScriptType script_type = ScriptExecutor::JAVASCRIPT; | 118 ScriptExecutor::ScriptType script_type = ScriptExecutor::JAVASCRIPT; |
119 if (ShouldInsertCSS()) | 119 if (ShouldInsertCSS()) |
120 script_type = ScriptExecutor::CSS; | 120 script_type = ScriptExecutor::CSS; |
121 | 121 |
122 ScriptExecutor::FrameScope frame_scope = | 122 ScriptExecutor::FrameScope frame_scope = |
123 details_->all_frames.get() && *details_->all_frames ? | 123 details_->all_frames.get() && *details_->all_frames ? |
124 ScriptExecutor::ALL_FRAMES : | 124 ScriptExecutor::ALL_FRAMES : |
125 ScriptExecutor::TOP_FRAME; | 125 ScriptExecutor::TOP_FRAME; |
126 | 126 |
| 127 bool match_about_blank = |
| 128 details_->matches_about_blank.get() && *details_->matches_about_blank; |
| 129 |
127 UserScript::RunLocation run_at = | 130 UserScript::RunLocation run_at = |
128 UserScript::UNDEFINED; | 131 UserScript::UNDEFINED; |
129 switch (details_->run_at) { | 132 switch (details_->run_at) { |
130 case InjectDetails::RUN_AT_NONE: | 133 case InjectDetails::RUN_AT_NONE: |
131 case InjectDetails::RUN_AT_DOCUMENT_IDLE: | 134 case InjectDetails::RUN_AT_DOCUMENT_IDLE: |
132 run_at = UserScript::DOCUMENT_IDLE; | 135 run_at = UserScript::DOCUMENT_IDLE; |
133 break; | 136 break; |
134 case InjectDetails::RUN_AT_DOCUMENT_START: | 137 case InjectDetails::RUN_AT_DOCUMENT_START: |
135 run_at = UserScript::DOCUMENT_START; | 138 run_at = UserScript::DOCUMENT_START; |
136 break; | 139 break; |
137 case InjectDetails::RUN_AT_DOCUMENT_END: | 140 case InjectDetails::RUN_AT_DOCUMENT_END: |
138 run_at = UserScript::DOCUMENT_END; | 141 run_at = UserScript::DOCUMENT_END; |
139 break; | 142 break; |
140 } | 143 } |
141 CHECK_NE(UserScript::UNDEFINED, run_at); | 144 CHECK_NE(UserScript::UNDEFINED, run_at); |
142 | 145 |
143 executor->ExecuteScript( | 146 executor->ExecuteScript( |
144 extension->id(), | 147 extension->id(), |
145 script_type, | 148 script_type, |
146 code_string, | 149 code_string, |
147 frame_scope, | 150 frame_scope, |
| 151 match_about_blank, |
148 run_at, | 152 run_at, |
149 ScriptExecutor::ISOLATED_WORLD, | 153 ScriptExecutor::ISOLATED_WORLD, |
150 IsWebView() ? ScriptExecutor::WEB_VIEW_PROCESS | 154 IsWebView() ? ScriptExecutor::WEB_VIEW_PROCESS |
151 : ScriptExecutor::DEFAULT_PROCESS, | 155 : ScriptExecutor::DEFAULT_PROCESS, |
152 file_url_, | 156 file_url_, |
153 user_gesture_, | 157 user_gesture_, |
154 has_callback() ? ScriptExecutor::JSON_SERIALIZED_RESULT | 158 has_callback() ? ScriptExecutor::JSON_SERIALIZED_RESULT |
155 : ScriptExecutor::NO_RESULT, | 159 : ScriptExecutor::NO_RESULT, |
156 base::Bind(&ExecuteCodeFunction::OnExecuteCodeFinished, this)); | 160 base::Bind(&ExecuteCodeFunction::OnExecuteCodeFinished, this)); |
157 return true; | 161 return true; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 int32 on_page_id, | 212 int32 on_page_id, |
209 const GURL& on_url, | 213 const GURL& on_url, |
210 const base::ListValue& result) { | 214 const base::ListValue& result) { |
211 if (!error.empty()) | 215 if (!error.empty()) |
212 SetError(error); | 216 SetError(error); |
213 | 217 |
214 SendResponse(error.empty()); | 218 SendResponse(error.empty()); |
215 } | 219 } |
216 | 220 |
217 } // namespace extensions | 221 } // namespace extensions |
OLD | NEW |