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

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

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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
« no previous file with comments | « chrome/browser/ui/panels/panel.h ('k') | chrome/browser/ui/panels/panel_browser_frame_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_prefs.h" 8 #include "chrome/browser/extensions/extension_prefs.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 content::NotificationService::NoDetails()); 100 content::NotificationService::NoDetails());
101 } 101 }
102 102
103 void Panel::SetAutoResizable(bool resizable) { 103 void Panel::SetAutoResizable(bool resizable) {
104 if (auto_resizable_ == resizable) 104 if (auto_resizable_ == resizable)
105 return; 105 return;
106 106
107 auto_resizable_ = resizable; 107 auto_resizable_ = resizable;
108 if (auto_resizable_) { 108 if (auto_resizable_) {
109 browser()->tabstrip_model()->AddObserver(this); 109 browser()->tabstrip_model()->AddObserver(this);
110 TabContents* tab_contents = browser()->GetSelectedTabContents(); 110 WebContents* web_contents = browser()->GetSelectedWebContents();
111 if (tab_contents) 111 if (web_contents)
112 EnableTabContentsAutoResize(tab_contents); 112 EnableWebContentsAutoResize(web_contents);
113 } else { 113 } else {
114 browser()->tabstrip_model()->RemoveObserver(this); 114 browser()->tabstrip_model()->RemoveObserver(this);
115 registrar_.RemoveAll(); 115 registrar_.RemoveAll();
116 } 116 }
117 } 117 }
118 118
119 void Panel::SetSizeRange(const gfx::Size& min_size, const gfx::Size& max_size) { 119 void Panel::SetSizeRange(const gfx::Size& min_size, const gfx::Size& max_size) {
120 if (min_size == min_size_ && max_size == max_size_) 120 if (min_size == min_size_ && max_size == max_size_)
121 return; 121 return;
122 122
123 DCHECK(min_size.width() <= max_size.width()); 123 DCHECK(min_size.width() <= max_size.width());
124 DCHECK(min_size.height() <= max_size.height()); 124 DCHECK(min_size.height() <= max_size.height());
125 min_size_ = min_size; 125 min_size_ = min_size;
126 max_size_ = max_size; 126 max_size_ = max_size;
127 127
128 ConfigureAutoResize(browser()->GetSelectedTabContents()); 128 ConfigureAutoResize(browser()->GetSelectedWebContents());
129 } 129 }
130 130
131 void Panel::SetAppIconVisibility(bool visible) { 131 void Panel::SetAppIconVisibility(bool visible) {
132 if (app_icon_visible_ == visible) 132 if (app_icon_visible_ == visible)
133 return; 133 return;
134 app_icon_visible_ = visible; 134 app_icon_visible_ = visible;
135 native_panel_->SetPanelAppIconVisibility(visible); 135 native_panel_->SetPanelAppIconVisibility(visible);
136 } 136 }
137 137
138 void Panel::SetExpansionState(ExpansionState new_state) { 138 void Panel::SetExpansionState(ExpansionState new_state) {
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 void Panel::ShowAvatarBubbleFromAvatarButton() { 591 void Panel::ShowAvatarBubbleFromAvatarButton() {
592 // Panels will never show an avatar button so this should never be called. 592 // Panels will never show an avatar button so this should never be called.
593 NOTREACHED(); 593 NOTREACHED();
594 } 594 }
595 595
596 void Panel::TabInsertedAt(TabContentsWrapper* contents, 596 void Panel::TabInsertedAt(TabContentsWrapper* contents,
597 int index, 597 int index,
598 bool foreground) { 598 bool foreground) {
599 if (auto_resizable_) { 599 if (auto_resizable_) {
600 DCHECK_EQ(0, index); 600 DCHECK_EQ(0, index);
601 EnableTabContentsAutoResize(contents->tab_contents()); 601 EnableWebContentsAutoResize(contents->web_contents());
602 } 602 }
603 } 603 }
604 604
605 void Panel::EnableTabContentsAutoResize(TabContents* tab_contents) { 605 void Panel::EnableWebContentsAutoResize(WebContents* web_contents) {
606 DCHECK(tab_contents); 606 DCHECK(web_contents);
607 ConfigureAutoResize(tab_contents); 607 ConfigureAutoResize(web_contents);
608 608
609 // We also need to know when the render view host changes in order 609 // We also need to know when the render view host changes in order
610 // to turn on auto-resize notifications in the new render view host. 610 // to turn on auto-resize notifications in the new render view host.
611 registrar_.RemoveAll(); // Stop notifications for previous contents, if any. 611 registrar_.RemoveAll(); // Stop notifications for previous contents, if any.
612 registrar_.Add( 612 registrar_.Add(
613 this, 613 this,
614 content::NOTIFICATION_TAB_CONTENTS_SWAPPED, 614 content::NOTIFICATION_WEB_CONTENTS_SWAPPED,
615 content::Source<TabContents>(tab_contents)); 615 content::Source<WebContents>(web_contents));
616 } 616 }
617 617
618 void Panel::Observe(int type, 618 void Panel::Observe(int type,
619 const content::NotificationSource& source, 619 const content::NotificationSource& source,
620 const content::NotificationDetails& details) { 620 const content::NotificationDetails& details) {
621 DCHECK_EQ(type, content::NOTIFICATION_TAB_CONTENTS_SWAPPED); 621 DCHECK_EQ(type, content::NOTIFICATION_WEB_CONTENTS_SWAPPED);
622 ConfigureAutoResize(content::Source<TabContents>(source).ptr()); 622 ConfigureAutoResize(content::Source<WebContents>(source).ptr());
623 } 623 }
624 624
625 void Panel::ConfigureAutoResize(TabContents* tab_contents) { 625 void Panel::ConfigureAutoResize(WebContents* web_contents) {
626 if (!auto_resizable_ || !tab_contents) 626 if (!auto_resizable_ || !web_contents)
627 return; 627 return;
628 628
629 // NULL might be returned if the tab has not been added. 629 // NULL might be returned if the tab has not been added.
630 RenderViewHost* render_view_host = tab_contents->GetRenderViewHost(); 630 RenderViewHost* render_view_host = web_contents->GetRenderViewHost();
631 if (!render_view_host) 631 if (!render_view_host)
632 return; 632 return;
633 633
634 render_view_host->EnableAutoResize( 634 render_view_host->EnableAutoResize(
635 min_size_, 635 min_size_,
636 native_panel_->ContentSizeFromWindowSize(max_size_)); 636 native_panel_->ContentSizeFromWindowSize(max_size_));
637 } 637 }
638 638
639 void Panel::OnWindowSizeAvailable() { 639 void Panel::OnWindowSizeAvailable() {
640 ConfigureAutoResize(browser()->GetSelectedTabContents()); 640 ConfigureAutoResize(browser()->GetSelectedWebContents());
641 } 641 }
642 642
643 void Panel::DestroyBrowser() { 643 void Panel::DestroyBrowser() {
644 native_panel_->DestroyPanelBrowser(); 644 native_panel_->DestroyPanelBrowser();
645 } 645 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel.h ('k') | chrome/browser/ui/panels/panel_browser_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698