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/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" |
11 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 11 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
| 12 #include "chrome/browser/view_type_utils.h" |
12 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
13 #include "chrome/common/chrome_view_type.h" | |
14 #include "chrome/common/extensions/extension_constants.h" | 14 #include "chrome/common/extensions/extension_constants.h" |
15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
17 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
18 #include "content/public/browser/site_instance.h" | 18 #include "content/public/browser/site_instance.h" |
19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
20 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
21 | 21 |
22 using content::SiteInstance; | 22 using content::SiteInstance; |
23 using content::WebContents; | 23 using content::WebContents; |
24 | 24 |
25 BackgroundContents::BackgroundContents(SiteInstance* site_instance, | 25 BackgroundContents::BackgroundContents(SiteInstance* site_instance, |
26 int routing_id, | 26 int routing_id, |
27 Delegate* delegate) | 27 Delegate* delegate) |
28 : delegate_(delegate) { | 28 : delegate_(delegate) { |
29 profile_ = Profile::FromBrowserContext( | 29 profile_ = Profile::FromBrowserContext( |
30 site_instance->GetBrowserContext()); | 30 site_instance->GetBrowserContext()); |
31 | 31 |
32 // TODO(rafaelw): Implement correct session storage. | 32 // TODO(rafaelw): Implement correct session storage. |
33 web_contents_.reset(WebContents::Create( | 33 web_contents_.reset(WebContents::Create( |
34 profile_, site_instance, routing_id, NULL, NULL)); | 34 profile_, site_instance, routing_id, NULL, NULL)); |
35 web_contents_->SetViewType(chrome::VIEW_TYPE_BACKGROUND_CONTENTS); | 35 chrome::SetViewType( |
| 36 web_contents_.get(), chrome::VIEW_TYPE_BACKGROUND_CONTENTS); |
36 web_contents_->SetDelegate(this); | 37 web_contents_->SetDelegate(this); |
37 content::WebContentsObserver::Observe(web_contents_.get()); | 38 content::WebContentsObserver::Observe(web_contents_.get()); |
38 | 39 |
39 // Close ourselves when the application is shutting down. | 40 // Close ourselves when the application is shutting down. |
40 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, | 41 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, |
41 content::NotificationService::AllSources()); | 42 content::NotificationService::AllSources()); |
42 | 43 |
43 // Register for our parent profile to shutdown, so we can shut ourselves down | 44 // Register for our parent profile to shutdown, so we can shut ourselves down |
44 // as well (should only be called for OTR profiles, as we should receive | 45 // as well (should only be called for OTR profiles, as we should receive |
45 // APP_TERMINATING before non-OTR profiles are destroyed). | 46 // APP_TERMINATING before non-OTR profiles are destroyed). |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 case chrome::NOTIFICATION_PROFILE_DESTROYED: | 125 case chrome::NOTIFICATION_PROFILE_DESTROYED: |
125 case content::NOTIFICATION_APP_TERMINATING: { | 126 case content::NOTIFICATION_APP_TERMINATING: { |
126 delete this; | 127 delete this; |
127 break; | 128 break; |
128 } | 129 } |
129 default: | 130 default: |
130 NOTREACHED() << "Unexpected notification sent."; | 131 NOTREACHED() << "Unexpected notification sent."; |
131 break; | 132 break; |
132 } | 133 } |
133 } | 134 } |
OLD | NEW |