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

Side by Side Diff: chrome/browser/ui/views/apps/native_app_window_views_win.cc

Issue 171003004: Extract Chrome-specific code from NativeAppWindowViews (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (split_native_app_window) Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/native_app_window_views_win.h" 5 #include "chrome/browser/ui/views/apps/native_app_window_views_win.h"
6 6
7 #include "apps/app_window.h" 7 #include "apps/app_window.h"
8 #include "apps/app_window_registry.h" 8 #include "apps/app_window_registry.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 base::Bind(&CreateIconAndSetRelaunchDetails, 104 base::Bind(&CreateIconAndSetRelaunchDetails,
105 web_app_path, icon_file, shortcut_info, hwnd)); 105 web_app_path, icon_file, shortcut_info, hwnd));
106 } 106 }
107 107
108 HWND NativeAppWindowViewsWin::GetNativeAppWindowHWND() const { 108 HWND NativeAppWindowViewsWin::GetNativeAppWindowHWND() const {
109 return views::HWNDForWidget(window()->GetTopLevelWidget()); 109 return views::HWNDForWidget(window()->GetTopLevelWidget());
110 } 110 }
111 111
112 void NativeAppWindowViewsWin::OnBeforeWidgetInit( 112 void NativeAppWindowViewsWin::OnBeforeWidgetInit(
113 views::Widget::InitParams* init_params, views::Widget* widget) { 113 views::Widget::InitParams* init_params, views::Widget* widget) {
114 content::BrowserContext* browser_context = app_window()->browser_context();
115 const extensions::Extension* extension = app_window()->extension();
114 // If an app has any existing windows, ensure new ones are created on the 116 // If an app has any existing windows, ensure new ones are created on the
115 // same desktop. 117 // same desktop.
116 apps::AppWindow* any_existing_window = 118 apps::AppWindow* any_existing_window =
117 apps::AppWindowRegistry::Get(browser_context()) 119 apps::AppWindowRegistry::Get(browser_context)
118 ->GetCurrentAppWindowForApp(extension()->id()); 120 ->GetCurrentAppWindowForApp(extension->id());
119 chrome::HostDesktopType desktop_type; 121 chrome::HostDesktopType desktop_type;
120 if (any_existing_window) { 122 if (any_existing_window) {
121 desktop_type = chrome::GetHostDesktopTypeForNativeWindow( 123 desktop_type = chrome::GetHostDesktopTypeForNativeWindow(
122 any_existing_window->GetNativeWindow()); 124 any_existing_window->GetNativeWindow());
123 } else { 125 } else {
124 PerAppSettingsService* settings = 126 PerAppSettingsService* settings =
125 PerAppSettingsServiceFactory::GetForBrowserContext(browser_context()); 127 PerAppSettingsServiceFactory::GetForBrowserContext(browser_context);
126 if (settings->HasDesktopLastLaunchedFrom(extension()->id())) { 128 if (settings->HasDesktopLastLaunchedFrom(extension->id())) {
127 desktop_type = settings->GetDesktopLastLaunchedFrom(extension()->id()); 129 desktop_type = settings->GetDesktopLastLaunchedFrom(extension->id());
128 } else { 130 } else {
129 // We don't know what desktop this app was last launched from, so take our 131 // We don't know what desktop this app was last launched from, so take our
130 // best guess as to what desktop the user is on. 132 // best guess as to what desktop the user is on.
131 desktop_type = chrome::GetActiveDesktop(); 133 desktop_type = chrome::GetActiveDesktop();
132 } 134 }
133 } 135 }
134 if (desktop_type == chrome::HOST_DESKTOP_TYPE_ASH) 136 if (desktop_type == chrome::HOST_DESKTOP_TYPE_ASH)
135 init_params->context = ash::Shell::GetPrimaryRootWindow(); 137 init_params->context = ash::Shell::GetPrimaryRootWindow();
136 else 138 else
137 init_params->native_widget = new views::DesktopNativeWidgetAura(widget); 139 init_params->native_widget = new views::DesktopNativeWidgetAura(widget);
138 } 140 }
139 141
140 void NativeAppWindowViewsWin::InitializeDefaultWindow( 142 void NativeAppWindowViewsWin::InitializeDefaultWindow(
141 const apps::AppWindow::CreateParams& create_params) { 143 const apps::AppWindow::CreateParams& create_params) {
142 NativeAppWindowViews::InitializeDefaultWindow(create_params); 144 NativeAppWindowViews::InitializeDefaultWindow(create_params);
143 145
146 const extensions::Extension* extension = app_window()->extension();
144 std::string app_name = 147 std::string app_name =
145 web_app::GenerateApplicationNameFromExtensionId(extension()->id()); 148 web_app::GenerateApplicationNameFromExtensionId(extension->id());
146 base::string16 app_name_wide = base::UTF8ToWide(app_name); 149 base::string16 app_name_wide = base::UTF8ToWide(app_name);
147 HWND hwnd = GetNativeAppWindowHWND(); 150 HWND hwnd = GetNativeAppWindowHWND();
151 Profile* profile =
152 Profile::FromBrowserContext(app_window()->browser_context());
148 ui::win::SetAppIdForWindow( 153 ui::win::SetAppIdForWindow(
149 ShellIntegration::GetAppModelIdForProfile( 154 ShellIntegration::GetAppModelIdForProfile(
150 app_name_wide, 155 app_name_wide,
151 Profile::FromBrowserContext(browser_context())->GetPath()), 156 profile->GetPath()),
152 hwnd); 157 hwnd);
153 158
154 web_app::UpdateShortcutInfoAndIconForApp( 159 web_app::UpdateShortcutInfoAndIconForApp(
155 *extension(), 160 *extension,
156 Profile::FromBrowserContext(browser_context()), 161 profile,
157 base::Bind(&NativeAppWindowViewsWin::OnShortcutInfoLoaded, 162 base::Bind(&NativeAppWindowViewsWin::OnShortcutInfoLoaded,
158 weak_ptr_factory_.GetWeakPtr())); 163 weak_ptr_factory_.GetWeakPtr()));
159 } 164 }
160 165
161 void NativeAppWindowViewsWin::Show() { 166 void NativeAppWindowViewsWin::Show() {
162 ActivateParentDesktopIfNecessary(); 167 ActivateParentDesktopIfNecessary();
163 NativeAppWindowViews::Show(); 168 NativeAppWindowViews::Show();
164 } 169 }
165 170
166 void NativeAppWindowViewsWin::Activate() { 171 void NativeAppWindowViewsWin::Activate() {
167 ActivateParentDesktopIfNecessary(); 172 ActivateParentDesktopIfNecessary();
168 NativeAppWindowViews::Activate(); 173 NativeAppWindowViews::Activate();
169 } 174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698