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

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

Issue 134993002: Media Galleries: chrome.mediaGalleries.addUserSelectedFolder() requires a user gesture. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 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
« no previous file with comments | « no previous file | chrome/common/extensions/api/media_galleries.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 media_galleries::UsageCount(media_galleries::ADD_USER_SELECTED_FOLDER); 413 media_galleries::UsageCount(media_galleries::ADD_USER_SELECTED_FOLDER);
414 MediaGalleriesPreferences* preferences = 414 MediaGalleriesPreferences* preferences =
415 media_file_system_registry()->GetPreferences(GetProfile()); 415 media_file_system_registry()->GetPreferences(GetProfile());
416 preferences->EnsureInitialized(base::Bind( 416 preferences->EnsureInitialized(base::Bind(
417 &MediaGalleriesAddUserSelectedFolderFunction::OnPreferencesInit, 417 &MediaGalleriesAddUserSelectedFolderFunction::OnPreferencesInit,
418 this)); 418 this));
419 return true; 419 return true;
420 } 420 }
421 421
422 void MediaGalleriesAddUserSelectedFolderFunction::OnPreferencesInit() { 422 void MediaGalleriesAddUserSelectedFolderFunction::OnPreferencesInit() {
423 if (!user_gesture()) {
424 OnDirectorySelected(base::FilePath());
425 return;
426 }
427
423 Profile* profile = GetProfile(); 428 Profile* profile = GetProfile();
424 const std::string& app_id = GetExtension()->id(); 429 const std::string& app_id = GetExtension()->id();
425 WebContents* contents = GetWebContents(render_view_host(), profile, app_id); 430 WebContents* contents = GetWebContents(render_view_host(), profile, app_id);
426 base::FilePath last_used_path = 431 base::FilePath last_used_path =
427 extensions::file_system_api::GetLastChooseEntryDirectory( 432 extensions::file_system_api::GetLastChooseEntryDirectory(
428 extensions::ExtensionPrefs::Get(profile), app_id); 433 extensions::ExtensionPrefs::Get(profile), app_id);
429 SelectDirectoryDialog::Callback callback = base::Bind( 434 SelectDirectoryDialog::Callback callback = base::Bind(
430 &MediaGalleriesAddUserSelectedFolderFunction::OnDirectorySelected, this); 435 &MediaGalleriesAddUserSelectedFolderFunction::OnDirectorySelected, this);
431 scoped_refptr<SelectDirectoryDialog> select_directory_dialog = 436 scoped_refptr<SelectDirectoryDialog> select_directory_dialog =
432 new SelectDirectoryDialog(contents, callback); 437 new SelectDirectoryDialog(contents, callback);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 if (mime_type_sniffed) 560 if (mime_type_sniffed)
556 metadata.mime_type = mime_type; 561 metadata.mime_type = mime_type;
557 562
558 // TODO(tommycli): Kick off SafeMediaMetadataParser if |mime_type_only| false. 563 // TODO(tommycli): Kick off SafeMediaMetadataParser if |mime_type_only| false.
559 564
560 SetResult(metadata.ToValue().release()); 565 SetResult(metadata.ToValue().release());
561 SendResponse(true); 566 SendResponse(true);
562 } 567 }
563 568
564 } // namespace extensions 569 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/api/media_galleries.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698