OLD | NEW |
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/tab_contents/background_contents.h" | 5 #include "chrome/browser/tab_contents/background_contents.h" |
6 | 6 |
7 #include "chrome/browser/background/background_contents_service.h" | 7 #include "chrome/browser/background/background_contents_service.h" |
8 #include "chrome/browser/extensions/extension_message_service.h" | 8 #include "chrome/browser/extensions/extension_message_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/renderer_preferences_util.h" | 10 #include "chrome/browser/renderer_preferences_util.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // available as a part of the web platform, it probably makes sense to have | 87 // available as a part of the web platform, it probably makes sense to have |
88 // some way to scope navigation of a background page to its opener's security | 88 // some way to scope navigation of a background page to its opener's security |
89 // origin. Note: if the first navigation is to a URL outside the app's | 89 // origin. Note: if the first navigation is to a URL outside the app's |
90 // extent a background page will be opened but will remain at about:blank. | 90 // extent a background page will be opened but will remain at about:blank. |
91 content::NotificationService::current()->Notify( | 91 content::NotificationService::current()->Notify( |
92 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, | 92 chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, |
93 content::Source<Profile>(profile_), | 93 content::Source<Profile>(profile_), |
94 content::Details<BackgroundContents>(this)); | 94 content::Details<BackgroundContents>(this)); |
95 } | 95 } |
96 | 96 |
97 void BackgroundContents::RenderViewGone() { | 97 void BackgroundContents::RenderViewGone(base::TerminationStatus status) { |
98 content::NotificationService::current()->Notify( | 98 content::NotificationService::current()->Notify( |
99 chrome::NOTIFICATION_BACKGROUND_CONTENTS_TERMINATED, | 99 chrome::NOTIFICATION_BACKGROUND_CONTENTS_TERMINATED, |
100 content::Source<Profile>(profile_), | 100 content::Source<Profile>(profile_), |
101 content::Details<BackgroundContents>(this)); | 101 content::Details<BackgroundContents>(this)); |
102 | 102 |
103 // Our RenderView went away, so we should go away also, so killing the process | 103 // Our RenderView went away, so we should go away also, so killing the process |
104 // via the TaskManager doesn't permanently leave a BackgroundContents hanging | 104 // via the TaskManager doesn't permanently leave a BackgroundContents hanging |
105 // around the system, blocking future instances from being created | 105 // around the system, blocking future instances from being created |
106 // (http://crbug.com/65189). | 106 // <http://crbug.com/65189>. |
107 delete this; | 107 delete this; |
108 } | 108 } |
109 | 109 |
110 void BackgroundContents::Observe(int type, | 110 void BackgroundContents::Observe(int type, |
111 const content::NotificationSource& source, | 111 const content::NotificationSource& source, |
112 const content::NotificationDetails& details) { | 112 const content::NotificationDetails& details) { |
113 // TODO(rafaelw): Implement pagegroup ref-counting so that non-persistent | 113 // TODO(rafaelw): Implement pagegroup ref-counting so that non-persistent |
114 // background pages are closed when the last referencing frame is closed. | 114 // background pages are closed when the last referencing frame is closed. |
115 switch (type) { | 115 switch (type) { |
116 case chrome::NOTIFICATION_PROFILE_DESTROYED: | 116 case chrome::NOTIFICATION_PROFILE_DESTROYED: |
117 case content::NOTIFICATION_APP_TERMINATING: { | 117 case content::NOTIFICATION_APP_TERMINATING: { |
118 delete this; | 118 delete this; |
119 break; | 119 break; |
120 } | 120 } |
121 default: | 121 default: |
122 NOTREACHED() << "Unexpected notification sent."; | 122 NOTREACHED() << "Unexpected notification sent."; |
123 break; | 123 break; |
124 } | 124 } |
125 } | 125 } |
OLD | NEW |