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

Unified Diff: chrome/browser/views/frame/browser_view.cc

Issue 42058: Merge r11285.... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/branches/169/src/
Patch Set: Created 11 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/views/frame/browser_view.h ('k') | chrome/views/view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/frame/browser_view.cc
===================================================================
--- chrome/browser/views/frame/browser_view.cc (revision 11412)
+++ chrome/browser/views/frame/browser_view.cc (working copy)
@@ -93,6 +93,9 @@
// If not -1, windows are shown with this state.
static int explicit_show_state = -1;
+// Returned from BrowserView::GetClassName.
+static const char kBrowserViewClassName[] = "browser/views/BrowserView";
+
static const struct {
bool separator;
int command;
@@ -126,12 +129,11 @@
class ResizeCorner : public views::View {
public:
- explicit ResizeCorner(const BrowserView* parent)
- : parent_(parent) {
- }
+ ResizeCorner() { }
virtual void Paint(ChromeCanvas* canvas) {
- if (parent_ && !parent_->CanCurrentlyResize())
+ BrowserView* browser = GetBrowserView();
+ if (browser && !browser->CanCurrentlyResize())
return;
SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed(
@@ -158,7 +160,8 @@
}
virtual gfx::Size GetPreferredSize() {
- return (parent_ && !parent_->CanCurrentlyResize()) ?
+ BrowserView* browser = GetBrowserView();
+ return (browser && !browser->CanCurrentlyResize()) ?
gfx::Size() : GetSize();
}
@@ -174,7 +177,13 @@
}
private:
- const BrowserView* parent_;
+ // Returns the BrowserView we're displayed in. Returns NULL if we're not
+ // currently in a browser view.
+ BrowserView* GetBrowserView() {
+ View* browser = GetAncestorWithClassName(kBrowserViewClassName);
+ return browser ? static_cast<BrowserView*>(browser) : NULL;
+ }
+
DISALLOW_COPY_AND_ASSIGN(ResizeCorner);
};
@@ -1185,6 +1194,10 @@
///////////////////////////////////////////////////////////////////////////////
// BrowserView, views::View overrides:
+std::string BrowserView::GetClassName() const {
+ return kBrowserViewClassName;
+}
+
void BrowserView::Layout() {
int top = LayoutTabStrip();
top = LayoutToolbar(top);
@@ -1445,7 +1458,7 @@
if (contents && contents->IsDownloadShelfVisible()) {
new_shelf = static_cast<DownloadShelfView*>(contents->GetDownloadShelf());
if (new_shelf != active_download_shelf_)
- new_shelf->AddChildView(new ResizeCorner(this));
+ new_shelf->AddChildView(new ResizeCorner());
}
return UpdateChildViewAndLayout(new_shelf, &active_download_shelf_);
}
« no previous file with comments | « chrome/browser/views/frame/browser_view.h ('k') | chrome/views/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698