[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / views / extensions / extension_dialog.h
blobf7570de7e610a1daa834c0d15db993e19006e4fe
1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_H_
8 #include "base/logging.h"
9 #include "base/memory/ref_counted.h"
10 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h"
12 #include "ui/aura/window.h"
13 #include "ui/gfx/native_widget_types.h"
14 #include "ui/views/window/dialog_delegate.h"
16 class ExtensionDialogObserver;
17 class GURL;
18 class Profile;
20 namespace content {
21 class WebContents;
24 namespace extensions {
25 class ExtensionViewHost;
28 // Modal dialog containing contents provided by an extension.
29 // Dialog is automatically centered in the owning window and has fixed size.
30 // For example, used by the Chrome OS file browser.
31 class ExtensionDialog : public views::DialogDelegate,
32 public content::NotificationObserver,
33 public base::RefCounted<ExtensionDialog> {
34 public:
35 // Create and show a dialog with |url| centered over the provided window.
36 // |parent_window| is the parent window to which the pop-up will be attached.
37 // |profile| is the profile that the extension is registered with.
38 // |web_contents| is the tab that spawned the dialog.
39 // |width| and |height| are the size of the dialog in pixels.
40 static ExtensionDialog* Show(const GURL& url,
41 aura::Window* parent_window,
42 Profile* profile,
43 content::WebContents* web_contents,
44 int width,
45 int height,
46 int min_width,
47 int min_height,
48 const base::string16& title,
49 ExtensionDialogObserver* observer);
51 // Notifies the dialog that the observer has been destroyed and should not
52 // be sent notifications.
53 void ObserverDestroyed();
55 // Focus to the render view if possible.
56 void MaybeFocusRenderView();
58 // Sets the window title.
59 void set_title(const base::string16& title) { window_title_ = title; }
61 // Sets minimum contents size in pixels and makes the window resizable.
62 void SetMinimumContentsSize(int width, int height);
64 extensions::ExtensionViewHost* host() const { return host_.get(); }
66 // views::DialogDelegate override.
67 virtual int GetDialogButtons() const OVERRIDE;
68 virtual bool CanResize() const OVERRIDE;
69 virtual ui::ModalType GetModalType() const OVERRIDE;
70 virtual bool ShouldShowWindowTitle() const OVERRIDE;
71 virtual base::string16 GetWindowTitle() const OVERRIDE;
72 virtual void WindowClosing() OVERRIDE;
73 virtual void DeleteDelegate() OVERRIDE;
74 virtual views::Widget* GetWidget() OVERRIDE;
75 virtual const views::Widget* GetWidget() const OVERRIDE;
76 virtual views::View* GetContentsView() OVERRIDE;
77 virtual bool UseNewStyleForThisDialog() const OVERRIDE;
79 // content::NotificationObserver overrides.
80 virtual void Observe(int type,
81 const content::NotificationSource& source,
82 const content::NotificationDetails& details) OVERRIDE;
84 protected:
85 virtual ~ExtensionDialog();
87 private:
88 friend class base::RefCounted<ExtensionDialog>;
90 // Use Show() to create instances.
91 ExtensionDialog(extensions::ExtensionViewHost* host,
92 ExtensionDialogObserver* observer);
94 void InitWindow(aura::Window* parent_window, int width, int height);
96 // Window Title
97 base::string16 window_title_;
99 // The contained host for the view.
100 scoped_ptr<extensions::ExtensionViewHost> host_;
102 content::NotificationRegistrar registrar_;
104 // The observer of this popup.
105 ExtensionDialogObserver* observer_;
107 DISALLOW_COPY_AND_ASSIGN(ExtensionDialog);
110 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_DIALOG_H_