OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/toolbar/media_router_action.h" | 5 #include "chrome/browser/ui/toolbar/media_router_action.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/media/router/media_router_dialog_controller.h" |
8 #include "chrome/browser/ui/toolbar/media_router_action_platform_delegate.h" | 9 #include "chrome/browser/ui/toolbar/media_router_action_platform_delegate.h" |
9 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" | 10 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" |
10 #include "chrome/browser/ui/webui/media_router/media_router_dialog_controller_im
pl.h" | |
11 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
12 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
15 #include "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
16 | 16 |
17 using media_router::MediaRouterDialogControllerImpl; | 17 using media_router::MediaRouterDialogController; |
18 | 18 |
19 MediaRouterAction::MediaRouterAction(Browser* browser) | 19 MediaRouterAction::MediaRouterAction(Browser* browser) |
20 : id_("media_router_action"), | 20 : id_("media_router_action"), |
21 name_(l10n_util::GetStringUTF16(IDS_MEDIA_ROUTER_TITLE)), | 21 name_(l10n_util::GetStringUTF16(IDS_MEDIA_ROUTER_TITLE)), |
22 media_router_idle_icon_(ui::ResourceBundle::GetSharedInstance(). | 22 media_router_idle_icon_(ui::ResourceBundle::GetSharedInstance(). |
23 GetImageNamed(IDR_MEDIA_ROUTER_IDLE_ICON)), | 23 GetImageNamed(IDR_MEDIA_ROUTER_IDLE_ICON)), |
24 delegate_(nullptr), | 24 delegate_(nullptr), |
25 platform_delegate_(MediaRouterActionPlatformDelegate::Create(browser)), | 25 platform_delegate_(MediaRouterActionPlatformDelegate::Create(browser)), |
26 contextual_menu_(browser) { | 26 contextual_menu_(browser) { |
27 } | 27 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 content::WebContents* web_contents) const { | 66 content::WebContents* web_contents) const { |
67 return false; | 67 return false; |
68 } | 68 } |
69 | 69 |
70 bool MediaRouterAction::HasPopup( | 70 bool MediaRouterAction::HasPopup( |
71 content::WebContents* web_contents) const { | 71 content::WebContents* web_contents) const { |
72 return true; | 72 return true; |
73 } | 73 } |
74 | 74 |
75 void MediaRouterAction::HidePopup() { | 75 void MediaRouterAction::HidePopup() { |
76 GetMediaRouterDialogController()->CloseMediaRouterDialog(); | 76 GetMediaRouterDialogController()->HideMediaRouterDialog(); |
77 } | 77 } |
78 | 78 |
79 gfx::NativeView MediaRouterAction::GetPopupNativeView() { | 79 gfx::NativeView MediaRouterAction::GetPopupNativeView() { |
80 return nullptr; | 80 return nullptr; |
81 } | 81 } |
82 | 82 |
83 ui::MenuModel* MediaRouterAction::GetContextMenu() { | 83 ui::MenuModel* MediaRouterAction::GetContextMenu() { |
84 return contextual_menu_.menu_model(); | 84 return contextual_menu_.menu_model(); |
85 } | 85 } |
86 | 86 |
87 bool MediaRouterAction::CanDrag() const { | 87 bool MediaRouterAction::CanDrag() const { |
88 return false; | 88 return false; |
89 } | 89 } |
90 | 90 |
91 bool MediaRouterAction::ExecuteAction(bool by_user) { | 91 bool MediaRouterAction::ExecuteAction(bool by_user) { |
92 GetMediaRouterDialogController()->ShowMediaRouterDialog(); | 92 GetMediaRouterDialogController()->ShowMediaRouterDialog(); |
93 if (platform_delegate_) | 93 if (platform_delegate_) |
94 platform_delegate_->CloseOverflowMenuIfOpen(); | 94 platform_delegate_->CloseOverflowMenuIfOpen(); |
95 return true; | 95 return true; |
96 } | 96 } |
97 | 97 |
98 void MediaRouterAction::UpdateState() { | 98 void MediaRouterAction::UpdateState() { |
99 } | 99 } |
100 | 100 |
101 MediaRouterDialogControllerImpl* | 101 MediaRouterDialogController* |
102 MediaRouterAction::GetMediaRouterDialogController() { | 102 MediaRouterAction::GetMediaRouterDialogController() { |
103 DCHECK(delegate_); | 103 DCHECK(delegate_); |
104 content::WebContents* web_contents = delegate_->GetCurrentWebContents(); | 104 content::WebContents* web_contents = delegate_->GetCurrentWebContents(); |
105 DCHECK(web_contents); | 105 DCHECK(web_contents); |
106 return MediaRouterDialogControllerImpl::GetOrCreateForWebContents( | 106 return MediaRouterDialogController::GetOrCreateForWebContents(web_contents); |
107 web_contents); | |
108 } | 107 } |
109 | 108 |
110 bool MediaRouterAction::DisabledClickOpensMenu() const { | 109 bool MediaRouterAction::DisabledClickOpensMenu() const { |
111 return false; | 110 return false; |
112 } | 111 } |
OLD | NEW |