Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/translate/content/browser/content_translate_driver.h" | 5 #include "components/translate/content/browser/content_translate_driver.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "components/translate/content/common/translate_messages.h" | 8 #include "components/translate/content/common/translate_messages.h" |
| 9 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
| 10 #include "content/public/browser/navigation_controller.h" | 10 #include "content/public/browser/navigation_controller.h" |
| 11 #include "content/public/browser/navigation_details.h" | 11 #include "content/public/browser/navigation_details.h" |
| 12 #include "content/public/browser/navigation_entry.h" | 12 #include "content/public/browser/navigation_entry.h" |
| 13 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "url/gurl.h" | |
| 15 | 16 |
| 16 ContentTranslateDriver::ContentTranslateDriver( | 17 ContentTranslateDriver::ContentTranslateDriver( |
| 17 content::NavigationController* nav_controller) | 18 content::NavigationController* nav_controller) |
| 18 : navigation_controller_(nav_controller), | 19 : navigation_controller_(nav_controller), |
| 19 language_state_(this), | 20 language_state_(this), |
| 20 observer_(NULL) { | 21 observer_(NULL) { |
| 21 DCHECK(navigation_controller_); | 22 DCHECK(navigation_controller_); |
| 22 } | 23 } |
| 23 | 24 |
| 24 ContentTranslateDriver::~ContentTranslateDriver() {} | 25 ContentTranslateDriver::~ContentTranslateDriver() {} |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 } | 87 } |
| 87 | 88 |
| 88 content::WebContents* web_contents = navigation_controller_->GetWebContents(); | 89 content::WebContents* web_contents = navigation_controller_->GetWebContents(); |
| 89 web_contents->GetRenderViewHost()->Send(new ChromeViewMsg_RevertTranslation( | 90 web_contents->GetRenderViewHost()->Send(new ChromeViewMsg_RevertTranslation( |
| 90 web_contents->GetRenderViewHost()->GetRoutingID(), entry->GetPageID())); | 91 web_contents->GetRenderViewHost()->GetRoutingID(), entry->GetPageID())); |
| 91 } | 92 } |
| 92 | 93 |
| 93 bool ContentTranslateDriver::IsOffTheRecord() { | 94 bool ContentTranslateDriver::IsOffTheRecord() { |
| 94 return navigation_controller_->GetBrowserContext()->IsOffTheRecord(); | 95 return navigation_controller_->GetBrowserContext()->IsOffTheRecord(); |
| 95 } | 96 } |
| 97 | |
| 98 const std::string& ContentTranslateDriver::GetContentsMimeType() { | |
| 99 return navigation_controller_->GetWebContents()->GetContentsMimeType(); | |
| 100 } | |
| 101 | |
| 102 const GURL& ContentTranslateDriver::GetLastCommittedURL() { | |
| 103 return navigation_controller_->GetWebContents()->GetLastCommittedURL(); | |
| 104 } | |
| 105 | |
| 106 const GURL& ContentTranslateDriver::GetActiveURL() { | |
| 107 content::NavigationEntry* entry = navigation_controller_->GetActiveEntry(); | |
|
droger
2014/04/08 12:01:28
Not sure if we can do something about it, but GetA
blundell
2014/04/08 12:46:02
The problem is that GetActiveEntry() and GetVisibl
droger
2014/04/08 13:01:21
Yes it does answer my question. Thanks.
| |
| 108 if (!entry) | |
| 109 return GURL::EmptyGURL(); | |
| 110 return entry->GetURL(); | |
| 111 } | |
| 112 | |
| 113 const GURL& ContentTranslateDriver::GetVisibleURL() { | |
| 114 return navigation_controller_->GetWebContents()->GetVisibleURL(); | |
| 115 } | |
| 116 | |
| 117 bool ContentTranslateDriver::HasCurrentPage() { | |
| 118 return (navigation_controller_->GetActiveEntry() != NULL); | |
| 119 } | |
| 120 | |
| 121 int ContentTranslateDriver::GetCurrentPageID() { | |
| 122 DCHECK(HasCurrentPage()); | |
| 123 content::NavigationEntry* entry = navigation_controller_->GetActiveEntry(); | |
| 124 return entry->GetPageID(); | |
| 125 } | |
| OLD | NEW |