| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // An observer that keeps track of whether a navigation entry was committed. | 56 // An observer that keeps track of whether a navigation entry was committed. |
| 57 class NavEntryCommittedObserver : public content::NotificationObserver { | 57 class NavEntryCommittedObserver : public content::NotificationObserver { |
| 58 public: | 58 public: |
| 59 explicit NavEntryCommittedObserver(content::WebContents* web_contents) { | 59 explicit NavEntryCommittedObserver(content::WebContents* web_contents) { |
| 60 registrar_.Add(this, | 60 registrar_.Add(this, |
| 61 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 61 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 62 content::Source<content::NavigationController>( | 62 content::Source<content::NavigationController>( |
| 63 &web_contents->GetController())); | 63 &web_contents->GetController())); |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual void Observe(int type, | 66 void Observe(int type, |
| 67 const content::NotificationSource& source, | 67 const content::NotificationSource& source, |
| 68 const content::NotificationDetails& details) override { | 68 const content::NotificationDetails& details) override { |
| 69 DCHECK(type == content::NOTIFICATION_NAV_ENTRY_COMMITTED); | 69 DCHECK(type == content::NOTIFICATION_NAV_ENTRY_COMMITTED); |
| 70 details_ = | 70 details_ = |
| 71 *(content::Details<content::LoadCommittedDetails>(details).ptr()); | 71 *(content::Details<content::LoadCommittedDetails>(details).ptr()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 const content::LoadCommittedDetails& load_committed_details() const { | 74 const content::LoadCommittedDetails& load_committed_details() const { |
| 75 return details_; | 75 return details_; |
| 76 } | 76 } |
| 77 | 77 |
| 78 private: | 78 private: |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 // WARNING: the pointers point to deleted objects, use only for comparison. | 362 // WARNING: the pointers point to deleted objects, use only for comparison. |
| 363 std::set<infobars::InfoBarDelegate*> removed_infobars_; | 363 std::set<infobars::InfoBarDelegate*> removed_infobars_; |
| 364 | 364 |
| 365 DISALLOW_COPY_AND_ASSIGN(TranslateManagerRenderViewHostTest); | 365 DISALLOW_COPY_AND_ASSIGN(TranslateManagerRenderViewHostTest); |
| 366 }; | 366 }; |
| 367 | 367 |
| 368 class MockTranslateBubbleFactory : public TranslateBubbleFactory { | 368 class MockTranslateBubbleFactory : public TranslateBubbleFactory { |
| 369 public: | 369 public: |
| 370 MockTranslateBubbleFactory() {} | 370 MockTranslateBubbleFactory() {} |
| 371 | 371 |
| 372 virtual void ShowImplementation( | 372 void ShowImplementation( |
| 373 BrowserWindow* window, | 373 BrowserWindow* window, |
| 374 content::WebContents* web_contents, | 374 content::WebContents* web_contents, |
| 375 translate::TranslateStep step, | 375 translate::TranslateStep step, |
| 376 translate::TranslateErrors::Type error_type) override { | 376 translate::TranslateErrors::Type error_type) override { |
| 377 if (model_) { | 377 if (model_) { |
| 378 model_->SetViewState( | 378 model_->SetViewState( |
| 379 TranslateBubbleModelImpl::TranslateStepToViewState(step)); | 379 TranslateBubbleModelImpl::TranslateStepToViewState(step)); |
| 380 return; | 380 return; |
| 381 } | 381 } |
| 382 | 382 |
| (...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1671 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE, 0); | 1671 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE, 0); |
| 1672 | 1672 |
| 1673 // Check the bubble exists instead of the infobar. | 1673 // Check the bubble exists instead of the infobar. |
| 1674 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 1674 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
| 1675 ASSERT_TRUE(infobar == NULL); | 1675 ASSERT_TRUE(infobar == NULL); |
| 1676 TranslateBubbleModel* bubble = factory->model(); | 1676 TranslateBubbleModel* bubble = factory->model(); |
| 1677 ASSERT_TRUE(bubble != NULL); | 1677 ASSERT_TRUE(bubble != NULL); |
| 1678 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, | 1678 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, |
| 1679 bubble->GetViewState()); | 1679 bubble->GetViewState()); |
| 1680 } | 1680 } |
| OLD | NEW |