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 "components/translate/core/browser/translate_script.h" | 5 #include "components/translate/core/browser/translate_script.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 fetcher_->set_extra_request_header(kRequestHeader); | 111 fetcher_->set_extra_request_header(kRequestHeader); |
112 fetcher_->Request( | 112 fetcher_->Request( |
113 translate_script_url, | 113 translate_script_url, |
114 base::Bind(&TranslateScript::OnScriptFetchComplete, | 114 base::Bind(&TranslateScript::OnScriptFetchComplete, |
115 base::Unretained(this))); | 115 base::Unretained(this))); |
116 } | 116 } |
117 | 117 |
118 | 118 |
119 void TranslateScript::OnScriptFetchComplete( | 119 void TranslateScript::OnScriptFetchComplete( |
120 int id, bool success, const std::string& data) { | 120 int id, bool success, const std::string& data) { |
121 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422577 is fixed. | |
122 tracked_objects::ScopedTracker tracking_profile( | |
123 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
124 "422577 TranslateScript::OnScriptFetchComplete")); | |
125 | |
126 DCHECK_EQ(kFetcherId, id); | 121 DCHECK_EQ(kFetcherId, id); |
127 | 122 |
128 scoped_ptr<const TranslateURLFetcher> delete_ptr(fetcher_.release()); | 123 scoped_ptr<const TranslateURLFetcher> delete_ptr(fetcher_.release()); |
129 | 124 |
130 if (success) { | 125 if (success) { |
131 DCHECK(data_.empty()); | 126 DCHECK(data_.empty()); |
132 // Insert variable definitions on API Key and security origin. | 127 // Insert variable definitions on API Key and security origin. |
133 data_ = base::StringPrintf("var translateApiKey = '%s';\n", | 128 data_ = base::StringPrintf("var translateApiKey = '%s';\n", |
134 google_apis::GetAPIKey().c_str()); | 129 google_apis::GetAPIKey().c_str()); |
135 | 130 |
(...skipping 19 matching lines...) Expand all Loading... |
155 | 150 |
156 for (RequestCallbackList::iterator it = callback_list_.begin(); | 151 for (RequestCallbackList::iterator it = callback_list_.begin(); |
157 it != callback_list_.end(); | 152 it != callback_list_.end(); |
158 ++it) { | 153 ++it) { |
159 it->Run(success, data); | 154 it->Run(success, data); |
160 } | 155 } |
161 callback_list_.clear(); | 156 callback_list_.clear(); |
162 } | 157 } |
163 | 158 |
164 } // namespace translate | 159 } // namespace translate |
OLD | NEW |