Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / webui / media_router / media_router_dialog_controller.h
blob96b1fe0f4db89523be31df8a0a1b0865cbb00af7
1 // Copyright 2015 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_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H_
8 #include "base/macros.h"
9 #include "content/public/browser/web_contents_observer.h"
10 #include "content/public/browser/web_contents_user_data.h"
12 namespace media_router {
14 // An instance of this class is tied to a WebContents known as the initiator,
15 // and is lazily created when a Media Router dialog needs to be shown.
16 // The MediaRouterDialogController allows creating, querying, and removing a
17 // Media Router dialog modal to the initiator WebContents.
18 // This class is not thread safe and must be called on the UI thread.
19 class MediaRouterDialogController
20 : public content::WebContentsUserData<MediaRouterDialogController> {
21 public:
22 ~MediaRouterDialogController() override;
24 // Shows the media router dialog modal to the initiator WebContents.
25 // Creates the dialog if it did not exist prior to this call.
26 // If the dialog already exists, brings the dialog to the front.
27 // Returns WebContents for the media router dialog.
28 content::WebContents* ShowMediaRouterDialog();
30 // Returns the media router dialog WebContents.
31 // Returns nullptr if there is no dialog.
32 content::WebContents* GetMediaRouterDialog() const;
34 // Closes the media router dialog. This will destroy the dialog WebContents.
35 // It is an error to call this function if there is currently no dialog.
36 void CloseMediaRouterDialog();
38 private:
39 class DialogWebContentsObserver;
40 class InitiatorWebContentsObserver;
41 friend class content::WebContentsUserData<MediaRouterDialogController>;
43 // Use MediaRouterDialogController::CreateForWebContents() to create an
44 // instance.
45 explicit MediaRouterDialogController(content::WebContents* web_contents);
47 // Creates a new media router dialog modal to |initiator_|.
48 // Returns the WebContents of the newly created dialog.
49 content::WebContents* CreateMediaRouterDialog();
51 // Removes WebContentsObservers for the initiator and dialog WebContents.
52 void RemoveObservers();
54 // Invoked when the dialog WebContents has navigated.
55 void OnDialogNavigated(const content::LoadCommittedDetails& details);
57 scoped_ptr<InitiatorWebContentsObserver> initiator_observer_;
58 scoped_ptr<DialogWebContentsObserver> dialog_observer_;
60 content::WebContents* const initiator_;
62 // True if the controller is waiting for a new media router dialog to be
63 // created.
64 bool media_router_dialog_pending_;
66 base::ThreadChecker thread_checker_;
68 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogController);
71 } // namespace media_router
73 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H_