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 "chrome/browser/ui/views/apps/chrome_native_app_window_views_win.h" | 5 #include "chrome/browser/ui/views/apps/chrome_native_app_window_views_win.h" |
6 | 6 |
7 #include "apps/app_window.h" | |
8 #include "apps/app_window_registry.h" | |
9 #include "apps/ui/views/app_window_frame_view.h" | 7 #include "apps/ui/views/app_window_frame_view.h" |
10 #include "ash/shell.h" | 8 #include "ash/shell.h" |
11 #include "base/command_line.h" | 9 #include "base/command_line.h" |
12 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
13 #include "base/path_service.h" | 11 #include "base/path_service.h" |
14 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
15 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
16 #include "chrome/browser/apps/per_app_settings_service.h" | 14 #include "chrome/browser/apps/per_app_settings_service.h" |
17 #include "chrome/browser/apps/per_app_settings_service_factory.h" | 15 #include "chrome/browser/apps/per_app_settings_service_factory.h" |
18 #include "chrome/browser/jumplist_updater_win.h" | 16 #include "chrome/browser/jumplist_updater_win.h" |
19 #include "chrome/browser/metro_utils/metro_chrome_win.h" | 17 #include "chrome/browser/metro_utils/metro_chrome_win.h" |
20 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/shell_integration.h" | 19 #include "chrome/browser/shell_integration.h" |
22 #include "chrome/browser/ui/views/apps/app_window_desktop_native_widget_aura_win
.h" | 20 #include "chrome/browser/ui/views/apps/app_window_desktop_native_widget_aura_win
.h" |
23 #include "chrome/browser/ui/views/apps/glass_app_window_frame_view_win.h" | 21 #include "chrome/browser/ui/views/apps/glass_app_window_frame_view_win.h" |
24 #include "chrome/browser/web_applications/web_app.h" | 22 #include "chrome/browser/web_applications/web_app.h" |
25 #include "chrome/browser/web_applications/web_app_win.h" | 23 #include "chrome/browser/web_applications/web_app_win.h" |
26 #include "chrome/common/chrome_icon_resources_win.h" | 24 #include "chrome/common/chrome_icon_resources_win.h" |
27 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
29 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 28 #include "extensions/browser/app_window/app_window.h" |
| 29 #include "extensions/browser/app_window/app_window_registry.h" |
30 #include "extensions/browser/extension_util.h" | 30 #include "extensions/browser/extension_util.h" |
31 #include "extensions/common/extension.h" | 31 #include "extensions/common/extension.h" |
32 #include "ui/aura/remote_window_tree_host_win.h" | 32 #include "ui/aura/remote_window_tree_host_win.h" |
33 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
34 #include "ui/base/win/shell.h" | 34 #include "ui/base/win/shell.h" |
35 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 35 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
36 #include "ui/views/win/hwnd_util.h" | 36 #include "ui/views/win/hwnd_util.h" |
37 | 37 |
38 ChromeNativeAppWindowViewsWin::ChromeNativeAppWindowViewsWin() | 38 ChromeNativeAppWindowViewsWin::ChromeNativeAppWindowViewsWin() |
39 : weak_ptr_factory_(this), glass_frame_view_(NULL) { | 39 : weak_ptr_factory_(this), glass_frame_view_(NULL) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 ::SetWindowLong(hwnd, GWL_STYLE, current_style | WS_CAPTION); | 73 ::SetWindowLong(hwnd, GWL_STYLE, current_style | WS_CAPTION); |
74 } | 74 } |
75 | 75 |
76 void ChromeNativeAppWindowViewsWin::OnBeforeWidgetInit( | 76 void ChromeNativeAppWindowViewsWin::OnBeforeWidgetInit( |
77 views::Widget::InitParams* init_params, | 77 views::Widget::InitParams* init_params, |
78 views::Widget* widget) { | 78 views::Widget* widget) { |
79 content::BrowserContext* browser_context = app_window()->browser_context(); | 79 content::BrowserContext* browser_context = app_window()->browser_context(); |
80 std::string extension_id = app_window()->extension_id(); | 80 std::string extension_id = app_window()->extension_id(); |
81 // If an app has any existing windows, ensure new ones are created on the | 81 // If an app has any existing windows, ensure new ones are created on the |
82 // same desktop. | 82 // same desktop. |
83 apps::AppWindow* any_existing_window = | 83 extensions::AppWindow* any_existing_window = |
84 apps::AppWindowRegistry::Get(browser_context) | 84 extensions::AppWindowRegistry::Get(browser_context) |
85 ->GetCurrentAppWindowForApp(extension_id); | 85 ->GetCurrentAppWindowForApp(extension_id); |
86 chrome::HostDesktopType desktop_type; | 86 chrome::HostDesktopType desktop_type; |
87 if (any_existing_window) { | 87 if (any_existing_window) { |
88 desktop_type = chrome::GetHostDesktopTypeForNativeWindow( | 88 desktop_type = chrome::GetHostDesktopTypeForNativeWindow( |
89 any_existing_window->GetNativeWindow()); | 89 any_existing_window->GetNativeWindow()); |
90 } else { | 90 } else { |
91 PerAppSettingsService* settings = | 91 PerAppSettingsService* settings = |
92 PerAppSettingsServiceFactory::GetForBrowserContext(browser_context); | 92 PerAppSettingsServiceFactory::GetForBrowserContext(browser_context); |
93 if (settings->HasDesktopLastLaunchedFrom(extension_id)) { | 93 if (settings->HasDesktopLastLaunchedFrom(extension_id)) { |
94 desktop_type = settings->GetDesktopLastLaunchedFrom(extension_id); | 94 desktop_type = settings->GetDesktopLastLaunchedFrom(extension_id); |
95 } else { | 95 } else { |
96 // We don't know what desktop this app was last launched from, so take our | 96 // We don't know what desktop this app was last launched from, so take our |
97 // best guess as to what desktop the user is on. | 97 // best guess as to what desktop the user is on. |
98 desktop_type = chrome::GetActiveDesktop(); | 98 desktop_type = chrome::GetActiveDesktop(); |
99 } | 99 } |
100 } | 100 } |
101 if (desktop_type == chrome::HOST_DESKTOP_TYPE_ASH) | 101 if (desktop_type == chrome::HOST_DESKTOP_TYPE_ASH) |
102 init_params->context = ash::Shell::GetPrimaryRootWindow(); | 102 init_params->context = ash::Shell::GetPrimaryRootWindow(); |
103 else | 103 else |
104 init_params->native_widget = new AppWindowDesktopNativeWidgetAuraWin(this); | 104 init_params->native_widget = new AppWindowDesktopNativeWidgetAuraWin(this); |
105 } | 105 } |
106 | 106 |
107 void ChromeNativeAppWindowViewsWin::InitializeDefaultWindow( | 107 void ChromeNativeAppWindowViewsWin::InitializeDefaultWindow( |
108 const apps::AppWindow::CreateParams& create_params) { | 108 const extensions::AppWindow::CreateParams& create_params) { |
109 ChromeNativeAppWindowViews::InitializeDefaultWindow(create_params); | 109 ChromeNativeAppWindowViews::InitializeDefaultWindow(create_params); |
110 | 110 |
111 const extensions::Extension* extension = app_window()->GetExtension(); | 111 const extensions::Extension* extension = app_window()->GetExtension(); |
112 if (!extension) | 112 if (!extension) |
113 return; | 113 return; |
114 | 114 |
115 std::string app_name = | 115 std::string app_name = |
116 web_app::GenerateApplicationNameFromExtensionId(extension->id()); | 116 web_app::GenerateApplicationNameFromExtensionId(extension->id()); |
117 base::string16 app_name_wide = base::UTF8ToWide(app_name); | 117 base::string16 app_name_wide = base::UTF8ToWide(app_name); |
118 HWND hwnd = GetNativeAppWindowHWND(); | 118 HWND hwnd = GetNativeAppWindowHWND(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 extension->id()); | 187 extension->id()); |
188 | 188 |
189 ShellLinkItemList items; | 189 ShellLinkItemList items; |
190 items.push_back(link); | 190 items.push_back(link); |
191 jumplist_updater.AddTasks(items); | 191 jumplist_updater.AddTasks(items); |
192 } | 192 } |
193 | 193 |
194 // Note that an empty jumplist must still be committed to clear all items. | 194 // Note that an empty jumplist must still be committed to clear all items. |
195 jumplist_updater.CommitUpdate(); | 195 jumplist_updater.CommitUpdate(); |
196 } | 196 } |
OLD | NEW |