Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Side by Side Diff: chrome/browser/extensions/sidebar_container.cc

Issue 1168383002: Implement sidebar support for extension action popups Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add sidebar handling logic and browser_tests Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
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 "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_view_host_factory.h"
12 #include "chrome/browser/extensions/sidebar_manager.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "components/app_modal/javascript_dialog_manager.h"
15 #include "content/public/browser/notification_details.h"
16 #include "content/public/browser/notification_source.h"
17 #include "content/public/browser/web_contents.h"
18 #include "extensions/common/extension.h"
19 #include "extensions/common/extension_resource.h"
20 #include "url/gurl.h"
21
22 namespace extensions {
23 SidebarContainer::SidebarContainer(Browser* browser,
24 content::WebContents* tab,
25 const GURL& url)
26 : host_(extensions::ExtensionViewHostFactory::CreateSidebarHost(url,
27 browser)),
28 tab_(tab) {
29 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
30 host_contents());
31
32 // Listen for the containing view calling window.close();
33 registrar_.Add(
34 this, extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
35 content::Source<content::BrowserContext>(host_->browser_context()));
36
37 host_->CreateRenderViewSoon();
38 host_contents()->SetInitialFocus();
39 }
40
41 SidebarContainer::~SidebarContainer() {
42 }
43
44 void SidebarContainer::Observe(int type,
45 const content::NotificationSource& source,
46 const content::NotificationDetails& details) {
47 if (type != extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE) {
48 NOTREACHED() << L"Received unexpected notification";
49 return;
50 }
51
52 // If we aren't the host of the popup, then disregard the notification.
53 if (content::Details<extensions::ExtensionHost>(host_.get()) == details)
54 extensions::SidebarManager::GetFromContext(host_->browser_context())
55 ->HideSidebar(tab_);
56 }
57
58 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698