Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / webui / media_router / media_router_dialog_controller_impl.h
blobc84dd8321ba99254d736eaf4c40b4eb358ad14db
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_IMPL_H_
6 #define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_IMPL_H_
8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/media/router/media_router_dialog_controller.h"
11 #include "content/public/browser/web_contents_observer.h"
12 #include "content/public/browser/web_contents_user_data.h"
14 FORWARD_DECLARE_TEST(MediaRouterActionUnitTest, IconPressedState);
16 class MediaRouterAction;
18 namespace media_router {
20 namespace {
21 class MediaRouterDialogDelegate;
24 // A desktop implementation of MediaRouterDialogController.
25 // This class is not thread safe and must be called on the UI thread.
26 class MediaRouterDialogControllerImpl :
27 public content::WebContentsUserData<MediaRouterDialogControllerImpl>,
28 public MediaRouterDialogController {
29 public:
30 ~MediaRouterDialogControllerImpl() override;
32 static MediaRouterDialogControllerImpl* GetOrCreateForWebContents(
33 content::WebContents* web_contents);
35 // Returns the media router dialog WebContents.
36 // Returns nullptr if there is no dialog.
37 content::WebContents* GetMediaRouterDialog() const;
39 // |action| must always be non-null.
40 void SetMediaRouterAction(const base::WeakPtr<MediaRouterAction>& action);
42 // MediaRouterDialogController:
43 bool IsShowingMediaRouterDialog() const override;
45 private:
46 class DialogWebContentsObserver;
47 friend class content::WebContentsUserData<MediaRouterDialogControllerImpl>;
48 FRIEND_TEST_ALL_PREFIXES(::MediaRouterActionUnitTest, IconPressedState);
50 // Use MediaRouterDialogControllerImpl::CreateForWebContents() to create an
51 // instance.
52 explicit MediaRouterDialogControllerImpl(content::WebContents* web_contents);
54 // MediaRouterDialogController:
55 void CreateMediaRouterDialog() override;
56 void CloseMediaRouterDialog() override;
57 void Reset() override;
59 // Invoked when the dialog WebContents has navigated.
60 void OnDialogNavigated(const content::LoadCommittedDetails& details);
62 void PopulateDialog(content::WebContents* media_router_dialog);
64 scoped_ptr<DialogWebContentsObserver> dialog_observer_;
66 // True if the controller is waiting for a new media router dialog to be
67 // created.
68 bool media_router_dialog_pending_;
70 base::WeakPtr<MediaRouterAction> action_;
72 DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogControllerImpl);
75 } // namespace media_router
77 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_IMPL_H_