Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / media_galleries / media_galleries_scan_result_dialog_controller.h
index 28754a7..96d87b6 100644 (file)
@@ -13,7 +13,7 @@
 #include "base/memory/scoped_ptr.h"
 #include "base/strings/string16.h"
 #include "chrome/browser/media_galleries/media_galleries_preferences.h"
-#include "chrome/browser/storage_monitor/removable_storage_observer.h"
+#include "components/storage_monitor/removable_storage_observer.h"
 
 namespace content {
 class WebContents;
@@ -23,7 +23,12 @@ namespace extensions {
 class Extension;
 }
 
+namespace ui {
+class MenuModel;
+}
+
 class MediaGalleriesScanResultDialogController;
+class MediaGalleryContextMenu;
 class Profile;
 
 // The view.
@@ -51,13 +56,18 @@ class MediaGalleriesScanResultDialogController
         : pref_info(pref_info),
           selected(selected) {
     }
-    ScanResult() {}
+    ScanResult() : selected(false) {}
 
     MediaGalleryPrefInfo pref_info;
     bool selected;
   };
   typedef std::vector<ScanResult> OrderedScanResults;
 
+  // |preferences| must be already initialized.
+  static size_t ScanResultCountForExtension(
+      MediaGalleriesPreferences* preferences,
+      const extensions::Extension* extension);
+
   // The constructor creates a dialog controller which owns itself.
   MediaGalleriesScanResultDialogController(
       content::WebContents* web_contents,
@@ -87,12 +97,20 @@ class MediaGalleriesScanResultDialogController
 
   virtual content::WebContents* web_contents();
 
- private:
-  friend class MediaGalleriesScanResultDialogControllerTest;
+  ui::MenuModel* GetContextMenu(MediaGalleryPrefId id);
 
-  typedef std::map<MediaGalleryPrefId, ScanResult> ScanResults;
+ protected:
   typedef base::Callback<MediaGalleriesScanResultDialog* (
       MediaGalleriesScanResultDialogController*)> CreateDialogCallback;
+  typedef std::map<MediaGalleryPrefId, ScanResult> ScanResults;
+
+  // Updates |scan_results| from |preferences|. Will not add galleries from
+  // |ignore_list| onto |scan_results|.
+  static void UpdateScanResultsFromPreferences(
+      MediaGalleriesPreferences* preferences,
+      const extensions::Extension* extension,
+      MediaGalleryPrefIdSet ignore_list,
+      ScanResults* scan_results);
 
   // Used for unit tests.
   MediaGalleriesScanResultDialogController(
@@ -103,15 +121,15 @@ class MediaGalleriesScanResultDialogController
 
   virtual ~MediaGalleriesScanResultDialogController();
 
+ private:
+  friend class MediaGalleriesScanResultDialogControllerTest;
+  friend class MediaGalleriesScanResultDialogCocoaTest;
+
   // Bottom half of constructor -- called when |preferences_| is initialized.
   void OnPreferencesInitialized();
 
-  // Update the controller state from preferences.
-  void UpdateFromPreferences();
-
   // Used to keep the dialog in sync with the preferences.
-  void OnPreferenceUpdate(const std::string& extension_id,
-                          MediaGalleryPrefId pref_id);
+  void OnPreferenceUpdate(const std::string& extension_id);
 
   // Used to keep the dialog in sync with attached and detached devices.
   void OnRemovableDeviceUpdate(const std::string device_id);
@@ -166,6 +184,8 @@ class MediaGalleriesScanResultDialogController
   // The view that's showing.
   scoped_ptr<MediaGalleriesScanResultDialog> dialog_;
 
+  scoped_ptr<MediaGalleryContextMenu> context_menu_;
+
   DISALLOW_COPY_AND_ASSIGN(MediaGalleriesScanResultDialogController);
 };