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

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

Issue 11196007: Fix media galleries crash when the window is closed with config dialog open. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | no next file » | 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 30 matching lines...) Expand all
41 namespace MediaGalleries = extensions::api::media_galleries; 41 namespace MediaGalleries = extensions::api::media_galleries;
42 namespace GetMediaFileSystems = MediaGalleries::GetMediaFileSystems; 42 namespace GetMediaFileSystems = MediaGalleries::GetMediaFileSystems;
43 43
44 namespace extensions { 44 namespace extensions {
45 45
46 namespace { 46 namespace {
47 47
48 const char kDisallowedByPolicy[] = 48 const char kDisallowedByPolicy[] =
49 "Media Galleries API is disallowed by policy: "; 49 "Media Galleries API is disallowed by policy: ";
50 const char kInvalidInteractive[] = "Unknown value for interactive."; 50 const char kInvalidInteractive[] = "Unknown value for interactive.";
51 const char kInvalidRPH[] = "The render process no longer exists.";
51 52
52 // Checks whether the MediaGalleries API is currently accessible (it may be 53 // Checks whether the MediaGalleries API is currently accessible (it may be
53 // disallowed even if an extension has the requisite permission). 54 // disallowed even if an extension has the requisite permission).
54 bool ApiIsAccessible(std::string* error) { 55 bool ApiIsAccessible(std::string* error) {
55 if (!ChromeSelectFilePolicy::FileSelectDialogsAllowed()) { 56 if (!ChromeSelectFilePolicy::FileSelectDialogsAllowed()) {
56 *error = std::string(kDisallowedByPolicy) + 57 *error = std::string(kDisallowedByPolicy) +
57 prefs::kAllowFileSelectionDialogs; 58 prefs::kAllowFileSelectionDialogs;
58 return false; 59 return false;
59 } 60 }
60 61
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 115 }
115 116
116 void MediaGalleriesGetMediaFileSystemsFunction::GetAndReturnGalleries() { 117 void MediaGalleriesGetMediaFileSystemsFunction::GetAndReturnGalleries() {
117 MediaFileSystemRegistry::GetInstance()->GetMediaFileSystemsForExtension( 118 MediaFileSystemRegistry::GetInstance()->GetMediaFileSystemsForExtension(
118 render_view_host(), GetExtension(), base::Bind( 119 render_view_host(), GetExtension(), base::Bind(
119 &MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries, this)); 120 &MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries, this));
120 } 121 }
121 122
122 void MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries( 123 void MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries(
123 const std::vector<MediaFileSystemInfo>& filesystems) { 124 const std::vector<MediaFileSystemInfo>& filesystems) {
124 const int child_id = render_view_host()->GetProcess()->GetID(); 125 content::RenderViewHost* rvh = render_view_host();
126 if (!rvh) {
127 error_ = kInvalidRPH;
asargent_no_longer_on_chrome 2012/10/16 23:01:47 If the RPH no longer exists, doesn't that mean it'
vandebo (ex-Chrome) 2012/10/16 23:17:28 Yea, I wasn't sure about that part. Looking into
128 SendResponse(false);
129 return;
130 }
131 content::RenderProcessHost* rph = rvh->GetProcess();
132 if (!rph) {
133 error_ = kInvalidRPH;
134 SendResponse(false);
135 return;
136 }
137 const int child_id = rph->GetID();
125 std::set<std::string> file_system_names; 138 std::set<std::string> file_system_names;
126 base::ListValue* list = new base::ListValue(); 139 base::ListValue* list = new base::ListValue();
127 for (size_t i = 0; i < filesystems.size(); i++) { 140 for (size_t i = 0; i < filesystems.size(); i++) {
128 scoped_ptr<base::DictionaryValue> file_system_dict_value( 141 scoped_ptr<base::DictionaryValue> file_system_dict_value(
129 new base::DictionaryValue()); 142 new base::DictionaryValue());
130 143
131 // Send the file system id so the renderer can create a valid FileSystem 144 // Send the file system id so the renderer can create a valid FileSystem
132 // object. 145 // object.
133 file_system_dict_value->SetWithoutPathExpansion( 146 file_system_dict_value->SetWithoutPathExpansion(
134 "fsid", Value::CreateStringValue(filesystems[i].fsid)); 147 "fsid", Value::CreateStringValue(filesystems[i].fsid));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() { 202 bool MediaGalleriesAssembleMediaFileFunction::RunImpl() {
190 if (!ApiIsAccessible(&error_)) 203 if (!ApiIsAccessible(&error_))
191 return false; 204 return false;
192 205
193 // TODO(vandebo) Update the metadata and return the new file. 206 // TODO(vandebo) Update the metadata and return the new file.
194 SetResult(Value::CreateNullValue()); 207 SetResult(Value::CreateNullValue());
195 return true; 208 return true;
196 } 209 }
197 210
198 } // namespace extensions 211 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698