| OLD | NEW | 
|   1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |   1 // Copyright (c) 2016 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 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_MEDIA_DEVICES_SELECTION_HANDLER_H_ |   5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_MEDIA_DEVICES_SELECTION_HANDLE
    R_H_ | 
|   6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_MEDIA_DEVICES_SELECTION_HANDLER_H_ |   6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_MEDIA_DEVICES_SELECTION_HANDLE
    R_H_ | 
|   7  |   7  | 
|   8 #include "base/macros.h" |   8 #include "base/macros.h" | 
 |   9 #include "base/scoped_observer.h" | 
|   9 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |  10 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 
|  10 #include "chrome/browser/ui/webui/options/options_ui.h" |  11 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" | 
|  11 #include "content/public/browser/web_contents.h" |  12 #include "content/public/browser/web_contents.h" | 
|  12  |  13  | 
|  13 namespace options { |  14 namespace settings { | 
|  14  |  15  | 
|  15 // Handler for media devices selection in content settings. |  16 // Handler for media devices selection in content settings. | 
|  16 class MediaDevicesSelectionHandler |  17 class MediaDevicesSelectionHandler | 
|  17     : public MediaCaptureDevicesDispatcher::Observer, |  18     : public MediaCaptureDevicesDispatcher::Observer, | 
|  18       public OptionsPageUIHandler { |  19       public SettingsPageUIHandler { | 
|  19  public: |  20  public: | 
|  20   MediaDevicesSelectionHandler(); |  21   explicit MediaDevicesSelectionHandler(Profile* profile); | 
|  21   ~MediaDevicesSelectionHandler() override; |  22   ~MediaDevicesSelectionHandler() override; | 
|  22  |  23  | 
|  23   // OptionsPageUIHandler implementation. |  24   // SettingsPageUIHandler: | 
|  24   void GetLocalizedValues(base::DictionaryValue* values) override; |  25   void OnJavascriptAllowed() override; | 
|  25   void InitializePage() override; |  26   void OnJavascriptDisallowed() override; | 
|  26   void RegisterMessages() override; |  27   void RegisterMessages() override; | 
|  27  |  28  | 
|  28   // MediaCaptureDevicesDispatcher::Observer implementation. |  29   // MediaCaptureDevicesDispatcher::Observer: | 
|  29   void OnUpdateAudioDevices( |  30   void OnUpdateAudioDevices( | 
|  30       const content::MediaStreamDevices& devices) override; |  31       const content::MediaStreamDevices& devices) override; | 
|  31   void OnUpdateVideoDevices( |  32   void OnUpdateVideoDevices( | 
|  32       const content::MediaStreamDevices& devices) override; |  33       const content::MediaStreamDevices& devices) override; | 
|  33  |  34  | 
|  34  private: |  35  private: | 
|  35   enum DeviceType { |  36   enum DeviceType { | 
|  36     AUDIO, |  37     AUDIO, | 
|  37     VIDEO, |  38     VIDEO, | 
|  38   }; |  39   }; | 
|  39  |  40  | 
 |  41   // Fetches the list of default capture devices. | 
 |  42   void GetDefaultCaptureDevices(const base::ListValue* args); | 
 |  43  | 
|  40   // Sets the default audio/video capture device for media. |args| includes the |  44   // Sets the default audio/video capture device for media. |args| includes the | 
|  41   // media type (kAuudio/kVideo) and the unique id of the new default device |  45   // media type (kAuudio/kVideo) and the unique id of the new default device | 
|  42   // that the user has chosen. |  46   // that the user has chosen. | 
|  43   void SetDefaultCaptureDevice(const base::ListValue* args); |  47   void SetDefaultCaptureDevice(const base::ListValue* args); | 
|  44  |  48  | 
|  45   // Helpers methods to update the device menus. |  49   // Helpers methods to update the device menus. | 
|  46   void UpdateDevicesMenuForType(DeviceType type); |  50   void UpdateDevicesMenuForType(DeviceType type); | 
|  47   void UpdateDevicesMenu(DeviceType type, |  51   void UpdateDevicesMenu(DeviceType type, | 
|  48                          const content::MediaStreamDevices& devices); |  52                          const content::MediaStreamDevices& devices); | 
|  49  |  53  | 
 |  54   Profile* profile_;  // Weak pointer. | 
 |  55  | 
 |  56   ScopedObserver<MediaCaptureDevicesDispatcher, | 
 |  57                  MediaCaptureDevicesDispatcher::Observer> observer_; | 
 |  58  | 
|  50   DISALLOW_COPY_AND_ASSIGN(MediaDevicesSelectionHandler); |  59   DISALLOW_COPY_AND_ASSIGN(MediaDevicesSelectionHandler); | 
|  51 }; |  60 }; | 
|  52  |  61  | 
|  53 }  // namespace options |  62 }  // namespace settings | 
|  54  |  63  | 
|  55 #endif  // CHROME_BROWSER_UI_WEBUI_OPTIONS_MEDIA_DEVICES_SELECTION_HANDLER_H_ |  64 #endif  // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_MEDIA_DEVICES_SELECTION_HAN
    DLER_H_ | 
| OLD | NEW |