Chromium Code Reviews| Index: extensions/browser/api/execute_code_function_impl.h |
| diff --git a/extensions/browser/api/execute_code_function_impl.h b/extensions/browser/api/execute_code_function_impl.h |
| index 3a0252b804c17e0a5d04898f7c7d2a7dfc9ffe2d..fd8daf6640e41d6c8f67526042dce4e33dee62d9 100644 |
| --- a/extensions/browser/api/execute_code_function_impl.h |
| +++ b/extensions/browser/api/execute_code_function_impl.h |
| @@ -33,8 +33,7 @@ ExecuteCodeFunction<T>::~ExecuteCodeFunction() { |
| template <typename T> |
| void ExecuteCodeFunction<T>::DidLoadFile(bool success, |
| - const std::string& data) { |
| - |
| + const std::string& data) { |
| if (!success || !details_->file) { |
| DidLoadAndLocalizeFile(success, data); |
| return; |
| @@ -54,13 +53,15 @@ void ExecuteCodeFunction<T>::DidLoadFile(bool success, |
| } |
| content::BrowserThread::PostTask( |
| - content::BrowserThread::FILE, FROM_HERE, |
| - base::Bind(&ExecuteCodeFunction::GetFileURLAndLocalizeCSS, this, |
| - script_type, |
| - data, |
| - extension_id, |
| - extension_path, |
| - extension_default_locale)); |
| + content::BrowserThread::FILE, |
|
Fady Samuel
2014/09/04 20:41:09
Can you make these changes in the ExecuteCodeFunct
|
| + FROM_HERE, |
| + base::Bind(&ExecuteCodeFunction::GetFileURLAndLocalizeCSS, |
| + this, |
| + script_type, |
| + data, |
| + extension_id, |
| + extension_path, |
| + extension_default_locale)); |
| } |
| template <typename T> |
| @@ -70,11 +71,9 @@ void ExecuteCodeFunction<T>::GetFileURLAndLocalizeCSS( |
| const std::string& extension_id, |
| const base::FilePath& extension_path, |
| const std::string& extension_default_locale) { |
| - |
| std::string localized_data = data; |
| // Check if the file is CSS and needs localization. |
| - if ((script_type == ScriptExecutor::CSS) && |
| - !extension_id.empty() && |
| + if ((script_type == ScriptExecutor::CSS) && !extension_id.empty() && |
| (data.find(MessageBundle::kMessageBegin) != std::string::npos)) { |
| scoped_ptr<SubstitutionMap> localization_messages( |
| file_util::LoadMessageBundleSubstitutionMap( |
| @@ -82,9 +81,8 @@ void ExecuteCodeFunction<T>::GetFileURLAndLocalizeCSS( |
| // We need to do message replacement on the data, so it has to be mutable. |
| std::string error; |
| - MessageBundle::ReplaceMessagesWithExternalDictionary(*localization_messages, |
| - &localized_data, |
| - &error); |
| + MessageBundle::ReplaceMessagesWithExternalDictionary( |
| + *localization_messages, &localized_data, &error); |
| } |
| file_url_ = net::FilePathToFileURL(resource_.GetFilePath()); |
| @@ -93,21 +91,25 @@ void ExecuteCodeFunction<T>::GetFileURLAndLocalizeCSS( |
| // is always true, because if loading had failed, we wouldn't have had |
| // anything to localize. |
| content::BrowserThread::PostTask( |
| - content::BrowserThread::UI, FROM_HERE, |
| - base::Bind(&ExecuteCodeFunction::DidLoadAndLocalizeFile, this, |
| - true, localized_data)); |
| + content::BrowserThread::UI, |
| + FROM_HERE, |
| + base::Bind(&ExecuteCodeFunction::DidLoadAndLocalizeFile, |
| + this, |
| + true, |
| + localized_data)); |
| } |
| template <typename T> |
| void ExecuteCodeFunction<T>::DidLoadAndLocalizeFile(bool success, |
| - const std::string& data) { |
| + const std::string& data) { |
| if (success) { |
| if (!Execute(data)) |
| T::SendResponse(false); |
| } else { |
| // TODO(viettrungluu): bug: there's no particular reason the path should be |
| // UTF-8, in which case this may fail. |
| - T::error_ = ErrorUtils::FormatErrorMessage(tabs_constants::kLoadFileError, |
| + T::error_ = ErrorUtils::FormatErrorMessage( |
| + tabs_constants::kLoadFileError, |
| resource_.relative_path().AsUTF8Unsafe()); |
| T::SendResponse(false); |
| } |
| @@ -127,17 +129,16 @@ bool ExecuteCodeFunction<T>::Execute(const std::string& code_string) { |
| script_type = ScriptExecutor::CSS; |
| ScriptExecutor::FrameScope frame_scope = |
| - details_->all_frames.get() && *details_->all_frames ? |
| - ScriptExecutor::ALL_FRAMES : |
| - ScriptExecutor::TOP_FRAME; |
| + details_->all_frames.get() && *details_->all_frames |
| + ? ScriptExecutor::ALL_FRAMES |
| + : ScriptExecutor::TOP_FRAME; |
| ScriptExecutor::MatchAboutBlank match_about_blank = |
| - details_->match_about_blank.get() && *details_->match_about_blank ? |
| - ScriptExecutor::MATCH_ABOUT_BLANK : |
| - ScriptExecutor::DONT_MATCH_ABOUT_BLANK; |
| + details_->match_about_blank.get() && *details_->match_about_blank |
| + ? ScriptExecutor::MATCH_ABOUT_BLANK |
| + : ScriptExecutor::DONT_MATCH_ABOUT_BLANK; |
| - UserScript::RunLocation run_at = |
| - UserScript::UNDEFINED; |
| + UserScript::RunLocation run_at = UserScript::UNDEFINED; |
| switch (details_->run_at) { |
| case InjectDetails::RUN_AT_NONE: |
| case InjectDetails::RUN_AT_DOCUMENT_IDLE: |
| @@ -205,10 +206,11 @@ bool ExecuteCodeFunction<T>::RunAsync() { |
| } |
| int resource_id; |
| - if (ExtensionsBrowserClient::Get()->GetComponentExtensionResourceManager()-> |
| - IsComponentExtensionResource( |
| - resource_.extension_root(), resource_.relative_path(), |
| - &resource_id)) { |
| + if (ExtensionsBrowserClient::Get() |
| + ->GetComponentExtensionResourceManager() |
| + ->IsComponentExtensionResource(resource_.extension_root(), |
| + resource_.relative_path(), |
| + &resource_id)) { |
| const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| DidLoadFile(true, rb.GetRawDataResource(resource_id).as_string()); |
| } else { |
| @@ -239,4 +241,3 @@ bool ExecuteCodeFunction<T>::ValidationFailure(T* function) { |
| } // namespace extensions |
| #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ |
| - |