OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "athena/extensions/athena_native_app_window_views.h" | 5 #include "athena/extensions/athena_native_app_window_views.h" |
6 | 6 |
7 namespace athena { | 7 namespace athena { |
8 | 8 |
9 views::WebView* AthenaNativeAppWindowViews::GetWebView() { | 9 views::WebView* AthenaNativeAppWindowViews::GetWebView() { |
10 return web_view(); | 10 return web_view(); |
11 } | 11 } |
12 | 12 |
13 // Specialized initialization of the AppWindowViews specific to Athena. Starts | |
14 // the window maximized by default unless the create_params specifies a | |
15 // maximum size, in which case the window will be centered. | |
16 void AthenaNativeAppWindowViews::InitializeWindow( | |
oshima
2014/10/22 20:03:21
I think we need to handle this in different way. L
| |
17 extensions::AppWindow* app_window, | |
18 const extensions::AppWindow::CreateParams& create_params) { | |
19 | |
20 views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); | |
21 | |
22 // Use passed 'create_params' to initialize 'init_params' | |
23 init_params.delegate = this; | |
24 init_params.remove_standard_frame = IsFrameless(); | |
25 init_params.use_system_default_icon = true; | |
26 init_params.keep_on_top = create_params.always_on_top; | |
27 | |
28 init_params.visible_on_all_workspaces = create_params | |
29 .visible_on_all_workspaces; | |
30 if (create_params.alpha_enabled) | |
31 init_params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | |
32 | |
33 // Only maximize the window if the content doesn't specify a maximum size, | |
34 // otherwise center the window in the screen with the given bounds. | |
35 bool need_to_center = false; | |
36 if (create_params.content_spec.maximum_size.IsEmpty()) { | |
37 init_params.show_state = ui::SHOW_STATE_MAXIMIZED; | |
38 } else { | |
39 init_params.show_state = create_params.state; | |
40 init_params.bounds = create_params.content_spec.bounds; | |
41 need_to_center = true; | |
42 } | |
43 | |
44 // Initialize and create the widget | |
45 views::Widget* widget = this->widget(); | |
46 widget->Init(init_params); | |
47 | |
48 // The following should be inside views::Widget::Init(), I think! | |
49 if (need_to_center) { | |
50 widget->CenterWindow( | |
51 create_params.GetInitialWindowBounds(gfx::Insets()).size()); | |
52 } | |
53 } | |
54 | |
13 } // namespace athena | 55 } // namespace athena |
OLD | NEW |