summaryrefslogtreecommitdiffstats
path: root/athena/main
diff options
context:
space:
mode:
authoroshima <oshima@chromium.org>2014-09-09 23:30:42 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-10 06:34:47 +0000
commit480242d63b091995b58c1e21940249d91af9544f (patch)
treed3d998db3ca8526aa1c4b1e7c162b729bf0243a6 /athena/main
parente17158e079e4e51686d001ac288d9066c1ae310a (diff)
downloadchromium_src-480242d63b091995b58c1e21940249d91af9544f.zip
chromium_src-480242d63b091995b58c1e21940249d91af9544f.tar.gz
chromium_src-480242d63b091995b58c1e21940249d91af9544f.tar.bz2
Supprot V2 app: step1
* Add AthenaAppDelegate * Add factory functions to create various dialogs * Add terminating callback to AthenaEnv BUG=411415 TEST=AthenaEnvTest.TerminatingCallback TBR=sky@chromium.org, jochen@chromium.org, reed@chromium.org Review URL: https://codereview.chromium.org/544953003 Cr-Commit-Position: refs/heads/master@{#294123}
Diffstat (limited to 'athena/main')
-rw-r--r--athena/main/DEPS5
-rw-r--r--athena/main/athena_frame_view.cc92
-rw-r--r--athena/main/athena_frame_view.h56
-rw-r--r--athena/main/athena_launcher.cc19
-rw-r--r--athena/main/athena_main.cc1
-rw-r--r--athena/main/athena_main.gyp4
-rw-r--r--athena/main/athena_views_delegate.cc23
-rw-r--r--athena/main/athena_views_delegate.h29
8 files changed, 210 insertions, 19 deletions
diff --git a/athena/main/DEPS b/athena/main/DEPS
index 4316d72..da4ff5d 100644
--- a/athena/main/DEPS
+++ b/athena/main/DEPS
@@ -44,9 +44,12 @@ specific_include_rules = {
],
# TODO(oshima): Remove this.
"placeholder\.*": [
- "+third_party/skia",
+ "+third_party/skia/include",
"+ui/gfx",
"+ui/views",
],
+ "athena_frame_view\.*": [
+ "+third_party/skia/include",
+ ],
}
diff --git a/athena/main/athena_frame_view.cc b/athena/main/athena_frame_view.cc
new file mode 100644
index 0000000..5422a0c
--- /dev/null
+++ b/athena/main/athena_frame_view.cc
@@ -0,0 +1,92 @@
+// 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/main/athena_frame_view.h"
+
+#include "base/strings/utf_string_conversions.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/base/hit_test.h"
+#include "ui/views/background.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/view.h"
+#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_delegate.h"
+#include "ui/views/window/client_view.h"
+
+namespace athena {
+namespace {
+
+// The height of the top border necessary to display the title without the icon.
+const int kDefaultTitleHeight = 13;
+
+// The default background color for athena's frame. This is placeholder.
+const SkColor kDefaultTitleBackground = 0xFFcccccc;
+
+} // namespace
+
+// static
+const char AthenaFrameView::kViewClassName[] = "AthenaFrameView";
+
+AthenaFrameView::AthenaFrameView(views::Widget* frame) : frame_(frame) {
+ set_background(
+ views::Background::CreateSolidBackground(kDefaultTitleBackground));
+ UpdateWindowTitle();
+}
+
+AthenaFrameView::~AthenaFrameView() {
+}
+
+gfx::Rect AthenaFrameView::GetBoundsForClientView() const {
+ gfx::Rect client_bounds = bounds();
+ client_bounds.Inset(NonClientBorderInsets());
+ return client_bounds;
+}
+
+gfx::Rect AthenaFrameView::GetWindowBoundsForClientBounds(
+ const gfx::Rect& client_bounds) const {
+ gfx::Rect window_bounds = client_bounds;
+ window_bounds.Inset(-NonClientBorderInsets());
+ return window_bounds;
+}
+
+int AthenaFrameView::NonClientHitTest(const gfx::Point& point) {
+ if (!bounds().Contains(point))
+ return HTNOWHERE;
+ int client_hit_test = frame_->client_view()->NonClientHitTest(point);
+ if (client_hit_test != HTNOWHERE)
+ return client_hit_test;
+ int window_hit_test =
+ GetHTComponentForFrame(point, 0, NonClientBorderThickness(), 0, 0, false);
+ return (window_hit_test == HTNOWHERE) ? HTCAPTION : client_hit_test;
+}
+
+gfx::Size AthenaFrameView::GetPreferredSize() const {
+ gfx::Size pref = frame_->client_view()->GetPreferredSize();
+ gfx::Rect bounds(0, 0, pref.width(), pref.height());
+ return frame_->non_client_view()
+ ->GetWindowBoundsForClientBounds(bounds)
+ .size();
+}
+
+const char* AthenaFrameView::GetClassName() const {
+ return kViewClassName;
+}
+
+gfx::Insets AthenaFrameView::NonClientBorderInsets() const {
+ int border_thickness = NonClientBorderThickness();
+ return gfx::Insets(NonClientTopBorderHeight(),
+ border_thickness,
+ border_thickness,
+ border_thickness);
+}
+
+int AthenaFrameView::NonClientBorderThickness() const {
+ return 0;
+}
+
+int AthenaFrameView::NonClientTopBorderHeight() const {
+ return kDefaultTitleHeight;
+}
+
+} // namespace athena
diff --git a/athena/main/athena_frame_view.h b/athena/main/athena_frame_view.h
new file mode 100644
index 0000000..3037ea9
--- /dev/null
+++ b/athena/main/athena_frame_view.h
@@ -0,0 +1,56 @@
+// 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.
+
+#ifndef ATHENA_COMMON_ATHENA_FRAME_VIEW_H_
+#define ATHENA_COMMON_ATHENA_FRAME_VIEW_H_
+
+#include "ui/views/window/non_client_view.h"
+
+namespace views {
+class Widget;
+}
+
+namespace athena {
+
+// A NonClientFrameView used for non activity window.
+// TODO(oshima): Move this to athena/util and share the code.
+class AthenaFrameView : public views::NonClientFrameView {
+ public:
+ // The frame class name.
+ static const char kViewClassName[];
+
+ explicit AthenaFrameView(views::Widget* frame);
+ virtual ~AthenaFrameView();
+
+ // views::NonClientFrameView overrides:
+ virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
+ virtual gfx::Rect GetWindowBoundsForClientBounds(
+ const gfx::Rect& client_bounds) const OVERRIDE;
+ virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
+ virtual void GetWindowMask(const gfx::Size& size,
+ gfx::Path* window_mask) OVERRIDE {}
+ virtual void ResetWindowControls() OVERRIDE {}
+ virtual void UpdateWindowIcon() OVERRIDE {}
+ virtual void UpdateWindowTitle() OVERRIDE {}
+
+ // views::View overrides:
+ virtual gfx::Size GetPreferredSize() const OVERRIDE;
+ virtual const char* GetClassName() const OVERRIDE;
+ virtual void Layout() OVERRIDE {}
+
+ private:
+ gfx::Insets NonClientBorderInsets() const;
+
+ virtual int NonClientTopBorderHeight() const;
+ virtual int NonClientBorderThickness() const;
+
+ // Not owned.
+ views::Widget* frame_;
+
+ DISALLOW_COPY_AND_ASSIGN(AthenaFrameView);
+};
+
+} // namespace athena
+
+#endif // ATHENA_COMMON_ATHENA_FRAME_VIEW_H_
diff --git a/athena/main/athena_launcher.cc b/athena/main/athena_launcher.cc
index 304b0f7..c94d671 100644
--- a/athena/main/athena_launcher.cc
+++ b/athena/main/athena_launcher.cc
@@ -13,12 +13,12 @@
#include "athena/extensions/public/extensions_delegate.h"
#include "athena/home/public/home_card.h"
#include "athena/input/public/input_manager.h"
+#include "athena/main/athena_views_delegate.h"
#include "athena/main/placeholder.h"
#include "athena/main/placeholder.h"
#include "athena/main/url_search_provider.h"
#include "athena/resource_manager/public/resource_manager.h"
#include "athena/screen/public/screen_manager.h"
-#include "athena/screen/public/screen_manager.h"
#include "athena/system/public/system_ui.h"
#include "athena/virtual_keyboard/public/virtual_keyboard_manager.h"
#include "athena/wm/public/window_manager.h"
@@ -30,7 +30,6 @@
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_controller_observer.h"
#include "ui/native_theme/native_theme_switches.h"
-#include "ui/views/views_delegate.h"
#include "ui/wm/core/visibility_controller.h"
#if defined(USE_X11)
@@ -78,22 +77,6 @@ class VirtualKeyboardObserver : public keyboard::KeyboardControllerObserver {
DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardObserver);
};
-class AthenaViewsDelegate : public views::ViewsDelegate {
- public:
- AthenaViewsDelegate() {}
- virtual ~AthenaViewsDelegate() {}
-
- private:
- // views::ViewsDelegate:
- virtual void OnBeforeWidgetInit(
- views::Widget::InitParams* params,
- views::internal::NativeWidgetDelegate* delegate) OVERRIDE {
- params->context = athena::ScreenManager::Get()->GetContext();
- }
-
- DISALLOW_COPY_AND_ASSIGN(AthenaViewsDelegate);
-};
-
void StartAthenaEnv(scoped_refptr<base::TaskRunner> file_runner) {
athena::AthenaEnv::Create();
diff --git a/athena/main/athena_main.cc b/athena/main/athena_main.cc
index 7507ff5..beb1932 100644
--- a/athena/main/athena_main.cc
+++ b/athena/main/athena_main.cc
@@ -105,6 +105,7 @@ class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
}
virtual void Shutdown() OVERRIDE {
+ athena::AthenaEnv::Get()->OnTerminating();
athena::ShutdownAthena();
}
diff --git a/athena/main/athena_main.gyp b/athena/main/athena_main.gyp
index 7c61c43..9dd5afe 100644
--- a/athena/main/athena_main.gyp
+++ b/athena/main/athena_main.gyp
@@ -36,9 +36,13 @@
'sources': [
'athena_content_client.cc',
'athena_content_client.h',
+ 'athena_frame_view.cc',
+ 'athena_frame_view.h',
'athena_launcher.cc',
'athena_renderer_pdf_helper.cc',
'athena_renderer_pdf_helper.h',
+ 'athena_views_delegate.cc',
+ 'athena_views_delegate.h',
'placeholder.cc',
'placeholder.h',
'public/athena_launcher.h',
diff --git a/athena/main/athena_views_delegate.cc b/athena/main/athena_views_delegate.cc
new file mode 100644
index 0000000..3f30cda
--- /dev/null
+++ b/athena/main/athena_views_delegate.cc
@@ -0,0 +1,23 @@
+// 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/main/athena_views_delegate.h"
+
+#include "athena/main/athena_frame_view.h"
+#include "athena/screen/public/screen_manager.h"
+
+namespace athena {
+
+void AthenaViewsDelegate::OnBeforeWidgetInit(
+ views::Widget::InitParams* params,
+ views::internal::NativeWidgetDelegate* delegate) {
+ params->context = athena::ScreenManager::Get()->GetContext();
+}
+
+views::NonClientFrameView* AthenaViewsDelegate::CreateDefaultNonClientFrameView(
+ views::Widget* widget) {
+ return new AthenaFrameView(widget);
+}
+
+} // namespace athena
diff --git a/athena/main/athena_views_delegate.h b/athena/main/athena_views_delegate.h
new file mode 100644
index 0000000..b5d8586
--- /dev/null
+++ b/athena/main/athena_views_delegate.h
@@ -0,0 +1,29 @@
+// 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.
+#ifndef ATHENA_MAIN_ATHENA_VIEWS_DELEGATE_H_
+#define ATHENA_MAIN_ATHENA_VIEWS_DELEGATE_H_
+
+#include "ui/views/views_delegate.h"
+
+namespace athena {
+
+class AthenaViewsDelegate : public views::ViewsDelegate {
+ public:
+ AthenaViewsDelegate() {}
+ virtual ~AthenaViewsDelegate() {}
+
+ private:
+ // views::ViewsDelegate:
+ virtual void OnBeforeWidgetInit(
+ views::Widget::InitParams* params,
+ views::internal::NativeWidgetDelegate* delegate) OVERRIDE;
+ virtual views::NonClientFrameView* CreateDefaultNonClientFrameView(
+ views::Widget* widget) OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(AthenaViewsDelegate);
+};
+
+} // namespace athena
+
+#endif // ATHENA_MAIN_ATHENA_VIEWS_DELEGATE_H_