| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extensions/extension_shelf.h" | 5 #include "chrome/browser/views/extensions/extension_shelf.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 void DetachFromShelf(bool browser); | 146 void DetachFromShelf(bool browser); |
| 147 void AttachToShelf(bool browser); | 147 void AttachToShelf(bool browser); |
| 148 | 148 |
| 149 // Show / Hide the shelf handle. | 149 // Show / Hide the shelf handle. |
| 150 void ShowShelfHandle(); | 150 void ShowShelfHandle(); |
| 151 void DoShowShelfHandle(); | 151 void DoShowShelfHandle(); |
| 152 void HideShelfHandle(int delay_ms); | 152 void HideShelfHandle(int delay_ms); |
| 153 void DoHideShelfHandle(); | 153 void DoHideShelfHandle(); |
| 154 void StopHandleTimer(); | 154 void StopHandleTimer(); |
| 155 | 155 |
| 156 // Expand / Collapse |
| 157 void Expand(int height, const GURL& url); |
| 158 void Collapse(const GURL& url); |
| 159 |
| 156 // BrowserBubble::Delegate | 160 // BrowserBubble::Delegate |
| 157 virtual void BubbleBrowserWindowMoved(BrowserBubble* bubble); | 161 virtual void BubbleBrowserWindowMoved(BrowserBubble* bubble); |
| 158 virtual void BubbleBrowserWindowClosing(BrowserBubble* bubble); | 162 virtual void BubbleBrowserWindowClosing(BrowserBubble* bubble); |
| 159 | 163 |
| 160 private: | 164 private: |
| 161 // The actual renderer that this toolstrip contains. | 165 // The actual renderer that this toolstrip contains. |
| 162 ExtensionHost* host_; | 166 ExtensionHost* host_; |
| 163 | 167 |
| 164 // Manifest definition of this toolstrip. | 168 // Manifest definition of this toolstrip. |
| 165 Extension::ToolstripInfo info_; | 169 Extension::ToolstripInfo info_; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 251 |
| 248 if (dragging_) { | 252 if (dragging_) { |
| 249 // when we're dragging, draw the bottom border. | 253 // when we're dragging, draw the bottom border. |
| 250 canvas->FillRectInt(kBorderColor, 0, height() - 1, width(), 1); | 254 canvas->FillRectInt(kBorderColor, 0, height() - 1, width(), 1); |
| 251 } | 255 } |
| 252 } | 256 } |
| 253 | 257 |
| 254 gfx::Size ExtensionShelf::Toolstrip::GetPreferredSize() { | 258 gfx::Size ExtensionShelf::Toolstrip::GetPreferredSize() { |
| 255 gfx::Size sz = title_->GetPreferredSize(); | 259 gfx::Size sz = title_->GetPreferredSize(); |
| 256 sz.set_width(std::max(view()->width(), sz.width())); | 260 sz.set_width(std::max(view()->width(), sz.width())); |
| 257 if (!expanded_) { | 261 if (!expanded_) |
| 258 sz.Enlarge(2 + kHandlePadding * 2, kHandlePadding * 2); | 262 sz.Enlarge(2 + kHandlePadding * 2, kHandlePadding * 2); |
| 259 } | |
| 260 if (dragging_ || expanded_) { | 263 if (dragging_ || expanded_) { |
| 261 gfx::Size extension_size = view()->GetPreferredSize(); | 264 gfx::Size extension_size = view()->GetPreferredSize(); |
| 262 sz.Enlarge(0, extension_size.height() + 2); | 265 sz.Enlarge(0, extension_size.height() + 2); |
| 263 } | 266 } |
| 264 return sz; | 267 return sz; |
| 265 } | 268 } |
| 266 | 269 |
| 267 void ExtensionShelf::Toolstrip::Layout() { | 270 void ExtensionShelf::Toolstrip::Layout() { |
| 268 if (dragging_ || expanded_) { | 271 if (dragging_ || expanded_) { |
| 269 int y = title_->bounds().bottom() + kHandlePadding + 1; | 272 int y = title_->bounds().bottom() + kHandlePadding + 1; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 // Drop the toolstrip roughly where it is now. | 329 // Drop the toolstrip roughly where it is now. |
| 327 views::View::OnMouseReleased(event, canceled); | 330 views::View::OnMouseReleased(event, canceled); |
| 328 dragging_ = false; | 331 dragging_ = false; |
| 329 // |this| and |shelf_| are in different view hierarchies, so we need to | 332 // |this| and |shelf_| are in different view hierarchies, so we need to |
| 330 // convert to screen coordinates and back again to map locations. | 333 // convert to screen coordinates and back again to map locations. |
| 331 gfx::Point loc = event.location(); | 334 gfx::Point loc = event.location(); |
| 332 View::ConvertPointToScreen(this, &loc); | 335 View::ConvertPointToScreen(this, &loc); |
| 333 View::ConvertPointToView(NULL, shelf_, &loc); | 336 View::ConvertPointToView(NULL, shelf_, &loc); |
| 334 shelf_->DropExtension(this, loc, canceled); | 337 shelf_->DropExtension(this, loc, canceled); |
| 335 AttachToShelf(true); | 338 AttachToShelf(true); |
| 336 } else if (!canceled && | 339 } else if (!canceled) { |
| 337 info_.mole.is_valid() && info_.toolstrip.is_valid()) { | |
| 338 // Toggle mole to either expanded or collapsed. | 340 // Toggle mole to either expanded or collapsed. |
| 339 expanded_ = !expanded_; | 341 // TODO(erikkay) If there's no valid URL in the manifest, should we |
| 340 view()->set_is_toolstrip(!expanded_); | 342 // post an event to the toolstrip in this case? |
| 341 if (expanded_) { | 343 if (expanded_) { |
| 342 host_->NavigateToURL(info_.mole); | 344 if (info_.toolstrip.is_valid()) |
| 343 StopHandleTimer(); | 345 shelf_->CollapseToolstrip(host_, info_.toolstrip); |
| 344 DetachFromShelf(false); | |
| 345 | |
| 346 gfx::Size extension_size = view()->GetPreferredSize(); | |
| 347 extension_size.set_height(info_.mole_height); | |
| 348 view()->SetPreferredSize(extension_size); | |
| 349 LayoutHandle(); | |
| 350 } else { | 346 } else { |
| 351 gfx::Size extension_size = view()->GetPreferredSize(); | 347 if (info_.mole.is_valid()) |
| 352 extension_size.set_height(kToolstripHeight); | 348 shelf_->ExpandToolstrip(host_, info_.mole, info_.mole_height); |
| 353 view()->SetPreferredSize(extension_size); | |
| 354 | |
| 355 host_->NavigateToURL(info_.toolstrip); | |
| 356 AttachToShelf(false); | |
| 357 } | 349 } |
| 358 | |
| 359 // This is to prevent flickering as the page loads and lays out. | |
| 360 // Once the navigation is finished, ExtensionView will wind up setting | |
| 361 // visibility to true. | |
| 362 view()->SetVisible(false); | |
| 363 } | 350 } |
| 364 } | 351 } |
| 365 | 352 |
| 366 BrowserBubble* ExtensionShelf::Toolstrip::GetHandle() { | 353 BrowserBubble* ExtensionShelf::Toolstrip::GetHandle() { |
| 367 if (!handle_.get()) { | 354 if (!handle_.get()) { |
| 368 handle_.reset(new BrowserBubble(this, shelf_->GetWidget(), | 355 handle_.reset(new BrowserBubble(this, shelf_->GetWidget(), |
| 369 gfx::Point(0, 0))); | 356 gfx::Point(0, 0))); |
| 370 handle_->set_delegate(this); | 357 handle_->set_delegate(this); |
| 371 LayoutHandle(); | 358 LayoutHandle(); |
| 372 } | 359 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 BrowserBubble* bubble) { | 394 BrowserBubble* bubble) { |
| 408 HideShelfHandle(0); | 395 HideShelfHandle(0); |
| 409 } | 396 } |
| 410 | 397 |
| 411 void ExtensionShelf::Toolstrip::BubbleBrowserWindowClosing( | 398 void ExtensionShelf::Toolstrip::BubbleBrowserWindowClosing( |
| 412 BrowserBubble* bubble) { | 399 BrowserBubble* bubble) { |
| 413 DoHideShelfHandle(); | 400 DoHideShelfHandle(); |
| 414 } | 401 } |
| 415 | 402 |
| 416 void ExtensionShelf::Toolstrip::DetachFromShelf(bool browserDetach) { | 403 void ExtensionShelf::Toolstrip::DetachFromShelf(bool browserDetach) { |
| 404 DCHECK(handle_.get()); |
| 417 DCHECK(!placeholder_view_); | 405 DCHECK(!placeholder_view_); |
| 418 if (browserDetach && handle_->attached()) | 406 if (browserDetach && handle_->attached()) |
| 419 handle_->DetachFromBrowser(); | 407 handle_->DetachFromBrowser(); |
| 420 | 408 |
| 421 // Construct a placeholder view to replace the view. | 409 // Construct a placeholder view to replace the view. |
| 422 placeholder_view_ = new PlaceholderView(); | 410 placeholder_view_ = new PlaceholderView(); |
| 423 placeholder_view_->SetBounds(view()->bounds()); | 411 placeholder_view_->SetBounds(view()->bounds()); |
| 424 shelf_->AddChildView(placeholder_view_); | 412 shelf_->AddChildView(placeholder_view_); |
| 425 | 413 |
| 426 AddChildView(view()); | 414 AddChildView(view()); |
| 427 SizeToPreferredSize(); | 415 SizeToPreferredSize(); |
| 428 handle_->ResizeToView(); | 416 handle_->ResizeToView(); |
| 429 Layout(); | 417 Layout(); |
| 430 } | 418 } |
| 431 | 419 |
| 432 void ExtensionShelf::Toolstrip::AttachToShelf(bool browserAttach) { | 420 void ExtensionShelf::Toolstrip::AttachToShelf(bool browserAttach) { |
| 421 DCHECK(handle_.get()); |
| 422 DCHECK(placeholder_view_); |
| 433 if (browserAttach && !handle_->attached()) | 423 if (browserAttach && !handle_->attached()) |
| 434 handle_->AttachToBrowser(); | 424 handle_->AttachToBrowser(); |
| 435 | 425 |
| 436 // Move the view back into the shelf and remove the old placeholder. | 426 // Move the view back into the shelf and remove the old placeholder. |
| 437 shelf_->AddChildView(view()); | 427 shelf_->AddChildView(view()); |
| 438 | 428 |
| 439 // The size of the view may have changed, so just set the position. | 429 // The size of the view may have changed, so just set the position. |
| 440 view()->SetX(placeholder_view_->x()); | 430 view()->SetX(placeholder_view_->x()); |
| 441 view()->SetY(placeholder_view_->y()); | 431 view()->SetY(placeholder_view_->y()); |
| 442 | 432 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 466 handle_->DetachFromBrowser(); | 456 handle_->DetachFromBrowser(); |
| 467 handle_.reset(NULL); | 457 handle_.reset(NULL); |
| 468 shelf_->Layout(); | 458 shelf_->Layout(); |
| 469 } | 459 } |
| 470 | 460 |
| 471 void ExtensionShelf::Toolstrip::StopHandleTimer() { | 461 void ExtensionShelf::Toolstrip::StopHandleTimer() { |
| 472 if (!timer_factory_.empty()) | 462 if (!timer_factory_.empty()) |
| 473 timer_factory_.RevokeAll(); | 463 timer_factory_.RevokeAll(); |
| 474 } | 464 } |
| 475 | 465 |
| 466 void ExtensionShelf::Toolstrip::Expand(int height, const GURL& url) { |
| 467 DCHECK(!expanded_); |
| 468 |
| 469 DoShowShelfHandle(); |
| 470 |
| 471 expanded_ = true; |
| 472 view()->set_is_toolstrip(!expanded_); |
| 473 |
| 474 if (!url.is_empty()) |
| 475 host_->NavigateToURL(url); |
| 476 StopHandleTimer(); |
| 477 DetachFromShelf(false); |
| 478 |
| 479 gfx::Size extension_size = view()->GetPreferredSize(); |
| 480 extension_size.set_height(height); |
| 481 view()->SetPreferredSize(extension_size); |
| 482 LayoutHandle(); |
| 483 |
| 484 // This is to prevent flickering as the page loads and lays out. |
| 485 // Once the navigation is finished, ExtensionView will wind up setting |
| 486 // visibility to true. |
| 487 if (!url.is_empty()) |
| 488 view()->SetVisible(false); |
| 489 } |
| 490 |
| 491 void ExtensionShelf::Toolstrip::Collapse(const GURL& url) { |
| 492 DCHECK(expanded_); |
| 493 expanded_ = false; |
| 494 view()->set_is_toolstrip(!expanded_); |
| 495 |
| 496 gfx::Size extension_size = view()->GetPreferredSize(); |
| 497 extension_size.set_height(kToolstripHeight); |
| 498 view()->SetPreferredSize(extension_size); |
| 499 |
| 500 if (!url.is_empty()) |
| 501 host_->NavigateToURL(url); |
| 502 AttachToShelf(false); |
| 503 |
| 504 // This is to prevent flickering as the page loads and lays out. |
| 505 // Once the navigation is finished, ExtensionView will wind up setting |
| 506 // visibility to true. |
| 507 if (!url.is_empty()) |
| 508 view()->SetVisible(false); |
| 509 |
| 510 DoHideShelfHandle(); |
| 511 } |
| 512 |
| 476 void ExtensionShelf::Toolstrip::ShowShelfHandle() { | 513 void ExtensionShelf::Toolstrip::ShowShelfHandle() { |
| 477 StopHandleTimer(); | 514 StopHandleTimer(); |
| 478 if (handle_visible()) | 515 if (handle_visible()) |
| 479 return; | 516 return; |
| 480 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 517 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 481 timer_factory_.NewRunnableMethod( | 518 timer_factory_.NewRunnableMethod( |
| 482 &ExtensionShelf::Toolstrip::DoShowShelfHandle), | 519 &ExtensionShelf::Toolstrip::DoShowShelfHandle), |
| 483 1000); | 520 1000); |
| 484 } | 521 } |
| 485 | 522 |
| 486 void ExtensionShelf::Toolstrip::HideShelfHandle(int delay_ms) { | 523 void ExtensionShelf::Toolstrip::HideShelfHandle(int delay_ms) { |
| 487 StopHandleTimer(); | 524 StopHandleTimer(); |
| 488 if (!handle_visible() || dragging_ || expanded_) | 525 if (!handle_visible() || dragging_ || expanded_) |
| 489 return; | 526 return; |
| 490 if (delay_ms) { | 527 if (delay_ms) { |
| 491 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 528 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 492 timer_factory_.NewRunnableMethod( | 529 timer_factory_.NewRunnableMethod( |
| 493 &ExtensionShelf::Toolstrip::DoHideShelfHandle), | 530 &ExtensionShelf::Toolstrip::DoHideShelfHandle), |
| 494 delay_ms); | 531 delay_ms); |
| 495 } else { | 532 } else { |
| 496 DoHideShelfHandle(); | 533 DoHideShelfHandle(); |
| 497 } | 534 } |
| 498 } | 535 } |
| 499 | 536 |
| 500 //////////////////////////////////////////////////////////////////////////////// | 537 //////////////////////////////////////////////////////////////////////////////// |
| 501 | 538 |
| 502 ExtensionShelf::ExtensionShelf(Browser* browser) | 539 ExtensionShelf::ExtensionShelf(Browser* browser) |
| 503 : model_(new ExtensionShelfModel(browser)) { | 540 : model_(browser->extension_shelf_model()) { |
| 504 model_->AddObserver(this); | 541 model_->AddObserver(this); |
| 505 LoadFromModel(); | 542 LoadFromModel(); |
| 506 EnableCanvasFlippingForRTLUI(true); | 543 EnableCanvasFlippingForRTLUI(true); |
| 507 } | 544 } |
| 508 | 545 |
| 509 ExtensionShelf::~ExtensionShelf() { | 546 ExtensionShelf::~ExtensionShelf() { |
| 510 int count = model_->count(); | 547 int count = model_->count(); |
| 511 for (int i = 0; i < count; ++i) { | 548 for (int i = 0; i < count; ++i) { |
| 512 delete ToolstripAtIndex(i); | 549 delete ToolstripAtIndex(i); |
| 513 model_->SetToolstripDataAt(i, NULL); | 550 model_->SetToolstripDataAt(i, NULL); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 return false; | 649 return false; |
| 613 } | 650 } |
| 614 | 651 |
| 615 void ExtensionShelf::SetAccessibleName(const std::wstring& name) { | 652 void ExtensionShelf::SetAccessibleName(const std::wstring& name) { |
| 616 accessible_name_.assign(name); | 653 accessible_name_.assign(name); |
| 617 } | 654 } |
| 618 | 655 |
| 619 void ExtensionShelf::ToolstripInsertedAt(ExtensionHost* host, | 656 void ExtensionShelf::ToolstripInsertedAt(ExtensionHost* host, |
| 620 int index) { | 657 int index) { |
| 621 model_->SetToolstripDataAt(index, | 658 model_->SetToolstripDataAt(index, |
| 622 new Toolstrip(this, host, model_->ToolstripInfoAt(index))); | 659 new Toolstrip(this, host, model_->ToolstripAt(index).info)); |
| 623 | 660 |
| 624 bool had_views = GetChildViewCount() > 0; | 661 bool had_views = GetChildViewCount() > 0; |
| 625 ExtensionView* view = host->view(); | 662 ExtensionView* view = host->view(); |
| 626 if (!background_.empty()) | 663 if (!background_.empty()) |
| 627 view->SetBackground(background_); | 664 view->SetBackground(background_); |
| 628 AddChildView(view); | 665 AddChildView(view); |
| 629 view->SetContainer(this); | 666 view->SetContainer(this); |
| 630 if (!had_views) | 667 if (!had_views) |
| 631 PreferredSizeChanged(); | 668 PreferredSizeChanged(); |
| 632 Layout(); | 669 Layout(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 646 } | 683 } |
| 647 | 684 |
| 648 void ExtensionShelf::ToolstripDraggingFrom(ExtensionHost* host, int index) { | 685 void ExtensionShelf::ToolstripDraggingFrom(ExtensionHost* host, int index) { |
| 649 } | 686 } |
| 650 | 687 |
| 651 void ExtensionShelf::ToolstripMoved(ExtensionHost* host, int from_index, | 688 void ExtensionShelf::ToolstripMoved(ExtensionHost* host, int from_index, |
| 652 int to_index) { | 689 int to_index) { |
| 653 Layout(); | 690 Layout(); |
| 654 } | 691 } |
| 655 | 692 |
| 656 void ExtensionShelf::ToolstripChangedAt(ExtensionHost* toolstrip, int index) { | 693 void ExtensionShelf::ToolstripChanged(ExtensionShelfModel::iterator toolstrip) { |
| 694 Toolstrip* t = static_cast<Toolstrip*>(toolstrip->data); |
| 695 if (toolstrip->height > 0) { |
| 696 if (!t->expanded()) { |
| 697 t->Expand(toolstrip->height, toolstrip->url); |
| 698 } |
| 699 } else if (t->expanded()) { |
| 700 t->Collapse(toolstrip->url); |
| 701 } |
| 657 } | 702 } |
| 658 | 703 |
| 659 void ExtensionShelf::ExtensionShelfEmpty() { | 704 void ExtensionShelf::ExtensionShelfEmpty() { |
| 660 PreferredSizeChanged(); | 705 PreferredSizeChanged(); |
| 661 } | 706 } |
| 662 | 707 |
| 663 void ExtensionShelf::ShelfModelReloaded() { | 708 void ExtensionShelf::ShelfModelReloaded() { |
| 664 // None of the child views are parent owned, so nothing is being leaked here. | 709 // None of the child views are parent owned, so nothing is being leaked here. |
| 665 RemoveAllChildViews(false); | 710 RemoveAllChildViews(false); |
| 666 LoadFromModel(); | 711 LoadFromModel(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 682 bool cancel) { | 727 bool cancel) { |
| 683 Toolstrip* dest_toolstrip = ToolstripAtX(pt.x()); | 728 Toolstrip* dest_toolstrip = ToolstripAtX(pt.x()); |
| 684 if (!dest_toolstrip) { | 729 if (!dest_toolstrip) { |
| 685 if (pt.x() > 0) | 730 if (pt.x() > 0) |
| 686 dest_toolstrip = ToolstripAtIndex(model_->count() - 1); | 731 dest_toolstrip = ToolstripAtIndex(model_->count() - 1); |
| 687 else | 732 else |
| 688 dest_toolstrip = ToolstripAtIndex(0); | 733 dest_toolstrip = ToolstripAtIndex(0); |
| 689 } | 734 } |
| 690 if (toolstrip == dest_toolstrip) | 735 if (toolstrip == dest_toolstrip) |
| 691 return; | 736 return; |
| 692 int from = model_->IndexOfToolstrip(toolstrip->host()); | 737 int from = model_->IndexOfHost(toolstrip->host()); |
| 693 int to = model_->IndexOfToolstrip(dest_toolstrip->host()); | 738 int to = model_->IndexOfHost(dest_toolstrip->host()); |
| 694 DCHECK(from != to); | 739 DCHECK(from != to); |
| 695 model_->MoveToolstripAt(from, to); | 740 model_->MoveToolstripAt(from, to); |
| 696 } | 741 } |
| 697 | 742 |
| 743 void ExtensionShelf::ExpandToolstrip(ExtensionHost* host, const GURL& url, int h
eight) { |
| 744 ExtensionShelfModel::iterator toolstrip = model_->ToolstripForHost(host); |
| 745 model_->ExpandToolstrip(toolstrip, url, height); |
| 746 } |
| 747 |
| 748 void ExtensionShelf::CollapseToolstrip(ExtensionHost* host, const GURL& url) { |
| 749 ExtensionShelfModel::iterator toolstrip = model_->ToolstripForHost(host); |
| 750 model_->CollapseToolstrip(toolstrip, url); |
| 751 } |
| 752 |
| 698 void ExtensionShelf::InitBackground(gfx::Canvas* canvas, const SkRect& subset) { | 753 void ExtensionShelf::InitBackground(gfx::Canvas* canvas, const SkRect& subset) { |
| 699 if (!background_.empty()) | 754 if (!background_.empty()) |
| 700 return; | 755 return; |
| 701 | 756 |
| 702 const SkBitmap& background = canvas->getDevice()->accessBitmap(false); | 757 const SkBitmap& background = canvas->getDevice()->accessBitmap(false); |
| 703 | 758 |
| 704 // Extract the correct subset of the toolstrip background into a bitmap. We | 759 // Extract the correct subset of the toolstrip background into a bitmap. We |
| 705 // must use a temporary here because extractSubset() returns a bitmap that | 760 // must use a temporary here because extractSubset() returns a bitmap that |
| 706 // references pixels in the original one and we want to actually make a copy | 761 // references pixels in the original one and we want to actually make a copy |
| 707 // that will have a long lifetime. | 762 // that will have a long lifetime. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 View* view = toolstrip->GetShelfView(); | 797 View* view = toolstrip->GetShelfView(); |
| 743 if (x > (view->x() + view->width() + kToolstripPadding)) | 798 if (x > (view->x() + view->width() + kToolstripPadding)) |
| 744 continue; | 799 continue; |
| 745 return toolstrip; | 800 return toolstrip; |
| 746 } | 801 } |
| 747 | 802 |
| 748 return NULL; | 803 return NULL; |
| 749 } | 804 } |
| 750 | 805 |
| 751 ExtensionShelf::Toolstrip* ExtensionShelf::ToolstripAtIndex(int index) { | 806 ExtensionShelf::Toolstrip* ExtensionShelf::ToolstripAtIndex(int index) { |
| 752 return static_cast<Toolstrip*>(model_->ToolstripDataAt(index)); | 807 return static_cast<Toolstrip*>(model_->ToolstripAt(index).data); |
| 753 } | 808 } |
| 754 | 809 |
| 755 ExtensionShelf::Toolstrip* ExtensionShelf::ToolstripForView( | 810 ExtensionShelf::Toolstrip* ExtensionShelf::ToolstripForView( |
| 756 ExtensionView* view) { | 811 ExtensionView* view) { |
| 757 int count = model_->count(); | 812 int count = model_->count(); |
| 758 for (int i = 0; i < count; ++i) { | 813 for (int i = 0; i < count; ++i) { |
| 759 Toolstrip* toolstrip = ToolstripAtIndex(i); | 814 Toolstrip* toolstrip = ToolstripAtIndex(i); |
| 760 if (view == toolstrip->view()) | 815 if (view == toolstrip->view()) |
| 761 return toolstrip; | 816 return toolstrip; |
| 762 } | 817 } |
| 763 NOTREACHED(); | |
| 764 return NULL; | 818 return NULL; |
| 765 } | 819 } |
| 766 | 820 |
| 767 void ExtensionShelf::LoadFromModel() { | 821 void ExtensionShelf::LoadFromModel() { |
| 768 int count = model_->count(); | 822 int count = model_->count(); |
| 769 for (int i = 0; i < count; ++i) | 823 for (int i = 0; i < count; ++i) |
| 770 ToolstripInsertedAt(model_->ToolstripAt(i), i); | 824 ToolstripInsertedAt(model_->ToolstripAt(i).host, i); |
| 771 } | 825 } |
| OLD | NEW |