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

Side by Side Diff: extensions/browser/api/runtime/runtime_api.cc

Issue 425303002: Move extension notifications to extensions/browser/notification_types.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (extension-notifications) rebase Created 6 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/runtime/runtime_api.h" 5 #include "extensions/browser/api/runtime/runtime_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "base/version.h" 14 #include "base/version.h"
15 #include "chrome/browser/chrome_notification_types.h"
16 #include "content/public/browser/browser_context.h" 15 #include "content/public/browser/browser_context.h"
17 #include "content/public/browser/child_process_security_policy.h" 16 #include "content/public/browser/child_process_security_policy.h"
18 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
19 #include "content/public/browser/render_process_host.h" 18 #include "content/public/browser/render_process_host.h"
20 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
21 #include "extensions/browser/api/runtime/runtime_api_delegate.h" 20 #include "extensions/browser/api/runtime/runtime_api_delegate.h"
22 #include "extensions/browser/event_router.h" 21 #include "extensions/browser/event_router.h"
23 #include "extensions/browser/extension_host.h" 22 #include "extensions/browser/extension_host.h"
24 #include "extensions/browser/extension_prefs.h" 23 #include "extensions/browser/extension_prefs.h"
25 #include "extensions/browser/extension_registry.h" 24 #include "extensions/browser/extension_registry.h"
26 #include "extensions/browser/extension_system.h" 25 #include "extensions/browser/extension_system.h"
27 #include "extensions/browser/extension_util.h" 26 #include "extensions/browser/extension_util.h"
28 #include "extensions/browser/extensions_browser_client.h" 27 #include "extensions/browser/extensions_browser_client.h"
29 #include "extensions/browser/lazy_background_task_queue.h" 28 #include "extensions/browser/lazy_background_task_queue.h"
29 #include "extensions/browser/notification_types.h"
30 #include "extensions/browser/process_manager.h" 30 #include "extensions/browser/process_manager.h"
31 #include "extensions/common/api/runtime.h" 31 #include "extensions/common/api/runtime.h"
32 #include "extensions/common/error_utils.h" 32 #include "extensions/common/error_utils.h"
33 #include "extensions/common/extension.h" 33 #include "extensions/common/extension.h"
34 #include "extensions/common/manifest_handlers/background_info.h" 34 #include "extensions/common/manifest_handlers/background_info.h"
35 #include "extensions/common/manifest_handlers/shared_module_info.h" 35 #include "extensions/common/manifest_handlers/shared_module_info.h"
36 #include "url/gurl.h" 36 #include "url/gurl.h"
37 #include "webkit/browser/fileapi/isolated_context.h" 37 #include "webkit/browser/fileapi/isolated_context.h"
38 38
39 using content::BrowserContext; 39 using content::BrowserContext;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // static 134 // static
135 BrowserContextKeyedAPIFactory<RuntimeAPI>* RuntimeAPI::GetFactoryInstance() { 135 BrowserContextKeyedAPIFactory<RuntimeAPI>* RuntimeAPI::GetFactoryInstance() {
136 return g_factory.Pointer(); 136 return g_factory.Pointer();
137 } 137 }
138 138
139 RuntimeAPI::RuntimeAPI(content::BrowserContext* context) 139 RuntimeAPI::RuntimeAPI(content::BrowserContext* context)
140 : browser_context_(context), 140 : browser_context_(context),
141 dispatch_chrome_updated_event_(false), 141 dispatch_chrome_updated_event_(false),
142 extension_registry_observer_(this) { 142 extension_registry_observer_(this) {
143 registrar_.Add(this, 143 registrar_.Add(this,
144 chrome::NOTIFICATION_EXTENSIONS_READY, 144 extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
145 content::Source<BrowserContext>(context)); 145 content::Source<BrowserContext>(context));
146 extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_)); 146 extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_));
147 147
148 delegate_ = ExtensionsBrowserClient::Get()->CreateRuntimeAPIDelegate( 148 delegate_ = ExtensionsBrowserClient::Get()->CreateRuntimeAPIDelegate(
149 browser_context_); 149 browser_context_);
150 150
151 // Check if registered events are up-to-date. We can only do this once 151 // Check if registered events are up-to-date. We can only do this once
152 // per browser context, since it updates internal state when called. 152 // per browser context, since it updates internal state when called.
153 dispatch_chrome_updated_event_ = 153 dispatch_chrome_updated_event_ =
154 ExtensionsBrowserClient::Get()->DidVersionUpdate(browser_context_); 154 ExtensionsBrowserClient::Get()->DidVersionUpdate(browser_context_);
155 } 155 }
156 156
157 RuntimeAPI::~RuntimeAPI() { 157 RuntimeAPI::~RuntimeAPI() {
158 delegate_->RemoveUpdateObserver(this); 158 delegate_->RemoveUpdateObserver(this);
159 } 159 }
160 160
161 void RuntimeAPI::Observe(int type, 161 void RuntimeAPI::Observe(int type,
162 const content::NotificationSource& source, 162 const content::NotificationSource& source,
163 const content::NotificationDetails& details) { 163 const content::NotificationDetails& details) {
164 DCHECK_EQ(chrome::NOTIFICATION_EXTENSIONS_READY, type); 164 DCHECK_EQ(extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED, type);
165 // We're done restarting Chrome after an update. 165 // We're done restarting Chrome after an update.
166 dispatch_chrome_updated_event_ = false; 166 dispatch_chrome_updated_event_ = false;
167 167
168 delegate_->AddUpdateObserver(this); 168 delegate_->AddUpdateObserver(this);
169 169
170 // RuntimeAPI is redirected in incognito, so |browser_context_| is never 170 // RuntimeAPI is redirected in incognito, so |browser_context_| is never
171 // incognito. We don't observe incognito ProcessManagers but that is OK 171 // incognito. We don't observe incognito ProcessManagers but that is OK
172 // because we don't send onStartup events to incognito browser contexts. 172 // because we don't send onStartup events to incognito browser contexts.
173 DCHECK(!browser_context_->IsOffTheRecord()); 173 DCHECK(!browser_context_->IsOffTheRecord());
174 // Some tests use partially constructed Profiles without a process manager. 174 // Some tests use partially constructed Profiles without a process manager.
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 content::ChildProcessSecurityPolicy* policy = 511 content::ChildProcessSecurityPolicy* policy =
512 content::ChildProcessSecurityPolicy::GetInstance(); 512 content::ChildProcessSecurityPolicy::GetInstance();
513 policy->GrantReadFileSystem(renderer_id, filesystem_id); 513 policy->GrantReadFileSystem(renderer_id, filesystem_id);
514 base::DictionaryValue* dict = new base::DictionaryValue(); 514 base::DictionaryValue* dict = new base::DictionaryValue();
515 dict->SetString("fileSystemId", filesystem_id); 515 dict->SetString("fileSystemId", filesystem_id);
516 dict->SetString("baseName", relative_path); 516 dict->SetString("baseName", relative_path);
517 return RespondNow(OneArgument(dict)); 517 return RespondNow(OneArgument(dict));
518 } 518 }
519 519
520 } // namespace extensions 520 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/api_resource_manager.h ('k') | extensions/browser/api/runtime/runtime_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698