Chromium Code Reviews| 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/ui/browser.h" | |
|
Devlin
2015/07/14 17:23:02
Doesn't actually look like you need this.
apacible
2015/07/14 21:15:23
Forgot to remove this while cleaning up, done.
| |
| 8 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" | 9 #include "chrome/browser/ui/toolbar/toolbar_action_view_delegate.h" |
| 9 #include "chrome/browser/ui/webui/media_router/media_router_dialog_controller.h" | 10 #include "chrome/browser/ui/webui/media_router/media_router_dialog_controller.h" |
| 10 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
| 11 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 13 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 14 #include "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
| 15 | 16 |
| 16 using media_router::MediaRouterDialogController; | 17 using media_router::MediaRouterDialogController; |
| 17 | 18 |
| 18 MediaRouterAction::MediaRouterAction() | 19 MediaRouterAction::MediaRouterAction(Browser* browser) |
| 19 : id_("media_router_action"), | 20 : id_("media_router_action"), |
| 20 name_(l10n_util::GetStringUTF16(IDS_MEDIA_ROUTER_TITLE)), | 21 name_(l10n_util::GetStringUTF16(IDS_MEDIA_ROUTER_TITLE)), |
| 21 media_router_idle_icon_(ui::ResourceBundle::GetSharedInstance(). | 22 media_router_idle_icon_(ui::ResourceBundle::GetSharedInstance(). |
| 22 GetImageNamed(IDR_MEDIA_ROUTER_IDLE_ICON)), | 23 GetImageNamed(IDR_MEDIA_ROUTER_IDLE_ICON)), |
| 23 delegate_(nullptr) { | 24 delegate_(nullptr), |
| 25 #if defined(OS_MACOSX) | |
| 26 platform_delegate_(nullptr) { | |
| 27 #else | |
| 28 platform_delegate_(MediaRouterActionPlatformDelegate::Create(browser)) { | |
| 29 #endif | |
| 24 } | 30 } |
| 25 | 31 |
| 26 MediaRouterAction::~MediaRouterAction() { | 32 MediaRouterAction::~MediaRouterAction() { |
| 27 } | 33 } |
| 28 | 34 |
| 29 const std::string& MediaRouterAction::GetId() const { | 35 const std::string& MediaRouterAction::GetId() const { |
| 30 return id_; | 36 return id_; |
| 31 } | 37 } |
| 32 | 38 |
| 33 void MediaRouterAction::SetDelegate(ToolbarActionViewDelegate* delegate) { | 39 void MediaRouterAction::SetDelegate(ToolbarActionViewDelegate* delegate) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 ui::MenuModel* MediaRouterAction::GetContextMenu() { | 86 ui::MenuModel* MediaRouterAction::GetContextMenu() { |
| 81 return nullptr; | 87 return nullptr; |
| 82 } | 88 } |
| 83 | 89 |
| 84 bool MediaRouterAction::CanDrag() const { | 90 bool MediaRouterAction::CanDrag() const { |
| 85 return false; | 91 return false; |
| 86 } | 92 } |
| 87 | 93 |
| 88 bool MediaRouterAction::ExecuteAction(bool by_user) { | 94 bool MediaRouterAction::ExecuteAction(bool by_user) { |
| 89 GetMediaRouterDialogController()->ShowMediaRouterDialog(); | 95 GetMediaRouterDialogController()->ShowMediaRouterDialog(); |
| 96 if (platform_delegate_.get()) | |
| 97 platform_delegate_.get()->CloseOverflowMenu(); | |
|
Devlin
2015/07/14 17:23:02
no need for the .get(). Really, in either the if
apacible
2015/07/14 21:15:23
Done.
| |
| 90 return true; | 98 return true; |
| 91 } | 99 } |
| 92 | 100 |
| 93 void MediaRouterAction::UpdateState() { | 101 void MediaRouterAction::UpdateState() { |
| 94 } | 102 } |
| 95 | 103 |
| 96 MediaRouterDialogController* | 104 MediaRouterDialogController* |
| 97 MediaRouterAction::GetMediaRouterDialogController() { | 105 MediaRouterAction::GetMediaRouterDialogController() { |
| 98 DCHECK(delegate_); | 106 DCHECK(delegate_); |
| 99 content::WebContents* web_contents = delegate_->GetCurrentWebContents(); | 107 content::WebContents* web_contents = delegate_->GetCurrentWebContents(); |
| 100 DCHECK(web_contents); | 108 DCHECK(web_contents); |
| 101 return MediaRouterDialogController::GetOrCreateForWebContents(web_contents); | 109 return MediaRouterDialogController::GetOrCreateForWebContents(web_contents); |
| 102 } | 110 } |
| 103 | 111 |
| 104 bool MediaRouterAction::DisabledClickOpensMenu() const { | 112 bool MediaRouterAction::DisabledClickOpensMenu() const { |
| 105 return false; | 113 return false; |
| 106 } | 114 } |
| OLD | NEW |