| OLD | NEW |
| 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_galleries/media_galleries_dialog_controller.h" | 5 #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h" |
| 6 | 6 |
| 7 #include "base/i18n/time_formatting.h" | 7 #include "base/i18n/time_formatting.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace | 93 } // namespace |
| 94 | 94 |
| 95 MediaGalleriesDialogController::MediaGalleriesDialogController( | 95 MediaGalleriesDialogController::MediaGalleriesDialogController( |
| 96 content::WebContents* web_contents, | 96 content::WebContents* web_contents, |
| 97 const Extension& extension, | 97 const Extension& extension, |
| 98 const base::Closure& on_finish) | 98 const base::Closure& on_finish) |
| 99 : web_contents_(web_contents), | 99 : web_contents_(web_contents), |
| 100 extension_(&extension), | 100 extension_(&extension), |
| 101 on_finish_(on_finish) { | 101 on_finish_(on_finish), |
| 102 weak_ptr_factory_(this) { |
| 103 StorageMonitor::GetInstance()->Initialize(base::Bind( |
| 104 &MediaGalleriesDialogController::OnStorageMonitorInitialized, |
| 105 weak_ptr_factory_.GetWeakPtr())); |
| 106 } |
| 107 |
| 108 void MediaGalleriesDialogController::OnStorageMonitorInitialized() { |
| 102 MediaFileSystemRegistry* registry = | 109 MediaFileSystemRegistry* registry = |
| 103 g_browser_process->media_file_system_registry(); | 110 g_browser_process->media_file_system_registry(); |
| 104 preferences_ = registry->GetPreferences( | 111 preferences_ = registry->GetPreferences( |
| 105 Profile::FromBrowserContext(web_contents->GetBrowserContext())); | 112 Profile::FromBrowserContext(web_contents_->GetBrowserContext())); |
| 106 InitializePermissions(); | 113 InitializePermissions(); |
| 107 | 114 |
| 108 dialog_.reset(MediaGalleriesDialog::Create(this)); | 115 dialog_.reset(MediaGalleriesDialog::Create(this)); |
| 109 | 116 |
| 110 StorageMonitor* monitor = StorageMonitor::GetInstance(); | 117 StorageMonitor* monitor = StorageMonitor::GetInstance(); |
| 111 if (monitor) | 118 if (monitor) |
| 112 monitor->AddObserver(this); | 119 monitor->AddObserver(this); |
| 113 | 120 |
| 114 preferences_->AddGalleryChangeObserver(this); | 121 preferences_->AddGalleryChangeObserver(this); |
| 115 } | 122 } |
| 116 | 123 |
| 117 MediaGalleriesDialogController::MediaGalleriesDialogController() | 124 MediaGalleriesDialogController::MediaGalleriesDialogController() |
| 118 : web_contents_(NULL), | 125 : web_contents_(NULL), |
| 119 extension_(NULL), | 126 extension_(NULL), |
| 120 preferences_(NULL) {} | 127 preferences_(NULL), |
| 128 weak_ptr_factory_(this) {} |
| 121 | 129 |
| 122 MediaGalleriesDialogController::~MediaGalleriesDialogController() { | 130 MediaGalleriesDialogController::~MediaGalleriesDialogController() { |
| 123 StorageMonitor* monitor = StorageMonitor::GetInstance(); | 131 StorageMonitor* monitor = StorageMonitor::GetInstance(); |
| 124 if (monitor) | 132 if (monitor) |
| 125 monitor->RemoveObserver(this); | 133 monitor->RemoveObserver(this); |
| 126 | 134 |
| 127 if (select_folder_dialog_.get()) | 135 if (select_folder_dialog_.get()) |
| 128 select_folder_dialog_->ListenerDestroyed(); | 136 select_folder_dialog_->ListenerDestroyed(); |
| 129 } | 137 } |
| 130 | 138 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 if (iter->pref_info.device_id == device_id) | 515 if (iter->pref_info.device_id == device_id) |
| 508 dialog_->UpdateGallery(iter->pref_info, iter->allowed); | 516 dialog_->UpdateGallery(iter->pref_info, iter->allowed); |
| 509 } | 517 } |
| 510 } | 518 } |
| 511 | 519 |
| 512 // MediaGalleries dialog ------------------------------------------------------- | 520 // MediaGalleries dialog ------------------------------------------------------- |
| 513 | 521 |
| 514 MediaGalleriesDialog::~MediaGalleriesDialog() {} | 522 MediaGalleriesDialog::~MediaGalleriesDialog() {} |
| 515 | 523 |
| 516 } // namespace chrome | 524 } // namespace chrome |
| OLD | NEW |