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

Unified Diff: chrome/browser/ui/views/frame/contents_container.cc

Issue 10915217: Hook up SetInstantPreviewHeight for ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move hidden notification, too. Created 8 years, 3 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/ui/views/frame/contents_container.h ('k') | chrome/test/base/test_browser_window.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/frame/contents_container.cc
diff --git a/chrome/browser/ui/views/frame/contents_container.cc b/chrome/browser/ui/views/frame/contents_container.cc
index 508fff9f24523528d3bd8804b09a49af50f3bfda..c1cd16b9b73462613fce9b6dc740bce815af384c 100644
--- a/chrome/browser/ui/views/frame/contents_container.cc
+++ b/chrome/browser/ui/views/frame/contents_container.cc
@@ -18,7 +18,9 @@ ContentsContainer::ContentsContainer(views::WebView* active)
overlay_(NULL),
preview_(NULL),
preview_web_contents_(NULL),
- active_top_margin_(0) {
+ active_top_margin_(0),
+ preview_height_(100),
+ preview_height_units_(INSTANT_SIZE_PERCENT) {
AddChildView(active_);
}
@@ -54,17 +56,23 @@ void ContentsContainer::MakePreviewContentsActiveContents() {
}
void ContentsContainer::SetPreview(views::WebView* preview,
- WebContents* preview_web_contents) {
- if (preview == preview_)
+ WebContents* preview_web_contents,
+ int height,
+ InstantSizeUnits units) {
+ const int old_height = PreviewHeightInPixels();
+ preview_height_ = height;
+ preview_height_units_ = units;
+ if (preview == preview_ && preview_web_contents_ == preview_web_contents &&
+ old_height == PreviewHeightInPixels())
return;
-
- if (preview_)
- RemoveChildView(preview_);
- preview_ = preview;
+ if (preview_ != preview) {
+ if (preview_)
+ RemoveChildView(preview_);
+ preview_ = preview;
+ if (preview_)
+ AddChildView(preview_);
+ }
preview_web_contents_ = preview_web_contents;
- if (preview_)
- AddChildView(preview_);
-
Layout();
}
@@ -95,13 +103,25 @@ void ContentsContainer::Layout() {
overlay_->SetBounds(0, 0, width(), height());
if (preview_)
- preview_->SetBounds(0, 0, width(), height());
+ preview_->SetBounds(0, 0, width(), PreviewHeightInPixels());
// Need to invoke views::View in case any views whose bounds didn't change
// still need a layout.
views::View::Layout();
}
+int ContentsContainer::PreviewHeightInPixels() const {
+ switch (preview_height_units_) {
+ case INSTANT_SIZE_PERCENT:
+ return std::min(height(), (height() * preview_height_) / 100);
+
+ case INSTANT_SIZE_PIXELS:
+ return std::min(height(), preview_height_);
+ }
+ NOTREACHED() << "unknown units: " << preview_height_units_;
+ return 0;
+}
+
std::string ContentsContainer::GetClassName() const {
return kViewClassName;
}
« no previous file with comments | « chrome/browser/ui/views/frame/contents_container.h ('k') | chrome/test/base/test_browser_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698