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

Unified Diff: chrome/browser/extensions/extension_infobar_delegate.cc

Issue 923463003: [Extensions] Remove the Infobar API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_infobar_delegate.cc
diff --git a/chrome/browser/extensions/extension_infobar_delegate.cc b/chrome/browser/extensions/extension_infobar_delegate.cc
deleted file mode 100644
index 52050b6ca2e45e22fb80ce83ff65c693fef73d74..0000000000000000000000000000000000000000
--- a/chrome/browser/extensions/extension_infobar_delegate.cc
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/extensions/extension_infobar_delegate.h"
-
-#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/extensions/extension_view_host.h"
-#include "chrome/browser/extensions/extension_view_host_factory.h"
-#include "chrome/browser/infobars/infobar_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/infobar_container_delegate.h"
-#include "components/infobars/core/infobar.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_source.h"
-#include "extensions/browser/extension_registry.h"
-#include "extensions/common/extension.h"
-
-ExtensionInfoBarDelegate::~ExtensionInfoBarDelegate() {
-}
-
-// static
-void ExtensionInfoBarDelegate::Create(content::WebContents* web_contents,
- Browser* browser,
- const extensions::Extension* extension,
- const GURL& url,
- int height) {
- InfoBarService::FromWebContents(web_contents)->AddInfoBar(
- ExtensionInfoBarDelegate::CreateInfoBar(
- scoped_ptr<ExtensionInfoBarDelegate>(new ExtensionInfoBarDelegate(
- browser, extension, url, web_contents, height))));
-}
-
-ExtensionInfoBarDelegate::ExtensionInfoBarDelegate(
- Browser* browser,
- const extensions::Extension* extension,
- const GURL& url,
- content::WebContents* web_contents,
- int height)
- : infobars::InfoBarDelegate(),
-#if defined(TOOLKIT_VIEWS)
- browser_(browser),
-#endif
- extension_(extension),
- extension_registry_observer_(this),
- closing_(false) {
- extension_view_host_.reset(
- extensions::ExtensionViewHostFactory::CreateInfobarHost(url, browser));
- extension_view_host_->SetAssociatedWebContents(web_contents);
-
- extension_registry_observer_.Add(
- extensions::ExtensionRegistry::Get(browser->profile()));
- registrar_.Add(this,
- extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE,
- content::Source<Profile>(browser->profile()));
-
- height_ = std::max(0, height);
- height_ =
- std::min(2 * InfoBarContainerDelegate::kDefaultBarTargetHeight, height_);
- if (height_ == 0)
- height_ = InfoBarContainerDelegate::kDefaultBarTargetHeight;
-}
-
-content::WebContents* ExtensionInfoBarDelegate::GetWebContents() {
- return InfoBarService::WebContentsFromInfoBar(infobar());
-}
-
-// ExtensionInfoBarDelegate::CreateInfoBar() is implemented in platform-specific
-// files.
-
-bool ExtensionInfoBarDelegate::EqualsDelegate(
- infobars::InfoBarDelegate* delegate) const {
- ExtensionInfoBarDelegate* extension_delegate =
- delegate->AsExtensionInfoBarDelegate();
- // When an extension crashes, an InfoBar is shown (for the crashed extension).
- // That will result in a call to this function (to see if this InfoBarDelegate
- // is already showing the 'extension crashed InfoBar', which it never is), but
- // if it is our extension that crashes, the extension delegate is NULL so
- // we cannot check.
- if (!extension_delegate)
- return false;
-
- // Only allow one InfoBar at a time per extension.
- return extension_delegate->extension_view_host()->extension() ==
- extension_view_host_->extension();
-}
-
-void ExtensionInfoBarDelegate::InfoBarDismissed() {
- closing_ = true;
-}
-
-infobars::InfoBarDelegate::Type ExtensionInfoBarDelegate::GetInfoBarType()
- const {
- return PAGE_ACTION_TYPE;
-}
-
-ExtensionInfoBarDelegate*
- ExtensionInfoBarDelegate::AsExtensionInfoBarDelegate() {
- return this;
-}
-
-void ExtensionInfoBarDelegate::OnExtensionUnloaded(
- content::BrowserContext* browser_context,
- const extensions::Extension* extension,
- extensions::UnloadedExtensionInfo::Reason reason) {
- if (extension_ == extension)
- infobar()->RemoveSelf();
-}
-
-void ExtensionInfoBarDelegate::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE);
- if (extension_view_host_.get() ==
- content::Details<extensions::ExtensionHost>(details).ptr())
- infobar()->RemoveSelf();
-}
« no previous file with comments | « chrome/browser/extensions/extension_infobar_delegate.h ('k') | chrome/browser/extensions/extension_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698