| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/translate/translate_bubble_factory.h" | 5 #include "chrome/browser/ui/translate/translate_bubble_factory.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/browser_finder.h" | 7 #include "chrome/browser/ui/browser_finder.h" |
| 8 #include "chrome/browser/ui/browser_window.h" | 8 #include "chrome/browser/ui/browser_window.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 void ShowDefault(BrowserWindow* window, | 12 ShowTranslateBubbleResult ShowDefault( |
| 13 content::WebContents* web_contents, | 13 BrowserWindow* window, |
| 14 translate::TranslateStep step, | 14 content::WebContents* web_contents, |
| 15 translate::TranslateErrors::Type error_type) { | 15 translate::TranslateStep step, |
| 16 translate::TranslateErrors::Type error_type) { |
| 16 // |window| might be null when testing. | 17 // |window| might be null when testing. |
| 17 if (!window) | 18 if (!window) |
| 18 return; | 19 return ShowTranslateBubbleResult::BROWSER_WINDOW_NOT_VALID; |
| 19 window->ShowTranslateBubble(web_contents, step, error_type, false); | 20 return window->ShowTranslateBubble(web_contents, step, error_type, false); |
| 20 } | 21 } |
| 21 | 22 |
| 22 } // namespace | 23 } // namespace |
| 23 | 24 |
| 24 TranslateBubbleFactory::~TranslateBubbleFactory() { | 25 TranslateBubbleFactory::~TranslateBubbleFactory() { |
| 25 } | 26 } |
| 26 | 27 |
| 27 // static | 28 // static |
| 28 void TranslateBubbleFactory::Show(BrowserWindow* window, | 29 ShowTranslateBubbleResult TranslateBubbleFactory::Show( |
| 29 content::WebContents* web_contents, | 30 BrowserWindow* window, |
| 30 translate::TranslateStep step, | 31 content::WebContents* web_contents, |
| 31 translate::TranslateErrors::Type error_type) { | 32 translate::TranslateStep step, |
| 33 translate::TranslateErrors::Type error_type) { |
| 32 if (current_factory_) { | 34 if (current_factory_) { |
| 33 current_factory_->ShowImplementation( | 35 return current_factory_->ShowImplementation(window, web_contents, step, |
| 34 window, web_contents, step, error_type); | 36 error_type); |
| 35 return; | |
| 36 } | 37 } |
| 37 | 38 |
| 38 ShowDefault(window, web_contents, step, error_type); | 39 return ShowDefault(window, web_contents, step, error_type); |
| 39 } | 40 } |
| 40 | 41 |
| 41 // static | 42 // static |
| 42 void TranslateBubbleFactory::SetFactory(TranslateBubbleFactory* factory) { | 43 void TranslateBubbleFactory::SetFactory(TranslateBubbleFactory* factory) { |
| 43 current_factory_ = factory; | 44 current_factory_ = factory; |
| 44 } | 45 } |
| 45 | 46 |
| 46 // static | 47 // static |
| 47 TranslateBubbleFactory* TranslateBubbleFactory::current_factory_ = NULL; | 48 TranslateBubbleFactory* TranslateBubbleFactory::current_factory_ = NULL; |
| OLD | NEW |