OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/views/extensions/native_app_window_views.h" | 5 #include "chrome/browser/ui/views/extensions/native_app_window_views.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
12 #include "chrome/browser/extensions/extension_host.h" | 12 #include "chrome/browser/extensions/extension_host.h" |
13 #include "chrome/browser/favicon/favicon_tab_helper.h" | 13 #include "chrome/browser/favicon/favicon_tab_helper.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" | 15 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views .h" |
16 #include "chrome/browser/ui/views/extensions/shell_window_frame_view.h" | 16 #include "chrome/browser/ui/views/extensions/shell_window_frame_view.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
21 #include "content/public/browser/render_widget_host_view.h" | 21 #include "content/public/browser/render_widget_host_view.h" |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 #include "content/public/browser/web_contents_view.h" | 23 #include "content/public/browser/web_contents_view.h" |
24 #include "extensions/common/draggable_region.h" | 24 #include "extensions/common/draggable_region.h" |
25 #include "ui/gfx/screen.h" | |
25 #include "ui/views/controls/webview/webview.h" | 26 #include "ui/views/controls/webview/webview.h" |
26 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
27 #include "ui/views/window/non_client_view.h" | 28 #include "ui/views/window/non_client_view.h" |
28 | 29 |
29 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
30 #include "base/strings/utf_string_conversions.h" | 31 #include "base/strings/utf_string_conversions.h" |
31 #include "chrome/browser/ui/web_applications/web_app_ui.h" | 32 #include "chrome/browser/ui/web_applications/web_app_ui.h" |
32 #include "chrome/browser/web_applications/web_app.h" | 33 #include "chrome/browser/web_applications/web_app.h" |
33 #include "ui/base/win/shell.h" | 34 #include "ui/base/win/shell.h" |
34 #include "ui/views/win/hwnd_util.h" | 35 #include "ui/views/win/hwnd_util.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 if (position_specified && !window_bounds.IsEmpty()) | 167 if (position_specified && !window_bounds.IsEmpty()) |
167 init_params.bounds = window_bounds; | 168 init_params.bounds = window_bounds; |
168 window_->Init(init_params); | 169 window_->Init(init_params); |
169 | 170 |
170 gfx::Rect adjusted_bounds = window_bounds; | 171 gfx::Rect adjusted_bounds = window_bounds; |
171 adjusted_bounds.Inset(-GetFrameInsets()); | 172 adjusted_bounds.Inset(-GetFrameInsets()); |
172 // Center window if no position was specified. | 173 // Center window if no position was specified. |
173 if (!position_specified) | 174 if (!position_specified) |
174 window_->CenterWindow(adjusted_bounds.size()); | 175 window_->CenterWindow(adjusted_bounds.size()); |
175 else if (!adjusted_bounds.IsEmpty() && adjusted_bounds != window_bounds) | 176 else if (!adjusted_bounds.IsEmpty() && adjusted_bounds != window_bounds) |
176 window_->SetBounds(adjusted_bounds); | 177 window_->SetBounds(adjusted_bounds); |
oshima
2013/06/20 19:46:32
The reason why it's currently broken on chromeos i
zhchbin
2013/06/21 06:36:31
My patch didn't change these lines. I think the ri
oshima
2013/06/21 16:13:30
Sorry I lied. I mixed up with something else, so p
| |
177 | 178 |
178 // Register accelarators supported by app windows. | 179 // Register accelarators supported by app windows. |
179 // TODO(jeremya/stevenjb): should these be registered for panels too? | 180 // TODO(jeremya/stevenjb): should these be registered for panels too? |
180 views::FocusManager* focus_manager = GetFocusManager(); | 181 views::FocusManager* focus_manager = GetFocusManager(); |
181 const std::map<ui::Accelerator, int>& accelerator_table = | 182 const std::map<ui::Accelerator, int>& accelerator_table = |
182 GetAcceleratorTable(); | 183 GetAcceleratorTable(); |
183 for (std::map<ui::Accelerator, int>::const_iterator iter = | 184 for (std::map<ui::Accelerator, int>::const_iterator iter = |
184 accelerator_table.begin(); | 185 accelerator_table.begin(); |
185 iter != accelerator_table.end(); ++iter) { | 186 iter != accelerator_table.end(); ++iter) { |
186 focus_manager->RegisterAccelerator( | 187 focus_manager->RegisterAccelerator( |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 // the specified amount of space to fit the window controls in, and return a | 400 // the specified amount of space to fit the window controls in, and return a |
400 // number larger than the real frame insets. Most window controls are smaller | 401 // number larger than the real frame insets. Most window controls are smaller |
401 // than 1000x1000px, so this should be big enough. | 402 // than 1000x1000px, so this should be big enough. |
402 gfx::Rect client_bounds = gfx::Rect(1000, 1000); | 403 gfx::Rect client_bounds = gfx::Rect(1000, 1000); |
403 gfx::Rect window_bounds = | 404 gfx::Rect window_bounds = |
404 window_->non_client_view()->GetWindowBoundsForClientBounds( | 405 window_->non_client_view()->GetWindowBoundsForClientBounds( |
405 client_bounds); | 406 client_bounds); |
406 return window_bounds.InsetsFrom(client_bounds); | 407 return window_bounds.InsetsFrom(client_bounds); |
407 } | 408 } |
408 | 409 |
410 gfx::Rect NativeAppWindowViews::GetScreenBounds() const { | |
411 return gfx::Screen::GetScreenFor(window_->GetNativeView())-> | |
412 GetDisplayMatching(GetBounds()).work_area(); | |
413 } | |
414 | |
409 gfx::NativeView NativeAppWindowViews::GetHostView() const { | 415 gfx::NativeView NativeAppWindowViews::GetHostView() const { |
410 return window_->GetNativeView(); | 416 return window_->GetNativeView(); |
411 } | 417 } |
412 | 418 |
413 gfx::Point NativeAppWindowViews::GetDialogPosition(const gfx::Size& size) { | 419 gfx::Point NativeAppWindowViews::GetDialogPosition(const gfx::Size& size) { |
414 gfx::Size shell_window_size = window_->GetWindowBoundsInScreen().size(); | 420 gfx::Size shell_window_size = window_->GetWindowBoundsInScreen().size(); |
415 return gfx::Point(shell_window_size.width() / 2 - size.width() / 2, | 421 return gfx::Point(shell_window_size.width() / 2 - size.width() / 2, |
416 shell_window_size.height() / 2 - size.height() / 2); | 422 shell_window_size.height() / 2 - size.height() / 2); |
417 } | 423 } |
418 | 424 |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
745 } | 751 } |
746 | 752 |
747 //------------------------------------------------------------------------------ | 753 //------------------------------------------------------------------------------ |
748 // NativeAppWindow::Create | 754 // NativeAppWindow::Create |
749 | 755 |
750 // static | 756 // static |
751 NativeAppWindow* NativeAppWindow::Create( | 757 NativeAppWindow* NativeAppWindow::Create( |
752 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { | 758 ShellWindow* shell_window, const ShellWindow::CreateParams& params) { |
753 return new NativeAppWindowViews(shell_window, params); | 759 return new NativeAppWindowViews(shell_window, params); |
754 } | 760 } |
OLD | NEW |