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

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

Issue 15010: Implement extension:// protocol. (Closed)
Patch Set: add missing unit test Created 12 years 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/extensions_service.h" 5 #include "chrome/browser/extensions/extensions_service.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/thread.h" 10 #include "base/thread.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/common/json_value_serializer.h" 12 #include "chrome/common/json_value_serializer.h"
13 #include "chrome/common/notification_service.h"
13 14
14 // ExtensionsService 15 // ExtensionsService
15 16
16 const FilePath::CharType* ExtensionsService::kInstallDirectoryName = 17 const FilePath::CharType* ExtensionsService::kInstallDirectoryName =
17 FILE_PATH_LITERAL("Extensions"); 18 FILE_PATH_LITERAL("Extensions");
18 19
19 ExtensionsService::ExtensionsService(const FilePath& profile_directory) 20 ExtensionsService::ExtensionsService(const FilePath& profile_directory)
20 : message_loop_(MessageLoop::current()), 21 : message_loop_(MessageLoop::current()),
21 backend_(new ExtensionsServiceBackend), 22 backend_(new ExtensionsServiceBackend),
22 install_directory_(profile_directory.Append(kInstallDirectoryName)) { 23 install_directory_(profile_directory.Append(kInstallDirectoryName)) {
(...skipping 21 matching lines...) Expand all
44 } 45 }
45 46
46 MessageLoop* ExtensionsService::GetMessageLoop() { 47 MessageLoop* ExtensionsService::GetMessageLoop() {
47 return message_loop_; 48 return message_loop_;
48 } 49 }
49 50
50 void ExtensionsService::OnExtensionsLoadedFromDirectory( 51 void ExtensionsService::OnExtensionsLoadedFromDirectory(
51 ExtensionList* new_extensions) { 52 ExtensionList* new_extensions) {
52 extensions_.insert(extensions_.end(), new_extensions->begin(), 53 extensions_.insert(extensions_.end(), new_extensions->begin(),
53 new_extensions->end()); 54 new_extensions->end());
55
56 NotificationService::current()->Notify(NOTIFY_EXTENSIONS_LOADED,
57 NotificationService::AllSources(),
58 Details<ExtensionList>(new_extensions));
59
54 delete new_extensions; 60 delete new_extensions;
55
56 // TODO(aa): Notify extensions are loaded.
57 } 61 }
58 62
59 void ExtensionsService::OnExtensionLoadError(const std::string& error) { 63 void ExtensionsService::OnExtensionLoadError(const std::string& error) {
60 // TODO(aa): Print the error message out somewhere better. I think we are 64 // TODO(aa): Print the error message out somewhere better. I think we are
61 // going to need some sort of 'extension inspector'. 65 // going to need some sort of 'extension inspector'.
62 LOG(WARNING) << error; 66 LOG(WARNING) << error;
63 } 67 }
64 68
65 69
66 // ExtensionsServicesBackend 70 // ExtensionsServicesBackend
(...skipping 25 matching lines...) Expand all
92 continue; 96 continue;
93 } 97 }
94 98
95 scoped_ptr<Value> scoped_root(root); 99 scoped_ptr<Value> scoped_root(root);
96 if (!root->IsType(Value::TYPE_DICTIONARY)) { 100 if (!root->IsType(Value::TYPE_DICTIONARY)) {
97 ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(), 101 ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(),
98 Extension::kInvalidManifestError); 102 Extension::kInvalidManifestError);
99 continue; 103 continue;
100 } 104 }
101 105
102 scoped_ptr<Extension> extension(new Extension()); 106 scoped_ptr<Extension> extension(new Extension(child_path));
103 if (!extension->InitFromValue(*static_cast<DictionaryValue*>(root), 107 if (!extension->InitFromValue(*static_cast<DictionaryValue*>(root),
104 &error)) { 108 &error)) {
105 ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(), 109 ReportExtensionLoadError(frontend.get(), child_path.ToWStringHack(),
106 error); 110 error);
107 continue; 111 continue;
108 } 112 }
109 113
110 extensions->push_back(extension.release()); 114 extensions->push_back(extension.release());
111 } 115 }
112 116
(...skipping 11 matching lines...) Expand all
124 message)); 128 message));
125 } 129 }
126 130
127 void ExtensionsServiceBackend::ReportExtensionsLoaded( 131 void ExtensionsServiceBackend::ReportExtensionsLoaded(
128 ExtensionsServiceFrontendInterface *frontend, ExtensionList* extensions) { 132 ExtensionsServiceFrontendInterface *frontend, ExtensionList* extensions) {
129 frontend->GetMessageLoop()->PostTask(FROM_HERE, NewRunnableMethod( 133 frontend->GetMessageLoop()->PostTask(FROM_HERE, NewRunnableMethod(
130 frontend, 134 frontend,
131 &ExtensionsServiceFrontendInterface::OnExtensionsLoadedFromDirectory, 135 &ExtensionsServiceFrontendInterface::OnExtensionsLoadedFromDirectory,
132 extensions)); 136 extensions));
133 } 137 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_protocol_unittest.cc ('k') | chrome/browser/greasemonkey_master.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698