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

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

Issue 7012031: Fix a couple of crashes related to app-crashed balloon. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ;; Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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_contents_service.h" 5 #include "chrome/browser/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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 59
60 void Display() {} 60 void Display() {}
61 61
62 void Error() {} 62 void Error() {}
63 63
64 void Close(bool by_user) {} 64 void Close(bool by_user) {}
65 65
66 void Click() { 66 void Click() {
67 if (is_hosted_app_) { 67 if (is_hosted_app_) {
68 BackgroundContentsServiceFactory::GetForProfile(profile_)-> 68 BackgroundContentsServiceFactory::GetForProfile(profile_)->
Andrew T Wilson (Slow) 2011/05/15 16:58:08 So, it seems like there's still a race condition t
sadrul 2011/05/15 17:56:54 Done (added the check in here).
69 LoadBackgroundContentsForExtension(profile_, extension_id_); 69 LoadBackgroundContentsForExtension(profile_, extension_id_);
70 } else { 70 } else {
71 profile_->GetExtensionService()->ReloadExtension(extension_id_); 71 profile_->GetExtensionService()->ReloadExtension(extension_id_);
72 } 72 }
73 73
74 // Closing the balloon here should be OK, but it causes a crash on Mac 74 // Closing the balloon here should be OK, but it causes a crash on Mac
75 // http://crbug.com/78167 75 // http://crbug.com/78167
76 ScheduleCloseBalloon(extension_id_); 76 ScheduleCloseBalloon(extension_id_);
77 } 77 }
78 78
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 Profile* profile = Source<Profile>(source).ptr(); 222 Profile* profile = Source<Profile>(source).ptr();
223 const string16& appid = GetParentApplicationId(bgcontents); 223 const string16& appid = GetParentApplicationId(bgcontents);
224 ExtensionService* extension_service = profile->GetExtensionService(); 224 ExtensionService* extension_service = profile->GetExtensionService();
225 // extension_service can be NULL when running tests. 225 // extension_service can be NULL when running tests.
226 if (extension_service) { 226 if (extension_service) {
227 const Extension* extension = 227 const Extension* extension =
228 extension_service->GetExtensionById(UTF16ToUTF8(appid), false); 228 extension_service->GetExtensionById(UTF16ToUTF8(appid), false);
229 if (extension && extension->background_url().is_valid()) 229 if (extension && extension->background_url().is_valid())
230 break; 230 break;
231 } 231 }
232 RegisterBackgroundContents(Details<BackgroundContents>(details).ptr()); 232 RegisterBackgroundContents(bgcontents);
233 break; 233 break;
234 } 234 }
235 case NotificationType::EXTENSION_LOADED: { 235 case NotificationType::EXTENSION_LOADED: {
236 const Extension* extension = Details<const Extension>(details).ptr(); 236 const Extension* extension = Details<const Extension>(details).ptr();
237 Profile* profile = Source<Profile>(source).ptr(); 237 Profile* profile = Source<Profile>(source).ptr();
238 if (extension->is_hosted_app() && 238 if (extension->is_hosted_app() &&
239 extension->background_url().is_valid()) { 239 extension->background_url().is_valid()) {
240 // If there is a background page specified in the manifest for a hosted 240 // If there is a background page specified in the manifest for a hosted
241 // app, then blow away registered urls in the pref. 241 // app, then blow away registered urls in the pref.
242 ShutdownAssociatedBackgroundContents(ASCIIToUTF16(extension->id())); 242 ShutdownAssociatedBackgroundContents(ASCIIToUTF16(extension->id()));
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 380 }
381 381
382 void BackgroundContentsService::LoadBackgroundContentsFromDictionary( 382 void BackgroundContentsService::LoadBackgroundContentsFromDictionary(
383 Profile* profile, 383 Profile* profile,
384 const std::string& extension_id, 384 const std::string& extension_id,
385 const DictionaryValue* contents) { 385 const DictionaryValue* contents) {
386 ExtensionService* extensions_service = profile->GetExtensionService(); 386 ExtensionService* extensions_service = profile->GetExtensionService();
387 DCHECK(extensions_service); 387 DCHECK(extensions_service);
388 388
389 DictionaryValue* dict; 389 DictionaryValue* dict;
390 contents->GetDictionaryWithoutPathExpansion(extension_id, &dict); 390 if (!contents->GetDictionaryWithoutPathExpansion(extension_id, &dict) ||
391 if (dict == NULL) 391 dict == NULL)
392 return; 392 return;
393
393 string16 frame_name; 394 string16 frame_name;
394 std::string url; 395 std::string url;
395 dict->GetString(kUrlKey, &url); 396 dict->GetString(kUrlKey, &url);
396 dict->GetString(kFrameNameKey, &frame_name); 397 dict->GetString(kFrameNameKey, &frame_name);
397 LoadBackgroundContents(profile, 398 LoadBackgroundContents(profile,
398 GURL(url), 399 GURL(url),
399 frame_name, 400 frame_name,
400 UTF8ToUTF16(extension_id)); 401 UTF8ToUTF16(extension_id));
401 } 402 }
402 403
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 } 512 }
512 } 513 }
513 514
514 void BackgroundContentsService::BackgroundContentsOpened( 515 void BackgroundContentsService::BackgroundContentsOpened(
515 BackgroundContentsOpenedDetails* details) { 516 BackgroundContentsOpenedDetails* details) {
516 // Add the passed object to our list. Should not already be tracked. 517 // Add the passed object to our list. Should not already be tracked.
517 DCHECK(!IsTracked(details->contents)); 518 DCHECK(!IsTracked(details->contents));
518 DCHECK(!details->application_id.empty()); 519 DCHECK(!details->application_id.empty());
519 contents_map_[details->application_id].contents = details->contents; 520 contents_map_[details->application_id].contents = details->contents;
520 contents_map_[details->application_id].frame_name = details->frame_name; 521 contents_map_[details->application_id].frame_name = details->frame_name;
522
523 ScheduleCloseBalloon(UTF16ToASCII(details->application_id));
521 } 524 }
522 525
523 // Used by test code and debug checks to verify whether a given 526 // Used by test code and debug checks to verify whether a given
524 // BackgroundContents is being tracked by this instance. 527 // BackgroundContents is being tracked by this instance.
525 bool BackgroundContentsService::IsTracked( 528 bool BackgroundContentsService::IsTracked(
526 BackgroundContents* background_contents) const { 529 BackgroundContents* background_contents) const {
527 return !GetParentApplicationId(background_contents).empty(); 530 return !GetParentApplicationId(background_contents).empty();
528 } 531 }
529 532
530 void BackgroundContentsService::BackgroundContentsShutdown( 533 void BackgroundContentsService::BackgroundContentsShutdown(
(...skipping 30 matching lines...) Expand all
561 TabContents* new_contents, 564 TabContents* new_contents,
562 WindowOpenDisposition disposition, 565 WindowOpenDisposition disposition,
563 const gfx::Rect& initial_pos, 566 const gfx::Rect& initial_pos,
564 bool user_gesture) { 567 bool user_gesture) {
565 Browser* browser = BrowserList::GetLastActiveWithProfile( 568 Browser* browser = BrowserList::GetLastActiveWithProfile(
566 new_contents->profile()); 569 new_contents->profile());
567 if (!browser) 570 if (!browser)
568 return; 571 return;
569 browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture); 572 browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture);
570 } 573 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698