Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
|
Devlin
2015/07/30 17:56:46
Umm... this class doesn't do anything other than i
ltilve
2015/08/07 16:15:02
Done. We have refactored out sidebarContainer now.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/extensions/sidebar_container.h" | |
| 6 | |
| 7 #include "chrome/browser/chrome_notification_types.h" | |
| 8 #include "chrome/browser/extensions/extension_service.h" | |
| 9 #include "chrome/browser/extensions/extension_view_host_factory.h" | |
| 10 #include "chrome/browser/ui/browser.h" | |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 12 #include "content/public/browser/notification_details.h" | |
| 13 #include "content/public/browser/notification_source.h" | |
| 14 #include "content/public/browser/web_contents.h" | |
| 15 #include "url/gurl.h" | |
| 16 | |
| 17 namespace extensions { | |
| 18 SidebarContainer::SidebarContainer(Browser* browser, | |
| 19 content::WebContents* tab, | |
| 20 const GURL& url) | |
| 21 : host_(extensions::ExtensionViewHostFactory::CreateSidebarHost(url, | |
| 22 browser)), | |
| 23 tab_(tab), | |
| 24 browser_(browser), | |
| 25 tab_strip_model_observer_(this) { | |
| 26 // Listen for the containing view calling window.close(); | |
| 27 registrar_.Add( | |
| 28 this, extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, | |
| 29 content::Source<content::BrowserContext>(host_->browser_context())); | |
| 30 | |
| 31 host_->CreateRenderViewSoon(); | |
| 32 sidebar_contents()->SetInitialFocus(); | |
| 33 | |
| 34 tab_strip_model_observer_.Add(browser_->tab_strip_model()); | |
| 35 } | |
| 36 | |
| 37 SidebarContainer::~SidebarContainer() { | |
| 38 tab_strip_model_observer_.Remove(browser_->tab_strip_model()); | |
| 39 } | |
| 40 | |
| 41 void SidebarContainer::TabClosingAt(TabStripModel* tab_strip_model, | |
| 42 content::WebContents* contents, | |
| 43 int index) { | |
| 44 } | |
| 45 | |
| 46 void SidebarContainer::Observe(int type, | |
| 47 const content::NotificationSource& source, | |
| 48 const content::NotificationDetails& details) { | |
| 49 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE) | |
| 50 << "Received unexpected notification"; | |
| 51 } | |
| 52 | |
| 53 } // namespace extensions | |
| OLD | NEW |