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