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