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

Side by Side Diff: chrome/browser/extensions/api/execute_code_function.cc

Issue 226663003: Allow content script insertion on about:-URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address reviewer's comments (matches->match) Created 6 years, 8 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) 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
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 file_url_, 158 file_url_,
153 user_gesture_, 159 user_gesture_,
154 has_callback() ? ScriptExecutor::JSON_SERIALIZED_RESULT 160 has_callback() ? ScriptExecutor::JSON_SERIALIZED_RESULT
155 : ScriptExecutor::NO_RESULT, 161 : ScriptExecutor::NO_RESULT,
156 base::Bind(&ExecuteCodeFunction::OnExecuteCodeFinished, this)); 162 base::Bind(&ExecuteCodeFunction::OnExecuteCodeFinished, this));
157 return true; 163 return true;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 int32 on_page_id, 214 int32 on_page_id,
209 const GURL& on_url, 215 const GURL& on_url,
210 const base::ListValue& result) { 216 const base::ListValue& result) {
211 if (!error.empty()) 217 if (!error.empty())
212 SetError(error); 218 SetError(error);
213 219
214 SendResponse(error.empty()); 220 SendResponse(error.empty());
215 } 221 }
216 222
217 } // namespace extensions 223 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698