[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / web_contents_modal_dialog_manager_cocoa.mm
blobf284c5b47b1c33a9f350c8b566ee092c960263d0
1 // Copyright (c) 2013 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.
5 #include "components/web_modal/web_contents_modal_dialog_manager.h"
7 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h"
8 #include "components/web_modal/single_web_contents_dialog_manager.h"
10 using web_modal::NativeWebContentsModalDialog;
12 namespace {
14 class NativeWebContentsModalDialogManagerCocoa
15     : public web_modal::SingleWebContentsDialogManager {
16  public:
17   NativeWebContentsModalDialogManagerCocoa(
18       NativeWebContentsModalDialog dialog)
19       : dialog_(dialog) {
20   }
22   virtual ~NativeWebContentsModalDialogManagerCocoa() {
23   }
25   // SingleWebContentsDialogManager overrides
26   virtual void Show() OVERRIDE {
27     GetConstrainedWindowMac(dialog())->ShowWebContentsModalDialog();
28   }
30   virtual void Hide() OVERRIDE {
31   }
33   virtual void Close() OVERRIDE {
34     GetConstrainedWindowMac(dialog())->CloseWebContentsModalDialog();
35   }
37   virtual void Focus() OVERRIDE {
38     GetConstrainedWindowMac(dialog())->FocusWebContentsModalDialog();
39   }
41   virtual void Pulse() OVERRIDE {
42     GetConstrainedWindowMac(dialog())->PulseWebContentsModalDialog();
43   }
45   virtual void HostChanged(
46       web_modal::WebContentsModalDialogHost* new_host) OVERRIDE {
47   }
49   virtual NativeWebContentsModalDialog dialog() OVERRIDE {
50     return dialog_;
51   }
53  private:
54   static ConstrainedWindowMac* GetConstrainedWindowMac(
55       NativeWebContentsModalDialog dialog) {
56     return static_cast<ConstrainedWindowMac*>(dialog);
57   }
59   // In mac this is a pointer to a ConstrainedWindowMac.
60   // TODO(gbillock): Replace this casting system with a more typesafe call path.
61   NativeWebContentsModalDialog dialog_;
63   DISALLOW_COPY_AND_ASSIGN(NativeWebContentsModalDialogManagerCocoa);
66 }  // namespace
68 namespace web_modal {
70 SingleWebContentsDialogManager*
71     WebContentsModalDialogManager::CreateNativeWebModalManager(
72         NativeWebContentsModalDialog dialog,
73         SingleWebContentsDialogManagerDelegate* native_delegate) {
74   return new NativeWebContentsModalDialogManagerCocoa(dialog);
77 }  // namespace web_modal