OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/panels/panel.h" | 5 #include "chrome/browser/ui/panels/panel.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 284 |
285 native_panel_->ShowPanelInactive(); | 285 native_panel_->ShowPanelInactive(); |
286 } | 286 } |
287 | 287 |
288 // Close() may be called multiple times if the panel window is not ready to | 288 // Close() may be called multiple times if the panel window is not ready to |
289 // close on the first attempt. | 289 // close on the first attempt. |
290 void Panel::Close() { | 290 void Panel::Close() { |
291 native_panel_->ClosePanel(); | 291 native_panel_->ClosePanel(); |
292 } | 292 } |
293 | 293 |
294 void Panel::Activate() { | 294 void Panel::Activate(bool user_gesture) { |
295 if (!collection_) | 295 if (!collection_) |
296 return; | 296 return; |
297 | 297 |
298 collection_->ActivatePanel(this); | 298 collection_->ActivatePanel(this); |
299 native_panel_->ActivatePanel(); | 299 native_panel_->ActivatePanel(); |
300 } | 300 } |
301 | 301 |
302 void Panel::Deactivate() { | 302 void Panel::Deactivate() { |
303 native_panel_->DeactivatePanel(); | 303 native_panel_->DeactivatePanel(); |
304 } | 304 } |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 // activate a minimized panel on mouse-down regardless of our attempts to | 467 // activate a minimized panel on mouse-down regardless of our attempts to |
468 // prevent system activation. Attention state is not cleared in that case. | 468 // prevent system activation. Attention state is not cleared in that case. |
469 // See Panel::OnActiveStateChanged(). | 469 // See Panel::OnActiveStateChanged(). |
470 // Therefore, we ensure activation and clearing of attention state if the | 470 // Therefore, we ensure activation and clearing of attention state if the |
471 // panel has been expanded. If the panel is in a stack, the titlebar click | 471 // panel has been expanded. If the panel is in a stack, the titlebar click |
472 // might minimize the panel and we do not want to activate it to make it | 472 // might minimize the panel and we do not want to activate it to make it |
473 // expand again. | 473 // expand again. |
474 // These are no-ops if no changes are needed. | 474 // These are no-ops if no changes are needed. |
475 if (IsMinimized()) | 475 if (IsMinimized()) |
476 return; | 476 return; |
477 Activate(); | 477 Activate(true /* user_gesture */); |
478 FlashFrame(false); | 478 FlashFrame(false); |
479 } | 479 } |
480 | 480 |
481 void Panel::OnMinimizeButtonClicked(panel::ClickModifier modifier) { | 481 void Panel::OnMinimizeButtonClicked(panel::ClickModifier modifier) { |
482 if (collection_) | 482 if (collection_) |
483 collection_->OnMinimizeButtonClicked(this, modifier); | 483 collection_->OnMinimizeButtonClicked(this, modifier); |
484 } | 484 } |
485 | 485 |
486 void Panel::OnRestoreButtonClicked(panel::ClickModifier modifier) { | 486 void Panel::OnRestoreButtonClicked(panel::ClickModifier modifier) { |
487 // Clicking the restore button has the same behavior as clicking the titlebar. | 487 // Clicking the restore button has the same behavior as clicking the titlebar. |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 // static | 890 // static |
891 void Panel::FormatTitleForDisplay(base::string16* title) { | 891 void Panel::FormatTitleForDisplay(base::string16* title) { |
892 size_t current_index = 0; | 892 size_t current_index = 0; |
893 size_t match_index; | 893 size_t match_index; |
894 while ((match_index = title->find(L'\n', current_index)) != | 894 while ((match_index = title->find(L'\n', current_index)) != |
895 base::string16::npos) { | 895 base::string16::npos) { |
896 title->replace(match_index, 1, base::string16()); | 896 title->replace(match_index, 1, base::string16()); |
897 current_index = match_index; | 897 current_index = match_index; |
898 } | 898 } |
899 } | 899 } |
OLD | NEW |