| Index: components/translate/content/browser/content_translate_client.cc
|
| diff --git a/components/translate/content/browser/content_translate_client.cc b/components/translate/content/browser/content_translate_client.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cf3d7bd76b909e33646a988173f92f8f8ef3683e
|
| --- /dev/null
|
| +++ b/components/translate/content/browser/content_translate_client.cc
|
| @@ -0,0 +1,57 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "components/translate/content/browser/content_translate_client.h"
|
| +
|
| +#include "components/translate/content/browser/language_state_observer.h"
|
| +#include "content/public/browser/navigation_controller.h"
|
| +#include "content/public/browser/navigation_details.h"
|
| +#include "content/public/browser/navigation_entry.h"
|
| +
|
| +ContentTranslateClient::ContentTranslateClient(
|
| + content::NavigationController* nav_controller)
|
| + : navigation_controller_(nav_controller),
|
| + language_state_observer_(NULL) {
|
| +}
|
| +
|
| +ContentTranslateClient::~ContentTranslateClient() {}
|
| +
|
| +void ContentTranslateClient::SetLanguageStateObserver(
|
| + LanguageStateObserver* observer) {
|
| + language_state_observer_ = observer;
|
| +}
|
| +
|
| +void ContentTranslateClient::DidNavigate(
|
| + const content::LoadCommittedDetails& details) {
|
| + const bool reload =
|
| + details.entry->GetTransitionType() == content::PAGE_TRANSITION_RELOAD ||
|
| + details.type == content::NAVIGATION_TYPE_SAME_PAGE;
|
| + language_state_.DidNavigate(
|
| + details.is_in_page, details.is_main_frame, reload);
|
| +}
|
| +
|
| +// TranslateClient methods
|
| +
|
| +bool ContentTranslateClient::IsLinkNavigation() {
|
| + return navigation_controller_ &&
|
| + navigation_controller_->GetActiveEntry() &&
|
| + navigation_controller_->GetActiveEntry()->GetTransitionType() ==
|
| + content::PAGE_TRANSITION_LINK;
|
| +}
|
| +
|
| +void ContentTranslateClient::OnTranslateEnabledChanged() {
|
| + if (language_state_observer_) {
|
| + content::WebContents* web_contents =
|
| + navigation_controller_->GetWebContents();
|
| + language_state_observer_->OnTranslateEnabledChanged(web_contents);
|
| + }
|
| +}
|
| +
|
| +void ContentTranslateClient::OnIsPageTranslatedChanged() {
|
| + if (language_state_observer_) {
|
| + content::WebContents* web_contents =
|
| + navigation_controller_->GetWebContents();
|
| + language_state_observer_->OnIsPageTranslatedChanged(web_contents);
|
| + }
|
| +}
|
|
|