summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/translate/translate_bubble_factory.cc
blob: 8f0bd27c24534b79b55cfe7adf6c9d9181823bb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/translate/translate_bubble_factory.h"

#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"

namespace {

void ShowDefault(BrowserWindow* window,
                 content::WebContents* web_contents,
                 TranslateBubbleModel::ViewState view_state) {
  // |window| might be null when testing.
  if (!window)
    return;
  window->ShowTranslateBubble(web_contents, view_state);
}

}  // namespace

TranslateBubbleFactory::~TranslateBubbleFactory() {
}

// static
void TranslateBubbleFactory::Show(BrowserWindow* window,
                                  content::WebContents* web_contents,
                                  TranslateBubbleModel::ViewState view_state) {
  if (current_factory_) {
    current_factory_->ShowImplementation(window, web_contents, view_state);
    return;
  }

  ShowDefault(window, web_contents, view_state);
}

// static
void TranslateBubbleFactory::SetFactory(TranslateBubbleFactory* factory) {
  current_factory_ = factory;
}

// static
TranslateBubbleFactory* TranslateBubbleFactory::current_factory_ = NULL;