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

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

Issue 133273029: Move LanguageState to the translate component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 11 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
OLDNEW
(Empty)
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.
4
5 #include "components/translate/content/browser/content_translate_client.h"
6
7 #include "components/translate/content/browser/language_state_observer.h"
8 #include "content/public/browser/navigation_controller.h"
9 #include "content/public/browser/navigation_details.h"
10 #include "content/public/browser/navigation_entry.h"
11
12 ContentTranslateClient::ContentTranslateClient(
13 content::NavigationController* nav_controller)
14 : navigation_controller_(nav_controller),
15 language_state_observer_(NULL) {
16 }
17
18 ContentTranslateClient::~ContentTranslateClient() {}
19
20 void ContentTranslateClient::SetLanguageStateObserver(
21 LanguageStateObserver* observer) {
22 language_state_observer_ = observer;
23 }
24
25 void ContentTranslateClient::DidNavigate(
26 const content::LoadCommittedDetails& details) {
27 const bool reload =
28 details.entry->GetTransitionType() == content::PAGE_TRANSITION_RELOAD ||
29 details.type == content::NAVIGATION_TYPE_SAME_PAGE;
30 language_state_.DidNavigate(
31 details.is_in_page, details.is_main_frame, reload);
32 }
33
34 // TranslateClient methods
35
36 bool ContentTranslateClient::IsLinkNavigation() {
37 return navigation_controller_ &&
38 navigation_controller_->GetActiveEntry() &&
39 navigation_controller_->GetActiveEntry()->GetTransitionType() ==
40 content::PAGE_TRANSITION_LINK;
41 }
42
43 void ContentTranslateClient::OnTranslateEnabledChanged() {
44 if (language_state_observer_) {
45 content::WebContents* web_contents =
46 navigation_controller_->GetWebContents();
47 language_state_observer_->OnTranslateEnabledChanged(web_contents);
48 }
49 }
50
51 void ContentTranslateClient::OnIsPageTranslatedChanged() {
52 if (language_state_observer_) {
53 content::WebContents* web_contents =
54 navigation_controller_->GetWebContents();
55 language_state_observer_->OnIsPageTranslatedChanged(web_contents);
56 }
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698