| OLD | NEW |
| 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 "apps/app_load_service.h" | 7 #include "apps/app_load_service.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, | 327 registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, |
| 328 content::Source<Profile>(profile)); | 328 content::Source<Profile>(profile)); |
| 329 | 329 |
| 330 // Track when the BackgroundContents navigates to a new URL so we can update | 330 // Track when the BackgroundContents navigates to a new URL so we can update |
| 331 // our persisted information as appropriate. | 331 // our persisted information as appropriate. |
| 332 registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, | 332 registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, |
| 333 content::Source<Profile>(profile)); | 333 content::Source<Profile>(profile)); |
| 334 | 334 |
| 335 // Listen for new extension installs so that we can load any associated | 335 // Listen for new extension installs so that we can load any associated |
| 336 // background page. | 336 // background page. |
| 337 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 337 registrar_.Add(this, |
| 338 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 338 content::Source<Profile>(profile)); | 339 content::Source<Profile>(profile)); |
| 339 | 340 |
| 340 // Track when the extensions crash so that the user can be notified | 341 // Track when the extensions crash so that the user can be notified |
| 341 // about it, and the crashed contents can be restarted. | 342 // about it, and the crashed contents can be restarted. |
| 342 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 343 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
| 343 content::Source<Profile>(profile)); | 344 content::Source<Profile>(profile)); |
| 344 registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_TERMINATED, | 345 registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_TERMINATED, |
| 345 content::Source<Profile>(profile)); | 346 content::Source<Profile>(profile)); |
| 346 | 347 |
| 347 // Listen for extensions to be unloaded so we can shutdown associated | 348 // Listen for extensions to be unloaded so we can shutdown associated |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 // extension_service can be NULL when running tests. | 396 // extension_service can be NULL when running tests. |
| 396 if (extension_service) { | 397 if (extension_service) { |
| 397 const Extension* extension = extension_service->GetExtensionById( | 398 const Extension* extension = extension_service->GetExtensionById( |
| 398 base::UTF16ToUTF8(appid), false); | 399 base::UTF16ToUTF8(appid), false); |
| 399 if (extension && BackgroundInfo::HasBackgroundPage(extension)) | 400 if (extension && BackgroundInfo::HasBackgroundPage(extension)) |
| 400 break; | 401 break; |
| 401 } | 402 } |
| 402 RegisterBackgroundContents(bgcontents); | 403 RegisterBackgroundContents(bgcontents); |
| 403 break; | 404 break; |
| 404 } | 405 } |
| 405 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 406 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { |
| 406 const Extension* extension = | 407 const Extension* extension = |
| 407 content::Details<const Extension>(details).ptr(); | 408 content::Details<const Extension>(details).ptr(); |
| 408 Profile* profile = content::Source<Profile>(source).ptr(); | 409 Profile* profile = content::Source<Profile>(source).ptr(); |
| 409 if (extension->is_hosted_app() && | 410 if (extension->is_hosted_app() && |
| 410 BackgroundInfo::HasBackgroundPage(extension)) { | 411 BackgroundInfo::HasBackgroundPage(extension)) { |
| 411 // If there is a background page specified in the manifest for a hosted | 412 // If there is a background page specified in the manifest for a hosted |
| 412 // app, then blow away registered urls in the pref. | 413 // app, then blow away registered urls in the pref. |
| 413 ShutdownAssociatedBackgroundContents( | 414 ShutdownAssociatedBackgroundContents( |
| 414 base::ASCIIToUTF16(extension->id())); | 415 base::ASCIIToUTF16(extension->id())); |
| 415 | 416 |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 bool user_gesture, | 787 bool user_gesture, |
| 787 bool* was_blocked) { | 788 bool* was_blocked) { |
| 788 Browser* browser = chrome::FindLastActiveWithProfile( | 789 Browser* browser = chrome::FindLastActiveWithProfile( |
| 789 Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 790 Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
| 790 chrome::GetActiveDesktop()); | 791 chrome::GetActiveDesktop()); |
| 791 if (browser) { | 792 if (browser) { |
| 792 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 793 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
| 793 initial_pos, user_gesture, was_blocked); | 794 initial_pos, user_gesture, was_blocked); |
| 794 } | 795 } |
| 795 } | 796 } |
| OLD | NEW |