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

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

Issue 696063008: Refactor ShellDesktopController and ShellNativeAppWindow to allow for non-aura implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: + Created 6 years, 1 month 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 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 "extensions/browser/app_window/app_window.h" 5 #include "extensions/browser/app_window/app_window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord()) 247 CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord())
248 << "Only off the record window may be opened in the guest mode."; 248 << "Only off the record window may be opened in the guest mode.";
249 } 249 }
250 250
251 void AppWindow::Init(const GURL& url, 251 void AppWindow::Init(const GURL& url,
252 AppWindowContents* app_window_contents, 252 AppWindowContents* app_window_contents,
253 const CreateParams& params) { 253 const CreateParams& params) {
254 // Initialize the render interface and web contents 254 // Initialize the render interface and web contents
255 app_window_contents_.reset(app_window_contents); 255 app_window_contents_.reset(app_window_contents);
256 app_window_contents_->Initialize(browser_context(), url); 256 app_window_contents_->Initialize(browser_context(), url);
257 WebContents* web_contents = app_window_contents_->GetWebContents();
258 if (CommandLine::ForCurrentProcess()->HasSwitch( 257 if (CommandLine::ForCurrentProcess()->HasSwitch(
259 switches::kEnableAppsShowOnFirstPaint)) { 258 switches::kEnableAppsShowOnFirstPaint)) {
260 content::WebContentsObserver::Observe(web_contents); 259 content::WebContentsObserver::Observe(web_contents());
261 } 260 }
262 app_delegate_->InitWebContents(web_contents); 261 app_delegate_->InitWebContents(web_contents());
263 262
264 WebContentsModalDialogManager::CreateForWebContents(web_contents); 263 WebContentsModalDialogManager::CreateForWebContents(web_contents());
265 264
266 web_contents->SetDelegate(this); 265 web_contents()->SetDelegate(this);
267 WebContentsModalDialogManager::FromWebContents(web_contents) 266 WebContentsModalDialogManager::FromWebContents(web_contents())
268 ->SetDelegate(this); 267 ->SetDelegate(this);
269 SetViewType(web_contents, VIEW_TYPE_APP_WINDOW); 268 SetViewType(web_contents(), VIEW_TYPE_APP_WINDOW);
270 269
271 // Initialize the window 270 // Initialize the window
272 CreateParams new_params = LoadDefaults(params); 271 CreateParams new_params = LoadDefaults(params);
273 window_type_ = new_params.window_type; 272 window_type_ = new_params.window_type;
274 window_key_ = new_params.window_key; 273 window_key_ = new_params.window_key;
275 274
276 // Windows cannot be always-on-top in fullscreen mode for security reasons. 275 // Windows cannot be always-on-top in fullscreen mode for security reasons.
277 cached_always_on_top_ = new_params.always_on_top; 276 cached_always_on_top_ = new_params.always_on_top;
278 if (new_params.state == ui::SHOW_STATE_FULLSCREEN) 277 if (new_params.state == ui::SHOW_STATE_FULLSCREEN)
279 new_params.always_on_top = false; 278 new_params.always_on_top = false;
280 279
281 requested_alpha_enabled_ = new_params.alpha_enabled; 280 requested_alpha_enabled_ = new_params.alpha_enabled;
282 281
283 AppWindowClient* app_window_client = AppWindowClient::Get(); 282 AppWindowClient* app_window_client = AppWindowClient::Get();
284 native_app_window_.reset( 283 native_app_window_.reset(
285 app_window_client->CreateNativeAppWindow(this, &new_params)); 284 app_window_client->CreateNativeAppWindow(this, &new_params));
286 285
287 helper_.reset(new AppWebContentsHelper( 286 helper_.reset(new AppWebContentsHelper(
288 browser_context_, extension_id_, web_contents, app_delegate_.get())); 287 browser_context_, extension_id_, web_contents(), app_delegate_.get()));
289 288
290 popup_manager_.reset( 289 popup_manager_.reset(
291 new web_modal::PopupManager(GetWebContentsModalDialogHost())); 290 new web_modal::PopupManager(GetWebContentsModalDialogHost()));
292 popup_manager_->RegisterWith(web_contents); 291 popup_manager_->RegisterWith(web_contents());
293 292
294 UpdateExtensionAppIcon(); 293 UpdateExtensionAppIcon();
295 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this); 294 AppWindowRegistry::Get(browser_context_)->AddAppWindow(this);
296 295
297 if (new_params.hidden) { 296 if (new_params.hidden) {
298 // Although the window starts hidden by default, calling Hide() here 297 // Although the window starts hidden by default, calling Hide() here
299 // notifies observers of the window being hidden. 298 // notifies observers of the window being hidden.
300 Hide(); 299 Hide();
301 } else { 300 } else {
302 // Panels are not activated by default. 301 // Panels are not activated by default.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 app_window_contents_->LoadContents(new_params.creator_process_id); 335 app_window_contents_->LoadContents(new_params.creator_process_id);
337 336
338 if (CommandLine::ForCurrentProcess()->HasSwitch( 337 if (CommandLine::ForCurrentProcess()->HasSwitch(
339 extensions::switches::kEnableAppsShowOnFirstPaint)) { 338 extensions::switches::kEnableAppsShowOnFirstPaint)) {
340 // We want to show the window only when the content has been painted. For 339 // We want to show the window only when the content has been painted. For
341 // that to happen, we need to define a size for the content, otherwise the 340 // that to happen, we need to define a size for the content, otherwise the
342 // layout will happen in a 0x0 area. 341 // layout will happen in a 0x0 area.
343 gfx::Insets frame_insets = native_app_window_->GetFrameInsets(); 342 gfx::Insets frame_insets = native_app_window_->GetFrameInsets();
344 gfx::Rect initial_bounds = new_params.GetInitialWindowBounds(frame_insets); 343 gfx::Rect initial_bounds = new_params.GetInitialWindowBounds(frame_insets);
345 initial_bounds.Inset(frame_insets); 344 initial_bounds.Inset(frame_insets);
346 app_delegate_->ResizeWebContents(web_contents, initial_bounds.size()); 345 app_delegate_->ResizeWebContents(web_contents(), initial_bounds.size());
347 } 346 }
348 } 347 }
349 348
350 AppWindow::~AppWindow() { 349 AppWindow::~AppWindow() {
351 } 350 }
352 351
353 void AppWindow::RequestMediaAccessPermission( 352 void AppWindow::RequestMediaAccessPermission(
354 content::WebContents* web_contents, 353 content::WebContents* web_contents,
355 const content::MediaStreamRequest& request, 354 const content::MediaStreamRequest& request,
356 const content::MediaResponseCallback& callback) { 355 const content::MediaResponseCallback& callback) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 if (show_on_first_paint_) { 444 if (show_on_first_paint_) {
446 DCHECK(delayed_show_type_ == SHOW_ACTIVE || 445 DCHECK(delayed_show_type_ == SHOW_ACTIVE ||
447 delayed_show_type_ == SHOW_INACTIVE); 446 delayed_show_type_ == SHOW_INACTIVE);
448 Show(delayed_show_type_); 447 Show(delayed_show_type_);
449 } 448 }
450 } 449 }
451 450
452 void AppWindow::OnNativeClose() { 451 void AppWindow::OnNativeClose() {
453 AppWindowRegistry::Get(browser_context_)->RemoveAppWindow(this); 452 AppWindowRegistry::Get(browser_context_)->RemoveAppWindow(this);
454 if (app_window_contents_) { 453 if (app_window_contents_) {
455 WebContents* web_contents = app_window_contents_->GetWebContents(); 454 WebContentsModalDialogManager* modal_dialog_manager =
456 WebContentsModalDialogManager::FromWebContents(web_contents) 455 WebContentsModalDialogManager::FromWebContents(web_contents());
457 ->SetDelegate(NULL); 456 if (modal_dialog_manager) // May be null in unit tests.
457 modal_dialog_manager->SetDelegate(nullptr);
458 app_window_contents_->NativeWindowClosed(); 458 app_window_contents_->NativeWindowClosed();
459 } 459 }
460 delete this; 460 delete this;
461 } 461 }
462 462
463 void AppWindow::OnNativeWindowChanged() { 463 void AppWindow::OnNativeWindowChanged() {
464 SaveWindowPosition(); 464 SaveWindowPosition();
465 465
466 #if defined(OS_WIN) 466 #if defined(OS_WIN)
467 if (native_app_window_ && cached_always_on_top_ && !IsFullscreen() && 467 if (native_app_window_ && cached_always_on_top_ && !IsFullscreen() &&
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 region.bounds.x(), 1089 region.bounds.x(),
1090 region.bounds.y(), 1090 region.bounds.y(),
1091 region.bounds.right(), 1091 region.bounds.right(),
1092 region.bounds.bottom(), 1092 region.bounds.bottom(),
1093 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 1093 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
1094 } 1094 }
1095 return sk_region; 1095 return sk_region;
1096 } 1096 }
1097 1097
1098 } // namespace extensions 1098 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/power/process_power_collector_unittest.cc ('k') | extensions/browser/app_window/test_app_window_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698