| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/views/toolbar/browser_actions_container.h" | 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 view->SetVisible(x + icon_width <= max_x); | 366 view->SetVisible(x + icon_width <= max_x); |
| 367 if (view->visible()) | 367 if (view->visible()) |
| 368 view->SetBounds(x, 0, icon_width, IconHeight()); | 368 view->SetBounds(x, 0, icon_width, IconHeight()); |
| 369 } | 369 } |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 | 372 |
| 373 bool BrowserActionsContainer::GetDropFormats( | 373 bool BrowserActionsContainer::GetDropFormats( |
| 374 int* formats, | 374 int* formats, |
| 375 std::set<OSExchangeData::CustomFormat>* custom_formats) { | 375 std::set<OSExchangeData::CustomFormat>* custom_formats) { |
| 376 custom_formats->insert(BrowserActionDragData::GetBrowserActionCustomFormat()); | 376 return BrowserActionDragData::GetDropFormats(formats, custom_formats); |
| 377 | |
| 378 return true; | |
| 379 } | 377 } |
| 380 | 378 |
| 381 bool BrowserActionsContainer::AreDropTypesRequired() { | 379 bool BrowserActionsContainer::AreDropTypesRequired() { |
| 382 return true; | 380 return BrowserActionDragData::AreDropTypesRequired(); |
| 383 } | 381 } |
| 384 | 382 |
| 385 bool BrowserActionsContainer::CanDrop(const OSExchangeData& data) { | 383 bool BrowserActionsContainer::CanDrop(const OSExchangeData& data) { |
| 386 BrowserActionDragData drop_data; | 384 return BrowserActionDragData::CanDrop(data, profile_); |
| 387 return drop_data.Read(data) ? drop_data.IsFromProfile(profile_) : false; | |
| 388 } | 385 } |
| 389 | 386 |
| 390 void BrowserActionsContainer::OnDragEntered( | 387 void BrowserActionsContainer::OnDragEntered( |
| 391 const ui::DropTargetEvent& event) { | 388 const ui::DropTargetEvent& event) { |
| 392 } | 389 } |
| 393 | 390 |
| 394 int BrowserActionsContainer::OnDragUpdated( | 391 int BrowserActionsContainer::OnDragUpdated( |
| 395 const ui::DropTargetEvent& event) { | 392 const ui::DropTargetEvent& event) { |
| 396 // First check if we are above the chevron (overflow) menu. | 393 // First check if we are above the chevron (overflow) menu. |
| 397 if (GetEventHandlerForPoint(event.location()) == chevron_) { | 394 if (GetEventHandlerForPoint(event.location()) == chevron_) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 if (i > data.index()) | 489 if (i > data.index()) |
| 493 --i; | 490 --i; |
| 494 | 491 |
| 495 if (profile_->IsOffTheRecord()) | 492 if (profile_->IsOffTheRecord()) |
| 496 i = model_->IncognitoIndexToOriginal(i); | 493 i = model_->IncognitoIndexToOriginal(i); |
| 497 | 494 |
| 498 model_->MoveBrowserAction( | 495 model_->MoveBrowserAction( |
| 499 browser_action_views_[data.index()]->button()->extension(), i); | 496 browser_action_views_[data.index()]->button()->extension(), i); |
| 500 | 497 |
| 501 OnDragExited(); // Perform clean up after dragging. | 498 OnDragExited(); // Perform clean up after dragging. |
| 499 FOR_EACH_OBSERVER(BrowserActionsContainerObserver, |
| 500 observers_, |
| 501 OnBrowserActionDropped()); |
| 502 return ui::DragDropTypes::DRAG_MOVE; | 502 return ui::DragDropTypes::DRAG_MOVE; |
| 503 } | 503 } |
| 504 | 504 |
| 505 void BrowserActionsContainer::GetAccessibleState( | 505 void BrowserActionsContainer::GetAccessibleState( |
| 506 ui::AXViewState* state) { | 506 ui::AXViewState* state) { |
| 507 state->role = ui::AX_ROLE_GROUP; | 507 state->role = ui::AX_ROLE_GROUP; |
| 508 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS); | 508 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_EXTENSIONS); |
| 509 } | 509 } |
| 510 | 510 |
| 511 void BrowserActionsContainer::OnMenuButtonClicked(views::View* source, | 511 void BrowserActionsContainer::OnMenuButtonClicked(views::View* source, |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 views::BubbleBorder::TOP_RIGHT, | 1055 views::BubbleBorder::TOP_RIGHT, |
| 1056 show_action); | 1056 show_action); |
| 1057 popup_->GetWidget()->AddObserver(this); | 1057 popup_->GetWidget()->AddObserver(this); |
| 1058 popup_button_ = button; | 1058 popup_button_ = button; |
| 1059 | 1059 |
| 1060 // Only set button as pushed if it was triggered by a user click. | 1060 // Only set button as pushed if it was triggered by a user click. |
| 1061 if (should_grant) | 1061 if (should_grant) |
| 1062 popup_button_->SetButtonPushed(); | 1062 popup_button_->SetButtonPushed(); |
| 1063 return true; | 1063 return true; |
| 1064 } | 1064 } |
| OLD | NEW |