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

Side by Side Diff: components/translate/content/browser/content_translate_driver.cc

Issue 2425603004: Remove usage of FOR_EACH_OBSERVER macro in components/translate (Closed)
Patch Set: rebase Created 4 years, 2 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
« no previous file with comments | « components/bubble/bubble_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/content/browser/content_translate_driver.h" 5 #include "components/translate/content/browser/content_translate_driver.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 return navigation_controller_ && 87 return navigation_controller_ &&
88 navigation_controller_->GetLastCommittedEntry() && 88 navigation_controller_->GetLastCommittedEntry() &&
89 ui::PageTransitionCoreTypeIs( 89 ui::PageTransitionCoreTypeIs(
90 navigation_controller_->GetLastCommittedEntry() 90 navigation_controller_->GetLastCommittedEntry()
91 ->GetTransitionType(), 91 ->GetTransitionType(),
92 ui::PAGE_TRANSITION_LINK); 92 ui::PAGE_TRANSITION_LINK);
93 } 93 }
94 94
95 void ContentTranslateDriver::OnTranslateEnabledChanged() { 95 void ContentTranslateDriver::OnTranslateEnabledChanged() {
96 content::WebContents* web_contents = navigation_controller_->GetWebContents(); 96 content::WebContents* web_contents = navigation_controller_->GetWebContents();
97 FOR_EACH_OBSERVER( 97 for (auto& observer : observer_list_)
98 Observer, observer_list_, OnTranslateEnabledChanged(web_contents)); 98 observer.OnTranslateEnabledChanged(web_contents);
99 } 99 }
100 100
101 void ContentTranslateDriver::OnIsPageTranslatedChanged() { 101 void ContentTranslateDriver::OnIsPageTranslatedChanged() {
102 content::WebContents* web_contents = navigation_controller_->GetWebContents(); 102 content::WebContents* web_contents = navigation_controller_->GetWebContents();
103 FOR_EACH_OBSERVER(Observer, observer_list_, 103 for (auto& observer : observer_list_)
104 OnIsPageTranslatedChanged(web_contents)); 104 observer.OnIsPageTranslatedChanged(web_contents);
105 } 105 }
106 106
107 void ContentTranslateDriver::TranslatePage(int page_seq_no, 107 void ContentTranslateDriver::TranslatePage(int page_seq_no,
108 const std::string& translate_script, 108 const std::string& translate_script,
109 const std::string& source_lang, 109 const std::string& source_lang,
110 const std::string& target_lang) { 110 const std::string& target_lang) {
111 auto it = pages_.find(page_seq_no); 111 auto it = pages_.find(page_seq_no);
112 if (it == pages_.end()) 112 if (it == pages_.end())
113 return; // This page has navigated away. 113 return; // This page has navigated away.
114 114
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 base::Bind(&ContentTranslateDriver::OnPageAway, base::Unretained(this), 231 base::Bind(&ContentTranslateDriver::OnPageAway, base::Unretained(this),
232 next_page_seq_no_)); 232 next_page_seq_no_));
233 translate_manager_->set_current_seq_no(next_page_seq_no_); 233 translate_manager_->set_current_seq_no(next_page_seq_no_);
234 234
235 translate_manager_->GetLanguageState().LanguageDetermined( 235 translate_manager_->GetLanguageState().LanguageDetermined(
236 details.adopted_language, page_needs_translation); 236 details.adopted_language, page_needs_translation);
237 237
238 if (web_contents()) 238 if (web_contents())
239 translate_manager_->InitiateTranslation(details.adopted_language); 239 translate_manager_->InitiateTranslation(details.adopted_language);
240 240
241 FOR_EACH_OBSERVER(Observer, observer_list_, OnLanguageDetermined(details)); 241 for (auto& observer : observer_list_)
242 observer.OnLanguageDetermined(details);
242 } 243 }
243 244
244 void ContentTranslateDriver::OnPageTranslated( 245 void ContentTranslateDriver::OnPageTranslated(
245 bool cancelled, 246 bool cancelled,
246 const std::string& original_lang, 247 const std::string& original_lang,
247 const std::string& translated_lang, 248 const std::string& translated_lang,
248 TranslateErrors::Type error_type) { 249 TranslateErrors::Type error_type) {
249 if (cancelled) 250 if (cancelled)
250 return; 251 return;
251 252
252 translate_manager_->PageTranslated( 253 translate_manager_->PageTranslated(
253 original_lang, translated_lang, error_type); 254 original_lang, translated_lang, error_type);
254 FOR_EACH_OBSERVER( 255 for (auto& observer : observer_list_)
255 Observer, 256 observer.OnPageTranslated(original_lang, translated_lang, error_type);
256 observer_list_,
257 OnPageTranslated(original_lang, translated_lang, error_type));
258 } 257 }
259 258
260 } // namespace translate 259 } // namespace translate
OLDNEW
« no previous file with comments | « components/bubble/bubble_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698