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/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/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 9 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 void BackgroundContents::AddNewContents(WebContents* source, | 116 void BackgroundContents::AddNewContents(WebContents* source, |
117 WebContents* new_contents, | 117 WebContents* new_contents, |
118 WindowOpenDisposition disposition, | 118 WindowOpenDisposition disposition, |
119 const gfx::Rect& initial_pos, | 119 const gfx::Rect& initial_pos, |
120 bool user_gesture, | 120 bool user_gesture, |
121 bool* was_blocked) { | 121 bool* was_blocked) { |
122 delegate_->AddWebContents( | 122 delegate_->AddWebContents( |
123 new_contents, disposition, initial_pos, user_gesture, was_blocked); | 123 new_contents, disposition, initial_pos, user_gesture, was_blocked); |
124 } | 124 } |
125 | 125 |
| 126 bool BackgroundContents::IsNeverVisible(content::WebContents* web_contents) { |
| 127 DCHECK_EQ(extensions::VIEW_TYPE_BACKGROUND_CONTENTS, |
| 128 extensions::GetViewType(web_contents)); |
| 129 return true; |
| 130 } |
| 131 |
126 void BackgroundContents::RenderProcessGone(base::TerminationStatus status) { | 132 void BackgroundContents::RenderProcessGone(base::TerminationStatus status) { |
127 content::NotificationService::current()->Notify( | 133 content::NotificationService::current()->Notify( |
128 chrome::NOTIFICATION_BACKGROUND_CONTENTS_TERMINATED, | 134 chrome::NOTIFICATION_BACKGROUND_CONTENTS_TERMINATED, |
129 content::Source<Profile>(profile_), | 135 content::Source<Profile>(profile_), |
130 content::Details<BackgroundContents>(this)); | 136 content::Details<BackgroundContents>(this)); |
131 | 137 |
132 // Our RenderView went away, so we should go away also, so killing the process | 138 // Our RenderView went away, so we should go away also, so killing the process |
133 // via the TaskManager doesn't permanently leave a BackgroundContents hanging | 139 // via the TaskManager doesn't permanently leave a BackgroundContents hanging |
134 // around the system, blocking future instances from being created | 140 // around the system, blocking future instances from being created |
135 // <http://crbug.com/65189>. | 141 // <http://crbug.com/65189>. |
136 delete this; | 142 delete this; |
137 } | 143 } |
138 | 144 |
139 void BackgroundContents::Observe(int type, | 145 void BackgroundContents::Observe(int type, |
140 const content::NotificationSource& source, | 146 const content::NotificationSource& source, |
141 const content::NotificationDetails& details) { | 147 const content::NotificationDetails& details) { |
142 // TODO(rafaelw): Implement pagegroup ref-counting so that non-persistent | 148 // TODO(rafaelw): Implement pagegroup ref-counting so that non-persistent |
143 // background pages are closed when the last referencing frame is closed. | 149 // background pages are closed when the last referencing frame is closed. |
144 switch (type) { | 150 switch (type) { |
145 case chrome::NOTIFICATION_PROFILE_DESTROYED: | 151 case chrome::NOTIFICATION_PROFILE_DESTROYED: |
146 case chrome::NOTIFICATION_APP_TERMINATING: { | 152 case chrome::NOTIFICATION_APP_TERMINATING: { |
147 delete this; | 153 delete this; |
148 break; | 154 break; |
149 } | 155 } |
150 default: | 156 default: |
151 NOTREACHED() << "Unexpected notification sent."; | 157 NOTREACHED() << "Unexpected notification sent."; |
152 break; | 158 break; |
153 } | 159 } |
154 } | 160 } |
OLD | NEW |