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

Unified Diff: athena/extensions/athena_constrained_window_views_client.cc

Issue 863033002: Delete athena/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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: athena/extensions/athena_constrained_window_views_client.cc
diff --git a/athena/extensions/athena_constrained_window_views_client.cc b/athena/extensions/athena_constrained_window_views_client.cc
deleted file mode 100644
index 7a89d53857da9c8313dfcb3bef975f87df9ee477..0000000000000000000000000000000000000000
--- a/athena/extensions/athena_constrained_window_views_client.cc
+++ /dev/null
@@ -1,144 +0,0 @@
-// Copyright 2014 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 "athena/extensions/athena_constrained_window_views_client.h"
-
-#include "athena/activity/public/activity.h"
-#include "athena/activity/public/activity_manager.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/observer_list.h"
-#include "components/constrained_window/constrained_window_views.h"
-#include "components/constrained_window/constrained_window_views_client.h"
-#include "components/web_modal/web_contents_modal_dialog_host.h"
-#include "extensions/browser/guest_view/guest_view_base.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_observer.h"
-#include "ui/aura/window_property.h"
-
-DECLARE_WINDOW_PROPERTY_TYPE(web_modal::ModalDialogHost*);
-
-namespace athena {
-namespace {
-
-// Provides the host environment for web modal dialogs. See
-// web_modal::WebContentsModalDialogHost, and ModalDialogHost for more
-// details.
-class ModalDialogHostImpl : public web_modal::WebContentsModalDialogHost,
- public aura::WindowObserver {
- public:
- // Returns a modal dialog host for |window|. If it doesn't exist it creates
- // one and stores it as owned property.
- static ModalDialogHost* Get(aura::Window* window);
-
- private:
- explicit ModalDialogHostImpl(aura::Window* host_window)
- : host_window_(host_window) {
- host_window_->AddObserver(this);
- }
- ~ModalDialogHostImpl() override {}
-
- // web_modal::ModalDialogHost:
- gfx::NativeView GetHostView() const override {
- return host_window_;
- }
- gfx::Point GetDialogPosition(const gfx::Size& size) override {
- gfx::Rect host_bounds = host_window_->GetBoundsInScreen();
- host_bounds.ClampToCenteredSize(size);
- return host_bounds.origin();
- }
- void AddObserver(web_modal::ModalDialogHostObserver* observer) override {
- observer_list_.AddObserver(observer);
- }
- void RemoveObserver(web_modal::ModalDialogHostObserver* observer) override {
- observer_list_.RemoveObserver(observer);
- }
-
- // web_modal::WebContensModalDialogHost:
- gfx::Size GetMaximumDialogSize() override {
- return host_window_->bounds().size();
- }
-
- // aura::WindowObserver:
- void OnWindowDestroying(aura::Window* window) override {
- if (window != host_window_)
- return;
- host_window_->RemoveObserver(this);
- FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver,
- observer_list_,
- OnHostDestroying());
- }
- void OnWindowBoundsChanged(aura::Window* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) override {
- if (window != host_window_)
- return;
- FOR_EACH_OBSERVER(web_modal::ModalDialogHostObserver,
- observer_list_,
- OnPositionRequiresUpdate());
- }
-
- aura::Window* host_window_;
- ObserverList<web_modal::ModalDialogHostObserver> observer_list_;
-
- DISALLOW_COPY_AND_ASSIGN(ModalDialogHostImpl);
-};
-
-// A window property key to store the modal dialog host for
-// dialogs created with the window as its parent.
-DEFINE_OWNED_WINDOW_PROPERTY_KEY(web_modal::ModalDialogHost,
- kModalDialogHostKey,
- nullptr);
-
-// static
-web_modal::ModalDialogHost* ModalDialogHostImpl::Get(
- aura::Window* window) {
- web_modal::ModalDialogHost* host = window->GetProperty(kModalDialogHostKey);
- if (!host) {
- host = new ModalDialogHostImpl(window);
- window->SetProperty(kModalDialogHostKey, host);
- }
- return host;
-}
-
-class AthenaConstrainedWindowViewsClient
- : public constrained_window::ConstrainedWindowViewsClient {
- public:
- AthenaConstrainedWindowViewsClient() {}
- ~AthenaConstrainedWindowViewsClient() override {}
-
- private:
- // ConstrainedWindowViewsClient:
- content::WebContents* GetEmbedderWebContents(
- content::WebContents* initiator_web_contents) override {
- extensions::GuestViewBase* guest_view =
- extensions::GuestViewBase::FromWebContents(initiator_web_contents);
- return guest_view && guest_view->embedder_web_contents() ?
- guest_view->embedder_web_contents() : initiator_web_contents;
- }
- web_modal::ModalDialogHost* GetModalDialogHost(
- gfx::NativeWindow parent) override {
- Activity* activity = ActivityManager::Get()->GetActivityForWindow(parent);
- if (activity)
- return ModalDialogHostImpl::Get(parent);
- return nullptr;
- }
- gfx::NativeView GetDialogHostView(gfx::NativeWindow parent) override {
- return parent;
- }
-
- DISALLOW_COPY_AND_ASSIGN(AthenaConstrainedWindowViewsClient);
-};
-
-} // namespace
-
-void InstallConstrainedWindowViewsClient() {
- constrained_window::SetConstrainedWindowViewsClient(
- make_scoped_ptr(new AthenaConstrainedWindowViewsClient));
-}
-
-void UninstallConstrainedWindowViewsClient() {
- constrained_window::SetConstrainedWindowViewsClient(nullptr);
-}
-
-} // namespace athena

Powered by Google App Engine
This is Rietveld 408576698