Chromium Code Reviews| Index: chrome/browser/ui/toolbar/media_router_action_controller.h |
| diff --git a/chrome/browser/ui/toolbar/media_router_action_controller.h b/chrome/browser/ui/toolbar/media_router_action_controller.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b810198bd8c628212c2e7bf35d2ce399c1d7c1d6 |
| --- /dev/null |
| +++ b/chrome/browser/ui/toolbar/media_router_action_controller.h |
| @@ -0,0 +1,79 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_ |
| +#define CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_ |
| + |
| +#include <memory> |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "chrome/browser/extensions/component_migration_helper.h" |
| +#include "chrome/browser/media/router/issues_observer.h" |
| +#include "chrome/browser/media/router/media_routes_observer.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "components/prefs/pref_change_registrar.h" |
| + |
| +using extensions::ComponentMigrationHelper; |
| + |
| +class Profile; |
| + |
| +// Controller for MediaRouterAction that determines when to show and hide the |
| +// action icon on the toolbar. There should be one instance of this class per |
| +// profile, and it should only be used on the UI thread. |
| +class MediaRouterActionController : public media_router::IssuesObserver, |
| + public media_router::MediaRoutesObserver { |
| + public: |
| + explicit MediaRouterActionController(Profile* profile); |
| + // Constructor for injecting dependencies in tests. |
|
imcheng
2016/09/13 23:13:10
nit: blank line before comment
takumif
2016/09/14 04:00:52
Moving the ctor to private.
|
| + MediaRouterActionController( |
|
imcheng
2016/09/13 23:13:10
nit: consider moving this ctor to private and addi
takumif
2016/09/14 04:00:52
Done.
|
| + Profile* profile, |
| + media_router::MediaRouter* router, |
| + ComponentMigrationHelper::ComponentActionDelegate* |
| + component_action_delegate, |
| + ComponentMigrationHelper* component_migration_helper); |
| + ~MediaRouterActionController() override; |
| + |
| + // media_router::IssuesObserver: |
| + void OnIssueUpdated(const media_router::Issue* issue) override; |
| + |
| + // media_router::MediaRoutesObserver: |
| + void OnRoutesUpdated(const std::vector<media_router::MediaRoute>& routes, |
| + const std::vector<media_router::MediaRoute::Id>& |
| + joinable_route_ids) override; |
| + |
| + private: |
| + FRIEND_TEST_ALL_PREFIXES(MediaRouterActionControllerUnitTest, EphemeralIcon); |
| + |
| + // Adds or removes the Media Router action icon to/from |
| + // |component_action_delegate_| if necessary, depending on whether or not |
| + // we have issues or local routes. |
| + void MaybeAddOrRemoveAction(); |
| + |
| + // Returns ture if the Media Router action should be present on the toolbar |
|
imcheng
2016/09/13 23:13:10
s/ture/|true|
takumif
2016/09/14 04:00:52
Oops. Replaced.
|
| + // or the overflow menu. |
| + bool IsActionEnabled(); |
|
imcheng
2016/09/13 23:13:10
const
takumif
2016/09/14 04:00:52
Done.
|
| + |
| + // The profile |this| is associated with. There should be one instance of this |
| + // class per profile. |
| + Profile* const profile_; |
| + |
| + // The delegate that is responsible for showing and hiding the icon on the |
| + // toolbar. It is a KeyedService and outlives |this|. |
| + ComponentMigrationHelper::ComponentActionDelegate* const |
| + component_action_delegate_; |
| + |
| + // Responsible for changing the pref to always show or hide component actions. |
| + // It is owned by ToolbarActionsModel and outlives |this|. |
| + ComponentMigrationHelper* const component_migration_helper_; |
| + |
| + bool has_issue_; |
| + bool has_local_display_route_; |
| + |
| + PrefChangeRegistrar pref_change_registrar_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MediaRouterActionController); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_UI_TOOLBAR_MEDIA_ROUTER_ACTION_CONTROLLER_H_ |