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

Side by Side Diff: chrome/browser/extensions/api/media_galleries/media_galleries_api.cc

Issue 166053003: Move ProfileKeyedAPI implementations to take BrowserContext in the constructor (part 2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: | Created 6 years, 10 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 // Implements the Chrome Extensions Media Galleries API. 5 // Implements the Chrome Extensions Media Galleries API.
6 6
7 #include "chrome/browser/extensions/api/media_galleries/media_galleries_api.h" 7 #include "chrome/browser/extensions/api/media_galleries/media_galleries_api.h"
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; 249 scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
250 WebContents* web_contents_; 250 WebContents* web_contents_;
251 Callback callback_; 251 Callback callback_;
252 252
253 DISALLOW_COPY_AND_ASSIGN(SelectDirectoryDialog); 253 DISALLOW_COPY_AND_ASSIGN(SelectDirectoryDialog);
254 }; 254 };
255 255
256 } // namespace 256 } // namespace
257 257
258 MediaGalleriesEventRouter::MediaGalleriesEventRouter(Profile* profile) 258 MediaGalleriesEventRouter::MediaGalleriesEventRouter(
259 : profile_(profile), 259 content::BrowserContext* context)
260 weak_ptr_factory_(this) { 260 : profile_(Profile::FromBrowserContext(context)), weak_ptr_factory_(this) {
261 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 261 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
262 DCHECK(profile_); 262 DCHECK(profile_);
263 media_scan_manager()->AddObserver(profile_, this); 263 media_scan_manager()->AddObserver(profile_, this);
264 } 264 }
265 265
266 MediaGalleriesEventRouter::~MediaGalleriesEventRouter() { 266 MediaGalleriesEventRouter::~MediaGalleriesEventRouter() {
267 } 267 }
268 268
269 void MediaGalleriesEventRouter::Shutdown() { 269 void MediaGalleriesEventRouter::Shutdown() {
270 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 270 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
271 weak_ptr_factory_.InvalidateWeakPtrs(); 271 weak_ptr_factory_.InvalidateWeakPtrs();
272 media_scan_manager()->RemoveObserver(profile_); 272 media_scan_manager()->RemoveObserver(profile_);
273 media_scan_manager()->CancelScansForProfile(profile_); 273 media_scan_manager()->CancelScansForProfile(profile_);
274 } 274 }
275 275
276 static base::LazyInstance<ProfileKeyedAPIFactory<MediaGalleriesEventRouter> > 276 static base::LazyInstance<ProfileKeyedAPIFactory<MediaGalleriesEventRouter> >
277 g_factory = LAZY_INSTANCE_INITIALIZER; 277 g_factory = LAZY_INSTANCE_INITIALIZER;
278 278
279 // static 279 // static
280 ProfileKeyedAPIFactory<MediaGalleriesEventRouter>* 280 ProfileKeyedAPIFactory<MediaGalleriesEventRouter>*
281 MediaGalleriesEventRouter::GetFactoryInstance() { 281 MediaGalleriesEventRouter::GetFactoryInstance() {
282 return g_factory.Pointer(); 282 return g_factory.Pointer();
283 } 283 }
284 284
285 // static 285 // static
286 MediaGalleriesEventRouter* MediaGalleriesEventRouter::Get(Profile* profile) { 286 MediaGalleriesEventRouter* MediaGalleriesEventRouter::Get(
287 DCHECK(media_file_system_registry()->GetPreferences(profile)-> 287 content::BrowserContext* context) {
288 IsInitialized()); 288 DCHECK(media_file_system_registry()
289 ->GetPreferences(Profile::FromBrowserContext(context))
290 ->IsInitialized());
289 return ProfileKeyedAPIFactory<MediaGalleriesEventRouter>::GetForProfile( 291 return ProfileKeyedAPIFactory<MediaGalleriesEventRouter>::GetForProfile(
290 profile); 292 context);
291 } 293 }
292 294
293 bool MediaGalleriesEventRouter::ExtensionHasScanProgressListener( 295 bool MediaGalleriesEventRouter::ExtensionHasScanProgressListener(
294 const std::string& extension_id) const { 296 const std::string& extension_id) const {
295 EventRouter* router = ExtensionSystem::Get(profile_)->event_router(); 297 EventRouter* router = ExtensionSystem::Get(profile_)->event_router();
296 return router->ExtensionHasEventListener( 298 return router->ExtensionHasEventListener(
297 extension_id, 299 extension_id,
298 MediaGalleries::OnScanProgress::kEventName); 300 MediaGalleries::OnScanProgress::kEventName);
299 } 301 }
300 302
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 if (mime_type_sniffed) 800 if (mime_type_sniffed)
799 metadata.mime_type = mime_type; 801 metadata.mime_type = mime_type;
800 802
801 // TODO(tommycli): Kick off SafeMediaMetadataParser if |mime_type_only| false. 803 // TODO(tommycli): Kick off SafeMediaMetadataParser if |mime_type_only| false.
802 804
803 SetResult(metadata.ToValue().release()); 805 SetResult(metadata.ToValue().release());
804 SendResponse(true); 806 SendResponse(true);
805 } 807 }
806 808
807 } // namespace extensions 809 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698