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

Side by Side Diff: chrome/browser/extensions/extension_management_api.cc

Issue 10649003: Move each permission classes to its own files in extensions/permissions (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase on HEAD Created 8 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/extensions/extension_management_api.h" 5 #include "chrome/browser/extensions/extension_management_api.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 26 matching lines...) Expand all
37 37
38 #if !defined(OS_ANDROID) 38 #if !defined(OS_ANDROID)
39 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" 39 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
40 #endif 40 #endif
41 41
42 using base::IntToString; 42 using base::IntToString;
43 using content::BrowserThread; 43 using content::BrowserThread;
44 using content::UtilityProcessHost; 44 using content::UtilityProcessHost;
45 using content::UtilityProcessHostClient; 45 using content::UtilityProcessHostClient;
46 using extensions::Extension; 46 using extensions::Extension;
47 using extensions::PermissionMessages;
47 48
48 namespace events = extension_event_names; 49 namespace events = extension_event_names;
49 namespace keys = extension_management_api_constants; 50 namespace keys = extension_management_api_constants;
50 51
51 namespace { 52 namespace {
52 53
53 enum AutoConfirmForTest { 54 enum AutoConfirmForTest {
54 DO_NOT_SKIP = 0, 55 DO_NOT_SKIP = 0,
55 PROCEED, 56 PROCEED,
56 ABORT 57 ABORT
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 std::string ext_id; 189 std::string ext_id;
189 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &ext_id)); 190 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &ext_id));
190 191
191 const Extension* extension = service()->GetExtensionById(ext_id, true); 192 const Extension* extension = service()->GetExtensionById(ext_id, true);
192 if (!extension) { 193 if (!extension) {
193 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoExtensionError, 194 error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kNoExtensionError,
194 ext_id); 195 ext_id);
195 return false; 196 return false;
196 } 197 }
197 198
198 ExtensionPermissionMessages warnings = extension->GetPermissionMessages(); 199 PermissionMessages warnings = extension->GetPermissionMessages();
199 ListValue* result = new ListValue(); 200 ListValue* result = new ListValue();
200 for (ExtensionPermissionMessages::const_iterator i = warnings.begin(); 201 for (PermissionMessages::const_iterator i = warnings.begin();
201 i < warnings.end(); ++i) 202 i < warnings.end(); ++i)
202 result->Append(Value::CreateStringValue(i->message())); 203 result->Append(Value::CreateStringValue(i->message()));
203 result_.reset(result); 204 result_.reset(result);
204 return true; 205 return true;
205 } 206 }
206 207
207 namespace { 208 namespace {
208 209
209 // This class helps GetPermissionWarningsByManifestFunction manage 210 // This class helps GetPermissionWarningsByManifestFunction manage
210 // sending manifest JSON strings to the utility process for parsing. 211 // sending manifest JSON strings to the utility process for parsing.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 CHECK(parsed_manifest); 313 CHECK(parsed_manifest);
313 314
314 scoped_refptr<Extension> extension = Extension::Create( 315 scoped_refptr<Extension> extension = Extension::Create(
315 FilePath(), Extension::INVALID, *parsed_manifest, Extension::NO_FLAGS, 316 FilePath(), Extension::INVALID, *parsed_manifest, Extension::NO_FLAGS,
316 &error_); 317 &error_);
317 if (!extension.get()) { 318 if (!extension.get()) {
318 OnParseFailure(keys::kExtensionCreateError); 319 OnParseFailure(keys::kExtensionCreateError);
319 return; 320 return;
320 } 321 }
321 322
322 ExtensionPermissionMessages warnings = extension->GetPermissionMessages(); 323 PermissionMessages warnings = extension->GetPermissionMessages();
323 ListValue* result = new ListValue(); 324 ListValue* result = new ListValue();
324 for (ExtensionPermissionMessages::const_iterator i = warnings.begin(); 325 for (PermissionMessages::const_iterator i = warnings.begin();
325 i < warnings.end(); ++i) 326 i < warnings.end(); ++i)
326 result->Append(Value::CreateStringValue(i->message())); 327 result->Append(Value::CreateStringValue(i->message()));
327 result_.reset(result); 328 result_.reset(result);
328 SendResponse(true); 329 SendResponse(true);
329 330
330 // Matched with AddRef() in RunImpl(). 331 // Matched with AddRef() in RunImpl().
331 Release(); 332 Release();
332 } 333 }
333 334
334 void GetPermissionWarningsByManifestFunction::OnParseFailure( 335 void GetPermissionWarningsByManifestFunction::OnParseFailure(
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 ExtensionService* service = profile->GetExtensionService(); 584 ExtensionService* service = profile->GetExtensionService();
584 args.Append(CreateExtensionInfo(*extension, service)); 585 args.Append(CreateExtensionInfo(*extension, service));
585 } 586 }
586 587
587 std::string args_json; 588 std::string args_json;
588 base::JSONWriter::Write(&args, &args_json); 589 base::JSONWriter::Write(&args, &args_json);
589 590
590 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 591 profile->GetExtensionEventRouter()->DispatchEventToRenderers(
591 event_name, args_json, NULL, GURL()); 592 event_name, args_json, NULL, GURL());
592 } 593 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_prompt.cc ('k') | chrome/browser/extensions/extension_preference_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698