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

Side by Side Diff: chrome/browser/ui/panels/panel.cc

Issue 1132163004: Remove NOTIFICATION_RENDER_VIEW_HOST_CHANGED. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove web_contents_ from WebContentsTracker as we can get it from WCO Created 5 years, 7 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 "chrome/browser/ui/panels/panel.h" 5 #include "chrome/browser/ui/panels/panel.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 default: 430 default:
431 LOG(WARNING) << "Received unimplemented command: " << id; 431 LOG(WARNING) << "Received unimplemented command: " << id;
432 break; 432 break;
433 } 433 }
434 } 434 }
435 435
436 void Panel::Observe(int type, 436 void Panel::Observe(int type,
437 const content::NotificationSource& source, 437 const content::NotificationSource& source,
438 const content::NotificationDetails& details) { 438 const content::NotificationDetails& details) {
439 switch (type) { 439 switch (type) {
440 case content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED:
441 ConfigureAutoResize(content::Source<content::WebContents>(source).ptr());
442 break;
443 case chrome::NOTIFICATION_APP_TERMINATING: 440 case chrome::NOTIFICATION_APP_TERMINATING:
444 Close(); 441 Close();
445 break; 442 break;
446 default: 443 default:
447 NOTREACHED() << "Received unexpected notification " << type; 444 NOTREACHED() << "Received unexpected notification " << type;
448 } 445 }
449 } 446 }
450 447
448 void Panel::RenderViewHostChanged(content::RenderViewHost* old_host,
449 content::RenderViewHost* new_host) {
450 ConfigureAutoResize(web_contents());
451 }
452
451 void Panel::OnExtensionUnloaded( 453 void Panel::OnExtensionUnloaded(
452 content::BrowserContext* browser_context, 454 content::BrowserContext* browser_context,
453 const extensions::Extension* extension, 455 const extensions::Extension* extension,
454 extensions::UnloadedExtensionInfo::Reason reason) { 456 extensions::UnloadedExtensionInfo::Reason reason) {
455 if (extension->id() == extension_id()) 457 if (extension->id() == extension_id())
456 Close(); 458 Close();
457 } 459 }
458 void Panel::OnTitlebarClicked(panel::ClickModifier modifier) { 460 void Panel::OnTitlebarClicked(panel::ClickModifier modifier) {
459 if (collection_) 461 if (collection_)
460 collection_->OnPanelTitlebarClicked(this, modifier); 462 collection_->OnPanelTitlebarClicked(this, modifier);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 if (auto_resizable_ == resizable) 588 if (auto_resizable_ == resizable)
587 return; 589 return;
588 590
589 auto_resizable_ = resizable; 591 auto_resizable_ = resizable;
590 content::WebContents* web_contents = GetWebContents(); 592 content::WebContents* web_contents = GetWebContents();
591 if (auto_resizable_) { 593 if (auto_resizable_) {
592 if (web_contents) 594 if (web_contents)
593 EnableWebContentsAutoResize(web_contents); 595 EnableWebContentsAutoResize(web_contents);
594 } else { 596 } else {
595 if (web_contents) { 597 if (web_contents) {
596 registrar_.Remove(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 598 content::WebContentsObserver::Observe(nullptr);
597 content::Source<content::WebContents>(web_contents));
598 599
599 // NULL might be returned if the tab has not been added. 600 // NULL might be returned if the tab has not been added.
600 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); 601 RenderViewHost* render_view_host = web_contents->GetRenderViewHost();
601 if (render_view_host) 602 if (render_view_host)
602 render_view_host->DisableAutoResize(full_size_); 603 render_view_host->DisableAutoResize(full_size_);
603 } 604 }
604 } 605 }
605 } 606 }
606 607
607 void Panel::EnableWebContentsAutoResize(content::WebContents* web_contents) { 608 void Panel::EnableWebContentsAutoResize(content::WebContents* web_contents) {
608 DCHECK(web_contents); 609 DCHECK(web_contents);
609 ConfigureAutoResize(web_contents); 610 ConfigureAutoResize(web_contents);
610 611
611 // We also need to know when the render view host changes in order 612 // We also need to know when the render view host changes in order
612 // to turn on auto-resize notifications in the new render view host. 613 // to turn on auto-resize notifications in the new render view host.
613 if (!registrar_.IsRegistered( 614 content::WebContentsObserver::Observe(web_contents);
614 this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
615 content::Source<content::WebContents>(web_contents))) {
616 registrar_.Add(
617 this,
618 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
619 content::Source<content::WebContents>(web_contents));
620 }
621 } 615 }
622 616
623 void Panel::OnContentsAutoResized(const gfx::Size& new_content_size) { 617 void Panel::OnContentsAutoResized(const gfx::Size& new_content_size) {
624 DCHECK(auto_resizable_); 618 DCHECK(auto_resizable_);
625 if (!collection_) 619 if (!collection_)
626 return; 620 return;
627 621
628 gfx::Size new_window_size = 622 gfx::Size new_window_size =
629 native_panel_->WindowSizeFromContentSize(new_content_size); 623 native_panel_->WindowSizeFromContentSize(new_content_size);
630 624
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 } 790 }
797 791
798 void Panel::MinimizeBySystem() { 792 void Panel::MinimizeBySystem() {
799 native_panel_->MinimizePanelBySystem(); 793 native_panel_->MinimizePanelBySystem();
800 } 794 }
801 795
802 Panel::Panel(Profile* profile, 796 Panel::Panel(Profile* profile,
803 const std::string& app_name, 797 const std::string& app_name,
804 const gfx::Size& min_size, 798 const gfx::Size& min_size,
805 const gfx::Size& max_size) 799 const gfx::Size& max_size)
806 : app_name_(app_name), 800 : content::WebContentsObserver(),
801 app_name_(app_name),
807 profile_(profile), 802 profile_(profile),
808 collection_(NULL), 803 collection_(NULL),
809 initialized_(false), 804 initialized_(false),
810 min_size_(min_size), 805 min_size_(min_size),
811 max_size_(max_size), 806 max_size_(max_size),
812 max_size_policy_(DEFAULT_MAX_SIZE), 807 max_size_policy_(DEFAULT_MAX_SIZE),
813 auto_resizable_(false), 808 auto_resizable_(false),
814 in_preview_mode_(false), 809 in_preview_mode_(false),
815 native_panel_(NULL), 810 native_panel_(NULL),
816 attention_mode_(USE_PANEL_ATTENTION), 811 attention_mode_(USE_PANEL_ATTENTION),
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 // static 891 // static
897 void Panel::FormatTitleForDisplay(base::string16* title) { 892 void Panel::FormatTitleForDisplay(base::string16* title) {
898 size_t current_index = 0; 893 size_t current_index = 0;
899 size_t match_index; 894 size_t match_index;
900 while ((match_index = title->find(L'\n', current_index)) != 895 while ((match_index = title->find(L'\n', current_index)) !=
901 base::string16::npos) { 896 base::string16::npos) {
902 title->replace(match_index, 1, base::string16()); 897 title->replace(match_index, 1, base::string16());
903 current_index = match_index; 898 current_index = match_index;
904 } 899 }
905 } 900 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698