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/views/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/ntp_background_util.h" | 23 #include "chrome/browser/ntp_background_util.h" |
24 #include "chrome/browser/prefs/pref_service.h" | 24 #include "chrome/browser/prefs/pref_service.h" |
25 #include "chrome/browser/profiles/avatar_menu_model.h" | 25 #include "chrome/browser/profiles/avatar_menu_model.h" |
26 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/browser/profiles/profile_info_cache.h" | 27 #include "chrome/browser/profiles/profile_info_cache.h" |
28 #include "chrome/browser/profiles/profile_manager.h" | 28 #include "chrome/browser/profiles/profile_manager.h" |
29 #include "chrome/browser/sessions/tab_restore_service.h" | 29 #include "chrome/browser/sessions/tab_restore_service.h" |
30 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 30 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
31 #include "chrome/browser/speech/extension_api/tts_extension_api.h" | 31 #include "chrome/browser/speech/extension_api/tts_extension_api.h" |
32 #include "chrome/browser/themes/theme_service.h" | 32 #include "chrome/browser/themes/theme_service.h" |
| 33 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
33 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" | 34 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
34 #include "chrome/browser/ui/browser.h" | 35 #include "chrome/browser/ui/browser.h" |
35 #include "chrome/browser/ui/browser_command_controller.h" | 36 #include "chrome/browser/ui/browser_command_controller.h" |
36 #include "chrome/browser/ui/browser_commands.h" | 37 #include "chrome/browser/ui/browser_commands.h" |
37 #include "chrome/browser/ui/browser_dialogs.h" | 38 #include "chrome/browser/ui/browser_dialogs.h" |
| 39 #include "chrome/browser/ui/browser_finder.h" |
38 #include "chrome/browser/ui/browser_list.h" | 40 #include "chrome/browser/ui/browser_list.h" |
39 #include "chrome/browser/ui/browser_tabstrip.h" | 41 #include "chrome/browser/ui/browser_tabstrip.h" |
40 #include "chrome/browser/ui/browser_window_state.h" | 42 #include "chrome/browser/ui/browser_window_state.h" |
41 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 43 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
42 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" | 44 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" |
43 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 45 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
44 #include "chrome/browser/ui/search/search.h" | 46 #include "chrome/browser/ui/search/search.h" |
45 #include "chrome/browser/ui/search/search_model.h" | 47 #include "chrome/browser/ui/search/search_model.h" |
46 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 48 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
47 #include "chrome/browser/ui/tabs/tab_menu_model.h" | 49 #include "chrome/browser/ui/tabs/tab_menu_model.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 contents_(NULL), | 325 contents_(NULL), |
324 contents_split_(NULL), | 326 contents_split_(NULL), |
325 devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM), | 327 devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM), |
326 initialized_(false), | 328 initialized_(false), |
327 ignore_layout_(true), | 329 ignore_layout_(true), |
328 #if defined(OS_WIN) && !defined(USE_AURA) | 330 #if defined(OS_WIN) && !defined(USE_AURA) |
329 hung_window_detector_(&hung_plugin_action_), | 331 hung_window_detector_(&hung_plugin_action_), |
330 ticker_(0), | 332 ticker_(0), |
331 #endif | 333 #endif |
332 force_location_bar_focus_(false), | 334 force_location_bar_focus_(false), |
333 ALLOW_THIS_IN_INITIALIZER_LIST(color_change_listener_(this)) { | 335 ALLOW_THIS_IN_INITIALIZER_LIST(color_change_listener_(this)), |
| 336 ALLOW_THIS_IN_INITIALIZER_LIST(activate_modal_dialog_factory_(this)) { |
334 browser_->tab_strip_model()->AddObserver(this); | 337 browser_->tab_strip_model()->AddObserver(this); |
335 } | 338 } |
336 | 339 |
337 BrowserView::~BrowserView() { | 340 BrowserView::~BrowserView() { |
338 #if defined(USE_ASH) | 341 #if defined(USE_ASH) |
339 // Destroy BrowserLauncherItemController early on as it listens to the | 342 // Destroy BrowserLauncherItemController early on as it listens to the |
340 // TabstripModel, which is destroyed by the browser. | 343 // TabstripModel, which is destroyed by the browser. |
341 launcher_item_controller_.reset(); | 344 launcher_item_controller_.reset(); |
342 #endif | 345 #endif |
343 | 346 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 std::map<ui::Accelerator, int>::iterator it = accelerator_table_.begin(); | 510 std::map<ui::Accelerator, int>::iterator it = accelerator_table_.begin(); |
508 for (; it != accelerator_table_.end(); ++it) { | 511 for (; it != accelerator_table_.end(); ++it) { |
509 if (it->second == cmd_id) { | 512 if (it->second == cmd_id) { |
510 *accelerator = it->first; | 513 *accelerator = it->first; |
511 return true; | 514 return true; |
512 } | 515 } |
513 } | 516 } |
514 return false; | 517 return false; |
515 } | 518 } |
516 | 519 |
517 bool BrowserView::ActivateAppModalDialog() const { | |
518 // If another browser is app modal, flash and activate the modal browser. | |
519 if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) { | |
520 Browser* active_browser = BrowserList::GetLastActive(); | |
521 if (active_browser && (browser_ != active_browser)) { | |
522 active_browser->window()->FlashFrame(true); | |
523 active_browser->window()->Activate(); | |
524 } | |
525 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); | |
526 return true; | |
527 } | |
528 return false; | |
529 } | |
530 | |
531 WebContents* BrowserView::GetActiveWebContents() const { | 520 WebContents* BrowserView::GetActiveWebContents() const { |
532 return chrome::GetActiveWebContents(browser_.get()); | 521 return chrome::GetActiveWebContents(browser_.get()); |
533 } | 522 } |
534 | 523 |
535 TabContents* BrowserView::GetActiveTabContents() const { | 524 TabContents* BrowserView::GetActiveTabContents() const { |
536 return chrome::GetActiveTabContents(browser_.get()); | 525 return chrome::GetActiveTabContents(browser_.get()); |
537 } | 526 } |
538 | 527 |
539 gfx::ImageSkia BrowserView::GetOTRAvatarIcon() const { | 528 gfx::ImageSkia BrowserView::GetOTRAvatarIcon() const { |
540 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 529 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 | 1476 |
1488 bool BrowserView::CanResize() const { | 1477 bool BrowserView::CanResize() const { |
1489 return true; | 1478 return true; |
1490 } | 1479 } |
1491 | 1480 |
1492 bool BrowserView::CanMaximize() const { | 1481 bool BrowserView::CanMaximize() const { |
1493 return true; | 1482 return true; |
1494 } | 1483 } |
1495 | 1484 |
1496 bool BrowserView::CanActivate() const { | 1485 bool BrowserView::CanActivate() const { |
1497 return !ActivateAppModalDialog(); | 1486 if (!AppModalDialogQueue::GetInstance()->active_dialog()) |
| 1487 return true; |
| 1488 |
| 1489 // If another browser is app modal, flash and activate the modal browser. This |
| 1490 // has to be done in a post task, otherwise if the user clicked on a window |
| 1491 // that doesn't have the modal dialog the windows keep trying to get the focus |
| 1492 // from each other on Windows. http://crbug.com/141650. |
| 1493 MessageLoop::current()->PostTask( |
| 1494 FROM_HERE, |
| 1495 base::Bind(&BrowserView::ActivateAppModalDialog, |
| 1496 activate_modal_dialog_factory_.GetWeakPtr())); |
| 1497 return false; |
1498 } | 1498 } |
1499 | 1499 |
1500 string16 BrowserView::GetWindowTitle() const { | 1500 string16 BrowserView::GetWindowTitle() const { |
1501 return browser_->GetWindowTitleForCurrentTab(); | 1501 return browser_->GetWindowTitleForCurrentTab(); |
1502 } | 1502 } |
1503 | 1503 |
1504 string16 BrowserView::GetAccessibleWindowTitle() const { | 1504 string16 BrowserView::GetAccessibleWindowTitle() const { |
1505 if (IsOffTheRecord()) { | 1505 if (IsOffTheRecord()) { |
1506 return l10n_util::GetStringFUTF16( | 1506 return l10n_util::GetStringFUTF16( |
1507 IDS_ACCESSIBLE_INCOGNITO_WINDOW_TITLE_FORMAT, | 1507 IDS_ACCESSIBLE_INCOGNITO_WINDOW_TITLE_FORMAT, |
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2584 if (contents && contents->GetContentNativeView() && | 2584 if (contents && contents->GetContentNativeView() && |
2585 contents->GetContentNativeView()->HasFocus()) { | 2585 contents->GetContentNativeView()->HasFocus()) { |
2586 (contents->GetRenderViewHost()->*method)(); | 2586 (contents->GetRenderViewHost()->*method)(); |
2587 return true; | 2587 return true; |
2588 } | 2588 } |
2589 #elif defined(OS_WIN) | 2589 #elif defined(OS_WIN) |
2590 // TODO(yusukes): Support non-Aura Windows. | 2590 // TODO(yusukes): Support non-Aura Windows. |
2591 #endif | 2591 #endif |
2592 return false; | 2592 return false; |
2593 } | 2593 } |
| 2594 |
| 2595 void BrowserView::ActivateAppModalDialog() const { |
| 2596 // If another browser is app modal, flash and activate the modal browser. |
| 2597 AppModalDialog* active_dialog = |
| 2598 AppModalDialogQueue::GetInstance()->active_dialog(); |
| 2599 if (!active_dialog) |
| 2600 return; |
| 2601 |
| 2602 Browser* modal_browser = |
| 2603 browser::FindBrowserWithWebContents(active_dialog->web_contents()); |
| 2604 if (modal_browser && (browser_ != modal_browser)) { |
| 2605 modal_browser->window()->FlashFrame(true); |
| 2606 modal_browser->window()->Activate(); |
| 2607 } |
| 2608 |
| 2609 AppModalDialogQueue::GetInstance()->ActivateModalDialog(); |
| 2610 } |
OLD | NEW |