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

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

Issue 16844020: app_mode: Add runtime.onRestartRequired event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use generated api code Created 7 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 | Annotate | Revision Log
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/api/runtime/runtime_api.h" 5 #include "chrome/browser/extensions/api/runtime/runtime_api.h"
6 6
7 #include <utility>
8
9 #include "base/logging.h"
7 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/values.h"
8 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/extensions/event_router.h" 13 #include "chrome/browser/extensions/event_router.h"
10 #include "chrome/browser/extensions/extension_host.h" 14 #include "chrome/browser/extensions/extension_host.h"
11 #include "chrome/browser/extensions/extension_process_manager.h" 15 #include "chrome/browser/extensions/extension_process_manager.h"
12 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/extension_system.h" 17 #include "chrome/browser/extensions/extension_system.h"
14 #include "chrome/browser/extensions/lazy_background_task_queue.h" 18 #include "chrome/browser/extensions/lazy_background_task_queue.h"
15 #include "chrome/browser/extensions/updater/extension_updater.h" 19 #include "chrome/browser/extensions/updater/extension_updater.h"
16 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/browser/ui/browser_finder.h" 22 #include "chrome/browser/ui/browser_finder.h"
19 #include "chrome/browser/ui/browser_navigator.h" 23 #include "chrome/browser/ui/browser_navigator.h"
20 #include "chrome/browser/ui/browser_window.h" 24 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/common/extensions/api/runtime.h"
22 #include "chrome/common/extensions/background_info.h" 25 #include "chrome/common/extensions/background_info.h"
23 #include "chrome/common/extensions/extension.h" 26 #include "chrome/common/extensions/extension.h"
24 #include "chrome/common/omaha_query_params/omaha_query_params.h" 27 #include "chrome/common/omaha_query_params/omaha_query_params.h"
25 #include "extensions/common/error_utils.h" 28 #include "extensions/common/error_utils.h"
26 #include "googleurl/src/gurl.h" 29 #include "googleurl/src/gurl.h"
27 30
28 namespace GetPlatformInfo = extensions::api::runtime::GetPlatformInfo; 31 namespace GetPlatformInfo = extensions::api::runtime::GetPlatformInfo;
29 32
30 namespace extensions { 33 namespace extensions {
31 34
32 namespace { 35 namespace {
33 36
34 const char kOnStartupEvent[] = "runtime.onStartup"; 37 const char kOnStartupEvent[] = "runtime.onStartup";
35 const char kOnInstalledEvent[] = "runtime.onInstalled"; 38 const char kOnInstalledEvent[] = "runtime.onInstalled";
36 const char kOnUpdateAvailableEvent[] = "runtime.onUpdateAvailable"; 39 const char kOnUpdateAvailableEvent[] = "runtime.onUpdateAvailable";
37 const char kOnBrowserUpdateAvailableEvent[] = 40 const char kOnBrowserUpdateAvailableEvent[] =
38 "runtime.onBrowserUpdateAvailable"; 41 "runtime.onBrowserUpdateAvailable";
42 const char kOnRestartRequiredEvent[] = "runtime.onRestartRequired";
39 const char kNoBackgroundPageError[] = "You do not have a background page."; 43 const char kNoBackgroundPageError[] = "You do not have a background page.";
40 const char kPageLoadError[] = "Background page failed to load."; 44 const char kPageLoadError[] = "Background page failed to load.";
41 const char kInstallReason[] = "reason"; 45 const char kInstallReason[] = "reason";
42 const char kInstallReasonChromeUpdate[] = "chrome_update"; 46 const char kInstallReasonChromeUpdate[] = "chrome_update";
43 const char kInstallReasonUpdate[] = "update"; 47 const char kInstallReasonUpdate[] = "update";
44 const char kInstallReasonInstall[] = "install"; 48 const char kInstallReasonInstall[] = "install";
45 const char kInstallPreviousVersion[] = "previousVersion"; 49 const char kInstallPreviousVersion[] = "previousVersion";
46 const char kInvalidUrlError[] = "Invalid URL."; 50 const char kInvalidUrlError[] = "Invalid URL.";
51 const char kRestartReasonAppUpdate[] = "app_update";
52 const char kRestartReasonOsUpdate[] = "os_update";
53 const char kRestartReasonPeriodic[] = "periodic";
Matt Perry 2013/06/21 22:43:32 no longer needed
xiyuan 2013/06/21 22:57:17 Removed.
47 const char kUpdatesDisabledError[] = "Autoupdate is not enabled."; 54 const char kUpdatesDisabledError[] = "Autoupdate is not enabled.";
48 const char kUpdateFound[] = "update_available"; 55 const char kUpdateFound[] = "update_available";
49 const char kUpdateNotFound[] = "no_update"; 56 const char kUpdateNotFound[] = "no_update";
50 const char kUpdateThrottled[] = "throttled"; 57 const char kUpdateThrottled[] = "throttled";
51 58
52 // A preference key storing the url loaded when an extension is uninstalled. 59 // A preference key storing the url loaded when an extension is uninstalled.
53 const char kUninstallUrl[] = "uninstall_url"; 60 const char kUninstallUrl[] = "uninstall_url";
54 61
55 static void DispatchOnStartupEventImpl( 62 static void DispatchOnStartupEventImpl(
56 Profile* profile, 63 Profile* profile,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 return; 182 return;
176 183
177 scoped_ptr<ListValue> args(new ListValue); 184 scoped_ptr<ListValue> args(new ListValue);
178 DCHECK(system->event_router()); 185 DCHECK(system->event_router());
179 scoped_ptr<Event> event(new Event(kOnBrowserUpdateAvailableEvent, 186 scoped_ptr<Event> event(new Event(kOnBrowserUpdateAvailableEvent,
180 args.Pass())); 187 args.Pass()));
181 system->event_router()->BroadcastEvent(event.Pass()); 188 system->event_router()->BroadcastEvent(event.Pass());
182 } 189 }
183 190
184 // static 191 // static
192 void RuntimeEventRouter::DispatchOnRestartRequiredEvent(
193 Profile* profile,
194 const std::string& app_id,
195 api::runtime::OnRestartRequired::Reason reason) {
196 ExtensionSystem* system = ExtensionSystem::Get(profile);
197 if (!system)
198 return;
199
200 scoped_ptr<Event> event(
201 new Event(kOnRestartRequiredEvent,
202 api::runtime::OnRestartRequired::Create(reason)));
203
204 DCHECK(system->event_router());
205 system->event_router()->DispatchEventToExtension(app_id, event.Pass());
206 }
207
208 // static
185 void RuntimeEventRouter::OnExtensionUninstalled( 209 void RuntimeEventRouter::OnExtensionUninstalled(
186 Profile *profile, 210 Profile* profile,
187 const std::string& extension_id) { 211 const std::string& extension_id) {
188 #if defined(ENABLE_EXTENSIONS) 212 #if defined(ENABLE_EXTENSIONS)
189 GURL uninstall_url(GetUninstallUrl(ExtensionPrefs::Get(profile), 213 GURL uninstall_url(GetUninstallUrl(ExtensionPrefs::Get(profile),
190 extension_id)); 214 extension_id));
191 215
192 if (uninstall_url.is_empty()) 216 if (uninstall_url.is_empty())
193 return; 217 return;
194 218
195 Browser* browser = chrome::FindLastActiveWithProfile(profile, 219 Browser* browser = chrome::FindLastActiveWithProfile(profile,
196 chrome::GetActiveDesktop()); 220 chrome::GetActiveDesktop());
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } else { 398 } else {
375 NOTREACHED(); 399 NOTREACHED();
376 return false; 400 return false;
377 } 401 }
378 402
379 results_ = GetPlatformInfo::Results::Create(info); 403 results_ = GetPlatformInfo::Results::Create(info);
380 return true; 404 return true;
381 } 405 }
382 406
383 } // namespace extensions 407 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698