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

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

Issue 133273029: Move LanguageState to the translate component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update BUILD.gn 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_driver.h"
6
7 #include "base/logging.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 ContentTranslateDriver::ContentTranslateDriver(
13 content::NavigationController* nav_controller)
14 : navigation_controller_(nav_controller),
15 language_state_(this),
16 observer_(NULL) {
17 DCHECK(navigation_controller_);
18 }
19
20 ContentTranslateDriver::~ContentTranslateDriver() {}
21
22 void ContentTranslateDriver::DidNavigate(
23 const content::LoadCommittedDetails& details) {
24 const bool reload =
25 details.entry->GetTransitionType() == content::PAGE_TRANSITION_RELOAD ||
26 details.type == content::NAVIGATION_TYPE_SAME_PAGE;
27 language_state_.DidNavigate(
28 details.is_in_page, details.is_main_frame, reload);
29 }
30
31 // TranslateDriver methods
32
33 bool ContentTranslateDriver::IsLinkNavigation() {
34 return navigation_controller_ && navigation_controller_->GetActiveEntry() &&
35 navigation_controller_->GetActiveEntry()->GetTransitionType() ==
36 content::PAGE_TRANSITION_LINK;
37 }
38
39 void ContentTranslateDriver::OnTranslateEnabledChanged() {
40 if (observer_) {
41 content::WebContents* web_contents =
42 navigation_controller_->GetWebContents();
43 observer_->OnTranslateEnabledChanged(web_contents);
44 }
45 }
46
47 void ContentTranslateDriver::OnIsPageTranslatedChanged() {
48 if (observer_) {
49 content::WebContents* web_contents =
50 navigation_controller_->GetWebContents();
51 observer_->OnIsPageTranslatedChanged(web_contents);
52 }
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698