Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Side by Side Diff: chrome/browser/media_gallery/media_galleries_dialog_controller.cc

Issue 11573048: [Media Galleries] Move RemovableStorageInfo notifications to chrome namespace (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to head Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/media_gallery/media_galleries_dialog_controller.h" 5 #include "chrome/browser/media_gallery/media_galleries_dialog_controller.h"
6 6
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/media_gallery/media_file_system_registry.h" 10 #include "chrome/browser/media_gallery/media_file_system_registry.h"
(...skipping 10 matching lines...) Expand all
21 using extensions::Extension; 21 using extensions::Extension;
22 22
23 namespace chrome { 23 namespace chrome {
24 24
25 namespace { 25 namespace {
26 26
27 bool IsAttachedDevice(const std::string& device_id) { 27 bool IsAttachedDevice(const std::string& device_id) {
28 if (!MediaStorageUtil::IsRemovableDevice(device_id)) 28 if (!MediaStorageUtil::IsRemovableDevice(device_id))
29 return false; 29 return false;
30 30
31 std::vector<base::SystemMonitor::RemovableStorageInfo> removable_storages = 31 std::vector<RemovableStorageNotifications::RemovableStorageInfo>
32 base::SystemMonitor::Get()->GetAttachedRemovableStorage(); 32 removable_storages = RemovableStorageNotifications::GetInstance()->
33 GetAttachedRemovableStorage();
33 for (size_t i = 0; i < removable_storages.size(); ++i) { 34 for (size_t i = 0; i < removable_storages.size(); ++i) {
34 if (removable_storages[i].device_id == device_id) 35 if (removable_storages[i].device_id == device_id)
35 return true; 36 return true;
36 } 37 }
37 return false; 38 return false;
38 } 39 }
39 40
40 } // namespace 41 } // namespace
41 42
42 MediaGalleriesDialogController::MediaGalleriesDialogController( 43 MediaGalleriesDialogController::MediaGalleriesDialogController(
43 content::WebContents* web_contents, 44 content::WebContents* web_contents,
44 const Extension& extension, 45 const Extension& extension,
45 const base::Closure& on_finish) 46 const base::Closure& on_finish)
46 : web_contents_(web_contents), 47 : web_contents_(web_contents),
47 extension_(&extension), 48 extension_(&extension),
48 on_finish_(on_finish) { 49 on_finish_(on_finish) {
49 MediaFileSystemRegistry* registry = 50 MediaFileSystemRegistry* registry =
50 g_browser_process->media_file_system_registry(); 51 g_browser_process->media_file_system_registry();
51 preferences_ = registry->GetPreferences( 52 preferences_ = registry->GetPreferences(
52 Profile::FromBrowserContext(web_contents->GetBrowserContext())); 53 Profile::FromBrowserContext(web_contents->GetBrowserContext()));
53 InitializePermissions(); 54 InitializePermissions();
54 55
55 dialog_.reset(MediaGalleriesDialog::Create(this)); 56 dialog_.reset(MediaGalleriesDialog::Create(this));
56 57
57 base::SystemMonitor* monitor = base::SystemMonitor::Get(); 58 RemovableStorageNotifications* notifications =
58 if (monitor) 59 RemovableStorageNotifications::GetInstance();
59 monitor->AddDevicesChangedObserver(this); 60 if (notifications)
61 notifications->AddRemovableStorageObserver(this);
60 } 62 }
61 63
62 MediaGalleriesDialogController::MediaGalleriesDialogController() 64 MediaGalleriesDialogController::MediaGalleriesDialogController()
63 : web_contents_(NULL), 65 : web_contents_(NULL),
64 extension_(NULL), 66 extension_(NULL),
65 preferences_(NULL) {} 67 preferences_(NULL) {}
66 68
67 MediaGalleriesDialogController::~MediaGalleriesDialogController() { 69 MediaGalleriesDialogController::~MediaGalleriesDialogController() {
68 base::SystemMonitor* monitor = base::SystemMonitor::Get(); 70 RemovableStorageNotifications* notifications =
69 if (monitor) 71 RemovableStorageNotifications::GetInstance();
70 monitor->RemoveDevicesChangedObserver(this); 72 if (notifications)
73 notifications->RemoveRemovableStorageObserver(this);
71 74
72 if (select_folder_dialog_.get()) 75 if (select_folder_dialog_.get())
73 select_folder_dialog_->ListenerDestroyed(); 76 select_folder_dialog_->ListenerDestroyed();
74 } 77 }
75 78
76 // static 79 // static
77 string16 MediaGalleriesDialogController::GetGalleryDisplayName( 80 string16 MediaGalleriesDialogController::GetGalleryDisplayName(
78 const MediaGalleryPrefInfo& gallery) { 81 const MediaGalleryPrefInfo& gallery) {
79 string16 name = gallery.display_name; 82 string16 name = gallery.display_name;
80 if (IsAttachedDevice(gallery.device_id)) { 83 if (IsAttachedDevice(gallery.device_id)) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 283
281 if (gallery) 284 if (gallery)
282 dialog_->UpdateGallery(&gallery->pref_info, gallery->allowed); 285 dialog_->UpdateGallery(&gallery->pref_info, gallery->allowed);
283 } 286 }
284 287
285 // MediaGalleries dialog ------------------------------------------------------- 288 // MediaGalleries dialog -------------------------------------------------------
286 289
287 MediaGalleriesDialog::~MediaGalleriesDialog() {} 290 MediaGalleriesDialog::~MediaGalleriesDialog() {}
288 291
289 } // namespace chrome 292 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698