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 ScriptExecutor::MatchAboutBlank match_about_blank = |
| 128 details_->match_about_blank.get() && *details_->match_about_blank ? |
| 129 ScriptExecutor::MATCH_ABOUT_BLANK : |
| 130 ScriptExecutor::DONT_MATCH_ABOUT_BLANK; |
| 131 |
127 UserScript::RunLocation run_at = | 132 UserScript::RunLocation run_at = |
128 UserScript::UNDEFINED; | 133 UserScript::UNDEFINED; |
129 switch (details_->run_at) { | 134 switch (details_->run_at) { |
130 case InjectDetails::RUN_AT_NONE: | 135 case InjectDetails::RUN_AT_NONE: |
131 case InjectDetails::RUN_AT_DOCUMENT_IDLE: | 136 case InjectDetails::RUN_AT_DOCUMENT_IDLE: |
132 run_at = UserScript::DOCUMENT_IDLE; | 137 run_at = UserScript::DOCUMENT_IDLE; |
133 break; | 138 break; |
134 case InjectDetails::RUN_AT_DOCUMENT_START: | 139 case InjectDetails::RUN_AT_DOCUMENT_START: |
135 run_at = UserScript::DOCUMENT_START; | 140 run_at = UserScript::DOCUMENT_START; |
136 break; | 141 break; |
137 case InjectDetails::RUN_AT_DOCUMENT_END: | 142 case InjectDetails::RUN_AT_DOCUMENT_END: |
138 run_at = UserScript::DOCUMENT_END; | 143 run_at = UserScript::DOCUMENT_END; |
139 break; | 144 break; |
140 } | 145 } |
141 CHECK_NE(UserScript::UNDEFINED, run_at); | 146 CHECK_NE(UserScript::UNDEFINED, run_at); |
142 | 147 |
143 executor->ExecuteScript( | 148 executor->ExecuteScript( |
144 extension->id(), | 149 extension->id(), |
145 script_type, | 150 script_type, |
146 code_string, | 151 code_string, |
147 frame_scope, | 152 frame_scope, |
| 153 match_about_blank, |
148 run_at, | 154 run_at, |
149 ScriptExecutor::ISOLATED_WORLD, | 155 ScriptExecutor::ISOLATED_WORLD, |
150 IsWebView() ? ScriptExecutor::WEB_VIEW_PROCESS | 156 IsWebView() ? ScriptExecutor::WEB_VIEW_PROCESS |
151 : ScriptExecutor::DEFAULT_PROCESS, | 157 : ScriptExecutor::DEFAULT_PROCESS, |
152 GetWebViewSrc(), | 158 GetWebViewSrc(), |
153 file_url_, | 159 file_url_, |
154 user_gesture_, | 160 user_gesture_, |
155 has_callback() ? ScriptExecutor::JSON_SERIALIZED_RESULT | 161 has_callback() ? ScriptExecutor::JSON_SERIALIZED_RESULT |
156 : ScriptExecutor::NO_RESULT, | 162 : ScriptExecutor::NO_RESULT, |
157 base::Bind(&ExecuteCodeFunction::OnExecuteCodeFinished, this)); | 163 base::Bind(&ExecuteCodeFunction::OnExecuteCodeFinished, this)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 int32 on_page_id, | 215 int32 on_page_id, |
210 const GURL& on_url, | 216 const GURL& on_url, |
211 const base::ListValue& result) { | 217 const base::ListValue& result) { |
212 if (!error.empty()) | 218 if (!error.empty()) |
213 SetError(error); | 219 SetError(error); |
214 | 220 |
215 SendResponse(error.empty()); | 221 SendResponse(error.empty()); |
216 } | 222 } |
217 | 223 |
218 } // namespace extensions | 224 } // namespace extensions |
OLD | NEW |