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

Side by Side Diff: chrome/browser/background/background_contents_service.cc

Issue 10375021: Move Extension into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Take 6 Created 8 years, 7 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/background/background_contents_service.h" 5 #include "chrome/browser/background/background_contents_service.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 19 matching lines...) Expand all
30 #include "chrome/common/extensions/extension_constants.h" 30 #include "chrome/common/extensions/extension_constants.h"
31 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
32 #include "content/public/browser/notification_service.h" 32 #include "content/public/browser/notification_service.h"
33 #include "content/public/browser/site_instance.h" 33 #include "content/public/browser/site_instance.h"
34 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
35 #include "grit/generated_resources.h" 35 #include "grit/generated_resources.h"
36 #include "ui/base/l10n/l10n_util.h" 36 #include "ui/base/l10n/l10n_util.h"
37 37
38 using content::SiteInstance; 38 using content::SiteInstance;
39 using content::WebContents; 39 using content::WebContents;
40 using extensions::Extension;
41 using extensions::UnloadedExtensionInfo;
40 42
41 namespace { 43 namespace {
42 44
43 const char kNotificationPrefix[] = "app.background.crashed."; 45 const char kNotificationPrefix[] = "app.background.crashed.";
44 46
45 void CloseBalloon(const std::string id) { 47 void CloseBalloon(const std::string id) {
46 g_browser_process->notification_ui_manager()->CancelById(id); 48 g_browser_process->notification_ui_manager()->CancelById(id);
47 } 49 }
48 50
49 void ScheduleCloseBalloon(const std::string& extension_id) { 51 void ScheduleCloseBalloon(const std::string& extension_id) {
50 if (!MessageLoop::current()) // For unit_tests 52 if (!MessageLoop::current()) // For unit_tests
51 return; 53 return;
52 MessageLoop::current()->PostTask( 54 MessageLoop::current()->PostTask(
53 FROM_HERE, base::Bind(&CloseBalloon, kNotificationPrefix + extension_id)); 55 FROM_HERE, base::Bind(&CloseBalloon, kNotificationPrefix + extension_id));
54 } 56 }
55 57
56 class CrashNotificationDelegate : public NotificationDelegate { 58 class CrashNotificationDelegate : public NotificationDelegate {
57 public: 59 public:
58 CrashNotificationDelegate(Profile* profile, const Extension* extension) 60 CrashNotificationDelegate(Profile* profile,
61 const Extension* extension)
59 : profile_(profile), 62 : profile_(profile),
60 is_hosted_app_(extension->is_hosted_app()), 63 is_hosted_app_(extension->is_hosted_app()),
61 extension_id_(extension->id()) { 64 extension_id_(extension->id()) {
62 } 65 }
63 66
64 void Display() {} 67 void Display() {}
65 68
66 void Error() {} 69 void Error() {}
67 70
68 void Close(bool by_user) {} 71 void Close(bool by_user) {}
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 return; 362 return;
360 const DictionaryValue* contents = 363 const DictionaryValue* contents =
361 prefs_->GetDictionary(prefs::kRegisteredBackgroundContents); 364 prefs_->GetDictionary(prefs::kRegisteredBackgroundContents);
362 if (!contents) 365 if (!contents)
363 return; 366 return;
364 ExtensionService* extensions_service = profile->GetExtensionService(); 367 ExtensionService* extensions_service = profile->GetExtensionService();
365 DCHECK(extensions_service); 368 DCHECK(extensions_service);
366 for (DictionaryValue::key_iterator it = contents->begin_keys(); 369 for (DictionaryValue::key_iterator it = contents->begin_keys();
367 it != contents->end_keys(); ++it) { 370 it != contents->end_keys(); ++it) {
368 // Check to make sure that the parent extension is still enabled. 371 // Check to make sure that the parent extension is still enabled.
369 const Extension* extension = extensions_service->GetExtensionById( 372 const Extension* extension = extensions_service->
370 *it, false); 373 GetExtensionById(*it, false);
371 if (!extension) { 374 if (!extension) {
372 // We should never reach here - it should not be possible for an app 375 // We should never reach here - it should not be possible for an app
373 // to become uninstalled without the associated BackgroundContents being 376 // to become uninstalled without the associated BackgroundContents being
374 // unregistered via the EXTENSIONS_UNLOADED notification, unless there's a 377 // unregistered via the EXTENSIONS_UNLOADED notification, unless there's a
375 // crash before we could save our prefs, or if the user deletes the 378 // crash before we could save our prefs, or if the user deletes the
376 // extension files manually rather than uninstalling it. 379 // extension files manually rather than uninstalling it.
377 NOTREACHED() << "No extension found for BackgroundContents - id = " 380 NOTREACHED() << "No extension found for BackgroundContents - id = "
378 << *it; 381 << *it;
379 // Don't cancel out of our loop, just ignore this BackgroundContents and 382 // Don't cancel out of our loop, just ignore this BackgroundContents and
380 // load the next one. 383 // load the next one.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 WebContents* new_contents, 607 WebContents* new_contents,
605 WindowOpenDisposition disposition, 608 WindowOpenDisposition disposition,
606 const gfx::Rect& initial_pos, 609 const gfx::Rect& initial_pos,
607 bool user_gesture) { 610 bool user_gesture) {
608 Browser* browser = browser::FindLastActiveWithProfile( 611 Browser* browser = browser::FindLastActiveWithProfile(
609 Profile::FromBrowserContext(new_contents->GetBrowserContext())); 612 Profile::FromBrowserContext(new_contents->GetBrowserContext()));
610 if (!browser) 613 if (!browser)
611 return; 614 return;
612 browser->AddWebContents(new_contents, disposition, initial_pos, user_gesture); 615 browser->AddWebContents(new_contents, disposition, initial_pos, user_gesture);
613 } 616 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698