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

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

Issue 14556015: [Media Galleries] Lazily initialize the storage monitor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix merge Created 7 years, 6 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
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_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
91 91
92 } // namespace 92 } // namespace
93 93
94 MediaGalleriesDialogController::MediaGalleriesDialogController( 94 MediaGalleriesDialogController::MediaGalleriesDialogController(
95 content::WebContents* web_contents, 95 content::WebContents* web_contents,
96 const Extension& extension, 96 const Extension& extension,
97 const base::Closure& on_finish) 97 const base::Closure& on_finish)
98 : web_contents_(web_contents), 98 : web_contents_(web_contents),
99 extension_(&extension), 99 extension_(&extension),
100 on_finish_(on_finish) { 100 on_finish_(on_finish) {
101 // Passing unretained pointer is safe, since the dialog controller
102 // is self-deleting, and so won't be deleted until it can be shown
103 // and then closed.
104 StorageMonitor::GetInstance()->Initialize(base::Bind(
105 &MediaGalleriesDialogController::OnStorageMonitorInitialized,
106 base::Unretained(this)));
107 }
108
109 void MediaGalleriesDialogController::OnStorageMonitorInitialized() {
101 MediaFileSystemRegistry* registry = 110 MediaFileSystemRegistry* registry =
102 g_browser_process->media_file_system_registry(); 111 g_browser_process->media_file_system_registry();
103 preferences_ = registry->GetPreferences( 112 preferences_ = registry->GetPreferences(
104 Profile::FromBrowserContext(web_contents->GetBrowserContext())); 113 Profile::FromBrowserContext(web_contents_->GetBrowserContext()));
105 InitializePermissions(); 114 InitializePermissions();
106 115
107 dialog_.reset(MediaGalleriesDialog::Create(this)); 116 dialog_.reset(MediaGalleriesDialog::Create(this));
108 117
109 StorageMonitor::GetInstance()->AddObserver(this); 118 StorageMonitor::GetInstance()->AddObserver(this);
110 119
111 preferences_->AddGalleryChangeObserver(this); 120 preferences_->AddGalleryChangeObserver(this);
112 } 121 }
113 122
114 MediaGalleriesDialogController::MediaGalleriesDialogController() 123 MediaGalleriesDialogController::MediaGalleriesDialogController()
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 if (iter->pref_info.device_id == device_id) 511 if (iter->pref_info.device_id == device_id)
503 dialog_->UpdateGallery(iter->pref_info, iter->allowed); 512 dialog_->UpdateGallery(iter->pref_info, iter->allowed);
504 } 513 }
505 } 514 }
506 515
507 // MediaGalleries dialog ------------------------------------------------------- 516 // MediaGalleries dialog -------------------------------------------------------
508 517
509 MediaGalleriesDialog::~MediaGalleriesDialog() {} 518 MediaGalleriesDialog::~MediaGalleriesDialog() {}
510 519
511 } // namespace chrome 520 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698