1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/browser_language_state_observer.h"
7 #include "chrome/browser/tab_contents/language_state.h"
8 #include "chrome/browser/translate/translate_tab_helper.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_window.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 BrowserLanguageStateObserver::BrowserLanguageStateObserver(Browser
* browser
)
17 BrowserLanguageStateObserver::~BrowserLanguageStateObserver() {
20 void BrowserLanguageStateObserver::OnIsPageTranslatedChanged(
21 content::WebContents
* source
) {
22 if (source
== browser_
->tab_strip_model()->GetActiveWebContents()) {
23 TranslateTabHelper
* translate_tab_helper
=
24 TranslateTabHelper::FromWebContents(source
);
25 LanguageState
& language_state
= translate_tab_helper
->language_state();
26 browser_
->window()->SetTranslateIconToggled(
27 language_state
.IsPageTranslated());
31 void BrowserLanguageStateObserver::OnTranslateEnabledChanged(
32 content::WebContents
* source
) {
33 if (source
== browser_
->tab_strip_model()->GetActiveWebContents())
34 browser_
->window()->UpdateToolbar(source
);