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

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

Issue 8116015: Now closes existing background contents if app opens a new one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed presubmit error (added license header to js file) Created 9 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/extensions/app_background_page_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 DCHECK(extensions_service); 347 DCHECK(extensions_service);
348 for (DictionaryValue::key_iterator it = contents->begin_keys(); 348 for (DictionaryValue::key_iterator it = contents->begin_keys();
349 it != contents->end_keys(); ++it) { 349 it != contents->end_keys(); ++it) {
350 // Check to make sure that the parent extension is still enabled. 350 // Check to make sure that the parent extension is still enabled.
351 const Extension* extension = extensions_service->GetExtensionById( 351 const Extension* extension = extensions_service->GetExtensionById(
352 *it, false); 352 *it, false);
353 if (!extension) { 353 if (!extension) {
354 // We should never reach here - it should not be possible for an app 354 // We should never reach here - it should not be possible for an app
355 // to become uninstalled without the associated BackgroundContents being 355 // to become uninstalled without the associated BackgroundContents being
356 // unregistered via the EXTENSIONS_UNLOADED notification, unless there's a 356 // unregistered via the EXTENSIONS_UNLOADED notification, unless there's a
357 // crash before we could save our prefs. 357 // crash before we could save our prefs, or if the user deletes the
358 // extension files manually rather than uninstalling it.
358 NOTREACHED() << "No extension found for BackgroundContents - id = " 359 NOTREACHED() << "No extension found for BackgroundContents - id = "
359 << *it; 360 << *it;
360 return; 361 // Don't cancel out of our loop, just ignore this BackgroundContents and
362 // load the next one.
363 continue;
361 } 364 }
362 LoadBackgroundContentsFromDictionary(profile, *it, contents); 365 LoadBackgroundContentsFromDictionary(profile, *it, contents);
363 } 366 }
364 } 367 }
365 368
366 void BackgroundContentsService::LoadBackgroundContentsForExtension( 369 void BackgroundContentsService::LoadBackgroundContentsForExtension(
367 Profile* profile, 370 Profile* profile,
368 const std::string& extension_id) { 371 const std::string& extension_id) {
369 // First look if the manifest specifies a background page. 372 // First look if the manifest specifies a background page.
370 const Extension* extension = 373 const Extension* extension =
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 TabContents* new_contents, 576 TabContents* new_contents,
574 WindowOpenDisposition disposition, 577 WindowOpenDisposition disposition,
575 const gfx::Rect& initial_pos, 578 const gfx::Rect& initial_pos,
576 bool user_gesture) { 579 bool user_gesture) {
577 Browser* browser = BrowserList::GetLastActiveWithProfile( 580 Browser* browser = BrowserList::GetLastActiveWithProfile(
578 Profile::FromBrowserContext(new_contents->browser_context())); 581 Profile::FromBrowserContext(new_contents->browser_context()));
579 if (!browser) 582 if (!browser)
580 return; 583 return;
581 browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture); 584 browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture);
582 } 585 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/app_background_page_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698