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

Side by Side Diff: extensions/browser/api/app_window/app_window_api.cc

Issue 583583008: Rename AppsClient -> AppWindowClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
OLDNEW
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 "extensions/browser/api/app_window/app_window_api.h" 5 #include "extensions/browser/api/app_window/app_window_api.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "content/public/browser/notification_registrar.h" 12 #include "content/public/browser/notification_registrar.h"
13 #include "content/public/browser/notification_types.h" 13 #include "content/public/browser/notification_types.h"
14 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
15 #include "content/public/browser/render_view_host.h" 15 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/common/url_constants.h" 17 #include "content/public/common/url_constants.h"
18 #include "extensions/browser/app_window/app_window.h" 18 #include "extensions/browser/app_window/app_window.h"
19 #include "extensions/browser/app_window/app_window_client.h"
19 #include "extensions/browser/app_window/app_window_contents.h" 20 #include "extensions/browser/app_window/app_window_contents.h"
20 #include "extensions/browser/app_window/app_window_registry.h" 21 #include "extensions/browser/app_window/app_window_registry.h"
21 #include "extensions/browser/app_window/apps_client.h"
22 #include "extensions/browser/app_window/native_app_window.h" 22 #include "extensions/browser/app_window/native_app_window.h"
23 #include "extensions/browser/extensions_browser_client.h" 23 #include "extensions/browser/extensions_browser_client.h"
24 #include "extensions/browser/image_util.h" 24 #include "extensions/browser/image_util.h"
25 #include "extensions/common/api/app_window.h" 25 #include "extensions/common/api/app_window.h"
26 #include "extensions/common/features/simple_feature.h" 26 #include "extensions/common/features/simple_feature.h"
27 #include "extensions/common/permissions/permissions_data.h" 27 #include "extensions/common/permissions/permissions_data.h"
28 #include "extensions/common/switches.h" 28 #include "extensions/common/switches.h"
29 #include "third_party/skia/include/core/SkColor.h" 29 #include "third_party/skia/include/core/SkColor.h"
30 #include "ui/base/ui_base_types.h" 30 #include "ui/base/ui_base_types.h"
31 #include "ui/gfx/rect.h" 31 #include "ui/gfx/rect.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 SetResult(result); 187 SetResult(result);
188 SendResponse(true); 188 SendResponse(true);
189 return true; 189 return true;
190 } 190 }
191 } 191 }
192 } 192 }
193 193
194 if (!GetBoundsSpec(*options, &create_params, &error_)) 194 if (!GetBoundsSpec(*options, &create_params, &error_))
195 return false; 195 return false;
196 196
197 if (!AppsClient::Get()->IsCurrentChannelOlderThanDev() || 197 if (!AppWindowClient::Get()->IsCurrentChannelOlderThanDev() ||
198 extension()->location() == extensions::Manifest::COMPONENT) { 198 extension()->location() == extensions::Manifest::COMPONENT) {
199 if (options->type == app_window::WINDOW_TYPE_PANEL) { 199 if (options->type == app_window::WINDOW_TYPE_PANEL) {
200 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL; 200 create_params.window_type = AppWindow::WINDOW_TYPE_PANEL;
201 } 201 }
202 } 202 }
203 203
204 if (!GetFrameOptions(*options, &create_params)) 204 if (!GetFrameOptions(*options, &create_params))
205 return false; 205 return false;
206 206
207 if (options->alpha_enabled.get()) { 207 if (options->alpha_enabled.get()) {
208 const char* whitelist[] = { 208 const char* whitelist[] = {
209 #if defined(OS_CHROMEOS) 209 #if defined(OS_CHROMEOS)
210 "B58B99751225318C7EB8CF4688B5434661083E07", // http://crbug.com/410550 210 "B58B99751225318C7EB8CF4688B5434661083E07", // http://crbug.com/410550
211 #endif 211 #endif
212 "0F42756099D914A026DADFA182871C015735DD95", // http://crbug.com/323773 212 "0F42756099D914A026DADFA182871C015735DD95", // http://crbug.com/323773
213 "2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7", 213 "2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7",
214 "E7E2461CE072DF036CF9592740196159E2D7C089", // http://crbug.com/356200 214 "E7E2461CE072DF036CF9592740196159E2D7C089", // http://crbug.com/356200
215 "A74A4D44C7CFCD8844830E6140C8D763E12DD8F3", 215 "A74A4D44C7CFCD8844830E6140C8D763E12DD8F3",
216 "312745D9BF916161191143F6490085EEA0434997", 216 "312745D9BF916161191143F6490085EEA0434997",
217 "53041A2FA309EECED01FFC751E7399186E860B2C", 217 "53041A2FA309EECED01FFC751E7399186E860B2C",
218 "A07A5B743CD82A1C2579DB77D353C98A23201EEF", // http://crbug.com/413748 218 "A07A5B743CD82A1C2579DB77D353C98A23201EEF", // http://crbug.com/413748
219 "F16F23C83C5F6DAD9B65A120448B34056DD80691", 219 "F16F23C83C5F6DAD9B65A120448B34056DD80691",
220 "0F585FB1D0FDFBEBCE1FEB5E9DFFB6DA476B8C9B" 220 "0F585FB1D0FDFBEBCE1FEB5E9DFFB6DA476B8C9B"
221 }; 221 };
222 if (AppsClient::Get()->IsCurrentChannelOlderThanDev() && 222 if (AppWindowClient::Get()->IsCurrentChannelOlderThanDev() &&
223 !extensions::SimpleFeature::IsIdInList( 223 !extensions::SimpleFeature::IsIdInList(
224 extension_id(), 224 extension_id(),
225 std::set<std::string>(whitelist, 225 std::set<std::string>(whitelist,
226 whitelist + arraysize(whitelist)))) { 226 whitelist + arraysize(whitelist)))) {
227 error_ = app_window_constants::kAlphaEnabledWrongChannel; 227 error_ = app_window_constants::kAlphaEnabledWrongChannel;
228 return false; 228 return false;
229 } 229 }
230 if (!extension()->permissions_data()->HasAPIPermission( 230 if (!extension()->permissions_data()->HasAPIPermission(
231 APIPermission::kAlphaEnabled)) { 231 APIPermission::kAlphaEnabled)) {
232 error_ = app_window_constants::kAlphaEnabledMissingPermission; 232 error_ = app_window_constants::kAlphaEnabledMissingPermission;
(...skipping 25 matching lines...) Expand all
258 APIPermission::kAlwaysOnTopWindows)) { 258 APIPermission::kAlwaysOnTopWindows)) {
259 error_ = app_window_constants::kAlwaysOnTopPermission; 259 error_ = app_window_constants::kAlwaysOnTopPermission;
260 return false; 260 return false;
261 } 261 }
262 } 262 }
263 263
264 if (options->focused.get()) 264 if (options->focused.get())
265 create_params.focused = *options->focused.get(); 265 create_params.focused = *options->focused.get();
266 266
267 if (options->visible_on_all_workspaces.get()) { 267 if (options->visible_on_all_workspaces.get()) {
268 if (AppsClient::Get()->IsCurrentChannelOlderThanDev()) { 268 if (AppWindowClient::Get()->IsCurrentChannelOlderThanDev()) {
269 error_ = app_window_constants::kVisibleOnAllWorkspacesWrongChannel; 269 error_ = app_window_constants::kVisibleOnAllWorkspacesWrongChannel;
270 return false; 270 return false;
271 } 271 }
272 create_params.visible_on_all_workspaces = 272 create_params.visible_on_all_workspaces =
273 *options->visible_on_all_workspaces.get(); 273 *options->visible_on_all_workspaces.get();
274 } 274 }
275 275
276 if (options->type != app_window::WINDOW_TYPE_PANEL) { 276 if (options->type != app_window::WINDOW_TYPE_PANEL) {
277 switch (options->state) { 277 switch (options->state) {
278 case app_window::STATE_NONE: 278 case app_window::STATE_NONE:
279 case app_window::STATE_NORMAL: 279 case app_window::STATE_NORMAL:
280 break; 280 break;
281 case app_window::STATE_FULLSCREEN: 281 case app_window::STATE_FULLSCREEN:
282 create_params.state = ui::SHOW_STATE_FULLSCREEN; 282 create_params.state = ui::SHOW_STATE_FULLSCREEN;
283 break; 283 break;
284 case app_window::STATE_MAXIMIZED: 284 case app_window::STATE_MAXIMIZED:
285 create_params.state = ui::SHOW_STATE_MAXIMIZED; 285 create_params.state = ui::SHOW_STATE_MAXIMIZED;
286 break; 286 break;
287 case app_window::STATE_MINIMIZED: 287 case app_window::STATE_MINIMIZED:
288 create_params.state = ui::SHOW_STATE_MINIMIZED; 288 create_params.state = ui::SHOW_STATE_MINIMIZED;
289 break; 289 break;
290 } 290 }
291 } 291 }
292 } 292 }
293 293
294 create_params.creator_process_id = 294 create_params.creator_process_id =
295 render_view_host_->GetProcess()->GetID(); 295 render_view_host_->GetProcess()->GetID();
296 296
297 AppWindow* app_window = 297 AppWindow* app_window =
298 AppsClient::Get()->CreateAppWindow(browser_context(), extension()); 298 AppWindowClient::Get()->CreateAppWindow(browser_context(), extension());
299 app_window->Init(url, new AppWindowContentsImpl(app_window), create_params); 299 app_window->Init(url, new AppWindowContentsImpl(app_window), create_params);
300 300
301 if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()) 301 if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode())
302 app_window->ForcedFullscreen(); 302 app_window->ForcedFullscreen();
303 303
304 content::RenderViewHost* created_view = 304 content::RenderViewHost* created_view =
305 app_window->web_contents()->GetRenderViewHost(); 305 app_window->web_contents()->GetRenderViewHost();
306 int view_id = MSG_ROUTING_NONE; 306 int view_id = MSG_ROUTING_NONE;
307 if (create_params.creator_process_id == created_view->GetProcess()->GetID()) 307 if (create_params.creator_process_id == created_view->GetProcess()->GetID())
308 view_id = created_view->GetRoutingID(); 308 view_id = created_view->GetRoutingID();
309 309
310 base::DictionaryValue* result = new base::DictionaryValue; 310 base::DictionaryValue* result = new base::DictionaryValue;
311 result->Set("viewId", new base::FundamentalValue(view_id)); 311 result->Set("viewId", new base::FundamentalValue(view_id));
312 result->Set("injectTitlebar", 312 result->Set("injectTitlebar",
313 new base::FundamentalValue(inject_html_titlebar_)); 313 new base::FundamentalValue(inject_html_titlebar_));
314 result->Set("id", new base::StringValue(app_window->window_key())); 314 result->Set("id", new base::StringValue(app_window->window_key()));
315 app_window->GetSerializedState(result); 315 app_window->GetSerializedState(result);
316 SetResult(result); 316 SetResult(result);
317 317
318 if (AppWindowRegistry::Get(browser_context()) 318 if (AppWindowRegistry::Get(browser_context())
319 ->HadDevToolsAttached(created_view)) { 319 ->HadDevToolsAttached(created_view)) {
320 AppsClient::Get()->OpenDevToolsWindow( 320 AppWindowClient::Get()->OpenDevToolsWindow(
321 app_window->web_contents(), 321 app_window->web_contents(),
322 base::Bind(&AppWindowCreateFunction::SendResponse, this, true)); 322 base::Bind(&AppWindowCreateFunction::SendResponse, this, true));
323 return true; 323 return true;
324 } 324 }
325 325
326 SendResponse(true); 326 SendResponse(true);
327 app_window->WindowEventsReady(); 327 app_window->WindowEventsReady();
328 328
329 return true; 329 return true;
330 } 330 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 504
505 if (options.frame->as_frame_options->inactive_color.get()) { 505 if (options.frame->as_frame_options->inactive_color.get()) {
506 error_ = app_window_constants::kInactiveColorWithoutColor; 506 error_ = app_window_constants::kInactiveColorWithoutColor;
507 return false; 507 return false;
508 } 508 }
509 509
510 return true; 510 return true;
511 } 511 }
512 512
513 } // namespace extensions 513 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698