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

Side by Side Diff: chrome/test/base/extension_load_waiter_one_shot.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 "chrome/test/base/extension_load_waiter_one_shot.h" 5 #include "chrome/test/base/extension_load_waiter_one_shot.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/common/extensions/extension_constants.h" 9 #include "chrome/common/extensions/extension_constants.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/notification_service.h" 11 #include "content/public/browser/notification_service.h"
12 #include "extensions/browser/extension_host.h" 12 #include "extensions/browser/extension_host.h"
13 13
14 ExtensionLoadWaiterOneShot::ExtensionLoadWaiterOneShot() : extension_id_(NULL), 14 ExtensionLoadWaiterOneShot::ExtensionLoadWaiterOneShot() : extension_id_(NULL),
15 browser_context_(NULL) { 15 browser_context_(NULL) {
16 } 16 }
17 17
18 ExtensionLoadWaiterOneShot::~ExtensionLoadWaiterOneShot() { 18 ExtensionLoadWaiterOneShot::~ExtensionLoadWaiterOneShot() {
19 } 19 }
20 20
21 void ExtensionLoadWaiterOneShot::WaitForExtension(const char* extension_id, 21 void ExtensionLoadWaiterOneShot::WaitForExtension(const char* extension_id,
22 const base::Closure& load_cb) { 22 const base::Closure& load_cb) {
23 CHECK(!extension_id_) << 23 CHECK(!extension_id_) <<
24 "ExtensionLoadWaiterOneShot should only be used once."; 24 "ExtensionLoadWaiterOneShot should only be used once.";
25 extension_id_ = extension_id; 25 extension_id_ = extension_id;
26 load_looper_ = new content::MessageLoopRunner(); 26 load_looper_ = new content::MessageLoopRunner();
27 registrar_.Add(this, 27 registrar_.Add(this,
28 chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, 28 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
29 content::NotificationService::AllSources()); 29 content::NotificationService::AllSources());
30 load_cb.Run(); 30 load_cb.Run();
31 load_looper_->Run(); 31 load_looper_->Run();
32 } 32 }
33 33
34 void ExtensionLoadWaiterOneShot::Observe(int type, 34 void ExtensionLoadWaiterOneShot::Observe(int type,
35 const content::NotificationSource& source, 35 const content::NotificationSource& source,
36 const content::NotificationDetails& details) { 36 const content::NotificationDetails& details) {
37 switch (type) { 37 switch (type) {
38 case chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: { 38 case extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: {
39 extensions::ExtensionHost* host = 39 extensions::ExtensionHost* host =
40 content::Details<extensions::ExtensionHost>(details).ptr(); 40 content::Details<extensions::ExtensionHost>(details).ptr();
41 if (host->extension_id() == extension_id_) { 41 if (host->extension_id() == extension_id_) {
42 browser_context_ = host->browser_context(); 42 browser_context_ = host->browser_context();
43 CHECK(browser_context_); 43 CHECK(browser_context_);
44 registrar_.Remove(this, 44 registrar_.Remove(
45 chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, 45 this,
46 content::NotificationService::AllSources()); 46 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
47 content::NotificationService::AllSources());
47 load_looper_->Quit(); 48 load_looper_->Quit();
48 } 49 }
49 break; 50 break;
50 } 51 }
51 } 52 }
52 } 53 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/uber/uber_ui.cc ('k') | chrome/test/remoting/remote_desktop_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698