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

Side by Side Diff: chrome/browser/views/app_launcher.cc

Issue 1171002: Some layout related fixes for the app launchers.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/views/app_launcher.h ('k') | chrome/browser/views/tabs/tab_strip.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/app_launcher.h" 5 #include "chrome/browser/views/app_launcher.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 view_win->ShowWindow(SW_SHOW); 336 view_win->ShowWindow(SW_SHOW);
337 #endif 337 #endif
338 render_view_container_->Attach(app_launcher_->rwhv_->GetNativeView()); 338 render_view_container_->Attach(app_launcher_->rwhv_->GetNativeView());
339 339
340 navigation_bar_ = new NavigationBar(app_launcher_); 340 navigation_bar_ = new NavigationBar(app_launcher_);
341 AddChildView(navigation_bar_); 341 AddChildView(navigation_bar_);
342 } 342 }
343 343
344 gfx::Size InfoBubbleContentsView::GetPreferredSize() { 344 gfx::Size InfoBubbleContentsView::GetPreferredSize() {
345 gfx::Rect bounds = app_launcher_->browser()->window()->GetRestoredBounds(); 345 gfx::Rect bounds = app_launcher_->browser()->window()->GetRestoredBounds();
346 return gfx::Size(bounds.width() * 2 / 3, bounds.width() * 4 / 5); 346 return gfx::Size(bounds.width() * 2 / 3, bounds.height() * 4 / 5);
347 } 347 }
348 348
349 void InfoBubbleContentsView::Layout() { 349 void InfoBubbleContentsView::Layout() {
350 if (bounds().IsEmpty() || GetChildViewCount() == 0) 350 if (bounds().IsEmpty() || GetChildViewCount() == 0)
351 return; 351 return;
352 352
353 gfx::Rect bounds = GetLocalBounds(false);
353 int navigation_bar_height = 354 int navigation_bar_height =
354 kNavigationBarHeight + kNavigationEntryYMargin * 2; 355 kNavigationBarHeight + kNavigationEntryYMargin * 2;
355 const views::Border* border = navigation_bar_->border(); 356 const views::Border* border = navigation_bar_->border();
356 if (border) { 357 if (border) {
357 gfx::Insets insets; 358 gfx::Insets insets;
358 border->GetInsets(&insets); 359 border->GetInsets(&insets);
359 navigation_bar_height += insets.height(); 360 navigation_bar_height += insets.height();
360 } 361 }
361 navigation_bar_->SetBounds(x(), y(), width(), navigation_bar_height); 362 navigation_bar_->SetBounds(bounds.x(), bounds.y(),
363 bounds.width(), navigation_bar_height);
362 int render_y = navigation_bar_->bounds().bottom(); 364 int render_y = navigation_bar_->bounds().bottom();
363 gfx::Size rwhv_size = 365 gfx::Size rwhv_size =
364 gfx::Size(width(), std::max(0, height() - render_y + y())); 366 gfx::Size(width(), std::max(0, bounds.height() - render_y + bounds.y()));
365 render_view_container_->SetBounds(x(), render_y, 367 render_view_container_->SetBounds(bounds.x(), render_y,
366 rwhv_size.width(), rwhv_size.height()); 368 rwhv_size.width(), rwhv_size.height());
367 app_launcher_->rwhv_->SetSize(rwhv_size); 369 app_launcher_->rwhv_->SetSize(rwhv_size);
368 } 370 }
369 371
370 //////////////////////////////////////////////////////////////////////////////// 372 ////////////////////////////////////////////////////////////////////////////////
371 // AppLauncher 373 // AppLauncher
372 374
373 AppLauncher::AppLauncher(Browser* browser) 375 AppLauncher::AppLauncher(Browser* browser)
374 : browser_(browser), 376 : browser_(browser),
375 info_bubble_(NULL), 377 info_bubble_(NULL),
(...skipping 25 matching lines...) Expand all
401 contents_rvh_->CreateRenderView(profile->GetRequestContext()); 403 contents_rvh_->CreateRenderView(profile->GetRequestContext());
402 DCHECK(contents_rvh_->IsRenderViewLive()); 404 DCHECK(contents_rvh_->IsRenderViewLive());
403 contents_rvh_->NavigateToURL(GetMenuURL()); 405 contents_rvh_->NavigateToURL(GetMenuURL());
404 } 406 }
405 407
406 AppLauncher::~AppLauncher() { 408 AppLauncher::~AppLauncher() {
407 contents_rvh_->Shutdown(); 409 contents_rvh_->Shutdown();
408 } 410 }
409 411
410 // static 412 // static
411 AppLauncher* AppLauncher::Show(Browser* browser) { 413 AppLauncher* AppLauncher::Show(Browser* browser, const gfx::Rect& bounds) {
412 AppLauncher* app_launcher = new AppLauncher(browser); 414 AppLauncher* app_launcher = new AppLauncher(browser);
413
414 BrowserView* browser_view = static_cast<BrowserView*>(browser->window()); 415 BrowserView* browser_view = static_cast<BrowserView*>(browser->window());
415 TabStrip* tabstrip = browser_view->tabstrip()->AsTabStrip();
416 if (!tabstrip) {
417 delete app_launcher;
418 return NULL;
419 }
420 gfx::Rect bounds = tabstrip->GetNewTabButtonBounds();
421 gfx::Point origin = bounds.origin();
422 views::RootView::ConvertPointToScreen(tabstrip, &origin);
423 bounds.set_origin(origin);
424 app_launcher->info_bubble_ = 416 app_launcher->info_bubble_ =
425 InfoBubble::Show(browser_view->frame()->GetWindow(), bounds, 417 InfoBubble::Show(browser_view->frame()->GetWindow(), bounds,
426 app_launcher->info_bubble_content_, app_launcher); 418 app_launcher->info_bubble_content_, app_launcher);
427 app_launcher->info_bubble_content_->BubbleShown(); 419 app_launcher->info_bubble_content_->BubbleShown();
428 return app_launcher; 420 return app_launcher;
429 } 421 }
430 422
423 // static
424 AppLauncher* AppLauncher::ShowForNewTab(Browser* browser) {
425 BrowserView* browser_view = static_cast<BrowserView*>(browser->window());
426 TabStrip* tabstrip = browser_view->tabstrip()->AsTabStrip();
427 if (!tabstrip)
428 return NULL;
429 gfx::Rect bounds = tabstrip->GetNewTabButtonBounds();
430 gfx::Point origin = bounds.origin();
431 views::RootView::ConvertPointToScreen(tabstrip, &origin);
432 bounds.set_origin(origin);
433 return Show(browser, bounds);
434 }
435
431 void AppLauncher::Hide() { 436 void AppLauncher::Hide() {
432 info_bubble_->Close(); 437 info_bubble_->Close();
433 } 438 }
434 439
435 void AppLauncher::InfoBubbleClosing(InfoBubble* info_bubble, 440 void AppLauncher::InfoBubbleClosing(InfoBubble* info_bubble,
436 bool closed_by_escape) { 441 bool closed_by_escape) {
437 // The stack may have pending_contents_ on it. Delay deleting the 442 // The stack may have pending_contents_ on it. Delay deleting the
438 // pending_contents_ as TabContents doesn't deal well with being deleted 443 // pending_contents_ as TabContents doesn't deal well with being deleted
439 // while on the stack. 444 // while on the stack.
440 MessageLoop::current()->PostTask(FROM_HERE, 445 MessageLoop::current()->PostTask(FROM_HERE,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 } 516 }
512 case chromeos::StatusAreaView::OPEN_TABS_ON_RIGHT: { 517 case chromeos::StatusAreaView::OPEN_TABS_ON_RIGHT: {
513 browser_->AddTabWithURL(url, GURL(), transition, true, -1, true, NULL); 518 browser_->AddTabWithURL(url, GURL(), transition, true, -1, true, NULL);
514 break; 519 break;
515 } 520 }
516 } 521 }
517 #else 522 #else
518 browser_->AddTabWithURL(url, GURL(), transition, true, -1, true, NULL); 523 browser_->AddTabWithURL(url, GURL(), transition, true, -1, true, NULL);
519 #endif 524 #endif
520 } 525 }
OLDNEW
« no previous file with comments | « chrome/browser/views/app_launcher.h ('k') | chrome/browser/views/tabs/tab_strip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698