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

Side by Side Diff: trunk/src/apps/shell_window.cc

Issue 22356002: Revert 215745 "Fix crash when reloading packaged app. " (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 4 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 "apps/shell_window.h" 5 #include "apps/shell_window.h"
6 6
7 #include "apps/shell_window_geometry_cache.h" 7 #include "apps/shell_window_geometry_cache.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 bool last_unlocked_by_target) { 273 bool last_unlocked_by_target) {
274 bool has_permission = IsExtensionWithPermissionOrSuggestInConsole( 274 bool has_permission = IsExtensionWithPermissionOrSuggestInConsole(
275 APIPermission::kPointerLock, 275 APIPermission::kPointerLock,
276 extension_, 276 extension_,
277 web_contents->GetRenderViewHost()); 277 web_contents->GetRenderViewHost());
278 278
279 web_contents->GotResponseToLockMouseRequest(has_permission); 279 web_contents->GotResponseToLockMouseRequest(has_permission);
280 } 280 }
281 281
282 void ShellWindow::OnNativeClose() { 282 void ShellWindow::OnNativeClose() {
283 if (extension_) { 283 extensions::ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this);
284 // If |extension_| is NULL here, it is because the extension has been 284 if (shell_window_contents_)
285 // unloaded. In this case, the window will have already been removed from 285 shell_window_contents_->NativeWindowClosed();
286 // the ShellWindowRegistry, and the app can not be informed of the window
287 // closing as it has gone.
288 extensions::ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this);
289 if (shell_window_contents_)
290 shell_window_contents_->NativeWindowClosed();
291 }
292 delete this; 286 delete this;
293 } 287 }
294 288
295 void ShellWindow::OnNativeWindowChanged() { 289 void ShellWindow::OnNativeWindowChanged() {
296 SaveWindowPosition(); 290 SaveWindowPosition();
297 if (shell_window_contents_ && native_app_window_) 291 if (shell_window_contents_ && native_app_window_)
298 shell_window_contents_->NativeWindowChanged(native_app_window_.get()); 292 shell_window_contents_->NativeWindowChanged(native_app_window_.get());
299 } 293 }
300 294
301 void ShellWindow::OnNativeWindowActivated() { 295 void ShellWindow::OnNativeWindowActivated() {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 delegate_->PreferredIconSize(), 440 delegate_->PreferredIconSize(),
447 extensions::IconsInfo::GetDefaultAppIcon(), 441 extensions::IconsInfo::GetDefaultAppIcon(),
448 this)); 442 this));
449 443
450 // Triggers actual image loading with 1x resources. The 2x resource will 444 // Triggers actual image loading with 1x resources. The 2x resource will
451 // be handled by IconImage class when requested. 445 // be handled by IconImage class when requested.
452 app_icon_image_->image_skia().GetRepresentation(ui::SCALE_FACTOR_100P); 446 app_icon_image_->image_skia().GetRepresentation(ui::SCALE_FACTOR_100P);
453 } 447 }
454 448
455 void ShellWindow::CloseContents(WebContents* contents) { 449 void ShellWindow::CloseContents(WebContents* contents) {
456 Close(); 450 native_app_window_->Close();
457 } 451 }
458 452
459 bool ShellWindow::ShouldSuppressDialogs() { 453 bool ShellWindow::ShouldSuppressDialogs() {
460 return true; 454 return true;
461 } 455 }
462 456
463 content::ColorChooser* ShellWindow::OpenColorChooser(WebContents* web_contents, 457 content::ColorChooser* ShellWindow::OpenColorChooser(WebContents* web_contents,
464 SkColor initial_color) { 458 SkColor initial_color) {
465 return delegate_->ShowColorChooser(web_contents, initial_color); 459 return delegate_->ShowColorChooser(web_contents, initial_color);
466 } 460 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 // TODO(jianli): once http://crbug.com/123007 is fixed, we'll no longer 519 // TODO(jianli): once http://crbug.com/123007 is fixed, we'll no longer
526 // need to make the native window (ShellWindowViews specially) update 520 // need to make the native window (ShellWindowViews specially) update
527 // the clickthrough region for the new RVH. 521 // the clickthrough region for the new RVH.
528 native_app_window_->RenderViewHostChanged(); 522 native_app_window_->RenderViewHostChanged();
529 break; 523 break;
530 } 524 }
531 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { 525 case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
532 const extensions::Extension* unloaded_extension = 526 const extensions::Extension* unloaded_extension =
533 content::Details<extensions::UnloadedExtensionInfo>( 527 content::Details<extensions::UnloadedExtensionInfo>(
534 details)->extension; 528 details)->extension;
535 if (extension_ == unloaded_extension) { 529 if (extension_ == unloaded_extension)
536 Close(); 530 native_app_window_->Close();
537 // After this notification finishes processing, the Extension will be
538 // deleted, so we null out our reference to avoid bad access.
539 extension_ = NULL;
540 }
541 break; 531 break;
542 } 532 }
543 case chrome::NOTIFICATION_APP_TERMINATING: 533 case chrome::NOTIFICATION_APP_TERMINATING:
544 Close(); 534 native_app_window_->Close();
545 break; 535 break;
546 default: 536 default:
547 NOTREACHED() << "Received unexpected notification"; 537 NOTREACHED() << "Received unexpected notification";
548 } 538 }
549 } 539 }
550 540
551 void ShellWindow::SetWebContentsBlocked(content::WebContents* web_contents, 541 void ShellWindow::SetWebContentsBlocked(content::WebContents* web_contents,
552 bool blocked) { 542 bool blocked) {
553 delegate_->SetWebContentsBlocked(web_contents, blocked); 543 delegate_->SetWebContentsBlocked(web_contents, blocked);
554 } 544 }
555 545
556 bool ShellWindow::IsWebContentsVisible(content::WebContents* web_contents) { 546 bool ShellWindow::IsWebContentsVisible(content::WebContents* web_contents) {
557 return delegate_->IsWebContentsVisible(web_contents); 547 return delegate_->IsWebContentsVisible(web_contents);
558 } 548 }
559 549
560 extensions::ActiveTabPermissionGranter* 550 extensions::ActiveTabPermissionGranter*
561 ShellWindow::GetActiveTabPermissionGranter() { 551 ShellWindow::GetActiveTabPermissionGranter() {
562 // Shell windows don't support the activeTab permission. 552 // Shell windows don't support the activeTab permission.
563 return NULL; 553 return NULL;
564 } 554 }
565 555
566 WebContentsModalDialogHost* ShellWindow::GetWebContentsModalDialogHost() { 556 WebContentsModalDialogHost* ShellWindow::GetWebContentsModalDialogHost() {
567 return native_app_window_.get(); 557 return native_app_window_.get();
568 } 558 }
569 559
570 void ShellWindow::Close() {
571 extensions::ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this);
572 native_app_window_->Close();
573 }
574
575 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level, 560 void ShellWindow::AddMessageToDevToolsConsole(ConsoleMessageLevel level,
576 const std::string& message) { 561 const std::string& message) {
577 content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); 562 content::RenderViewHost* rvh = web_contents()->GetRenderViewHost();
578 rvh->Send(new ExtensionMsg_AddMessageToConsole( 563 rvh->Send(new ExtensionMsg_AddMessageToConsole(
579 rvh->GetRoutingID(), level, message)); 564 rvh->GetRoutingID(), level, message));
580 } 565 }
581 566
582 void ShellWindow::SaveWindowPosition() { 567 void ShellWindow::SaveWindowPosition() {
583 if (window_key_.empty()) 568 if (window_key_.empty())
584 return; 569 return;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 region.bounds.x(), 626 region.bounds.x(),
642 region.bounds.y(), 627 region.bounds.y(),
643 region.bounds.right(), 628 region.bounds.right(),
644 region.bounds.bottom(), 629 region.bounds.bottom(),
645 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); 630 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
646 } 631 }
647 return sk_region; 632 return sk_region;
648 } 633 }
649 634
650 } // namespace apps 635 } // namespace apps
OLDNEW
« no previous file with comments | « trunk/src/apps/shell_window.h ('k') | trunk/src/chrome/browser/extensions/platform_app_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698