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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/browser_content_translate_driver_observer.h"
7 #include "chrome/browser/translate/chrome_translate_client.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_window.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
11 #include "components/translate/core/browser/language_state.h"
13 BrowserContentTranslateDriverObserver::BrowserContentTranslateDriverObserver(
14 Browser
* browser
) : browser_(browser
) {
17 BrowserContentTranslateDriverObserver::
18 ~BrowserContentTranslateDriverObserver() {
21 void BrowserContentTranslateDriverObserver::OnIsPageTranslatedChanged(
22 content::WebContents
* source
) {
23 if (source
== browser_
->tab_strip_model()->GetActiveWebContents()) {
24 ChromeTranslateClient
* chrome_translate_client
=
25 ChromeTranslateClient::FromWebContents(source
);
26 translate::LanguageState
& language_state
=
27 chrome_translate_client
->GetLanguageState();
28 browser_
->window()->SetTranslateIconToggled(
29 language_state
.IsPageTranslated());
33 void BrowserContentTranslateDriverObserver::OnTranslateEnabledChanged(
34 content::WebContents
* source
) {
35 if (source
== browser_
->tab_strip_model()->GetActiveWebContents())
36 browser_
->window()->UpdateToolbar(source
);