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/extensions/api/tabs/tabs_api.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 // those of the browser. | 197 // those of the browser. |
198 bool MatchesBool(bool* boolean, bool value) { | 198 bool MatchesBool(bool* boolean, bool value) { |
199 return !boolean || *boolean == value; | 199 return !boolean || *boolean == value; |
200 } | 200 } |
201 | 201 |
202 Browser* CreateBrowserWindow(const Browser::CreateParams& params, | 202 Browser* CreateBrowserWindow(const Browser::CreateParams& params, |
203 Profile* profile, | 203 Profile* profile, |
204 const std::string& extension_id) { | 204 const std::string& extension_id) { |
205 bool use_existing_browser_window = false; | 205 bool use_existing_browser_window = false; |
206 | 206 |
207 #if defined(OS_WIN) | 207 #if defined(OS_WIN) && !defined(USE_AURA) |
Dmitry Titov
2013/11/05 05:53:07
IsSingleWindowMetroMode() returns false if USE_ASH
sky
2013/11/05 15:49:37
You are right. I was trying to make it clear this
| |
208 // In windows 8 metro mode we don't allow windows to be created. | 208 // In windows 8 metro mode we don't allow windows to be created. |
209 if (win8::IsSingleWindowMetroMode()) | 209 if (win8::IsSingleWindowMetroMode()) |
210 use_existing_browser_window = true; | 210 use_existing_browser_window = true; |
211 #endif // OS_WIN | 211 #endif // OS_WIN |
212 | 212 |
213 Browser* new_window = NULL; | 213 Browser* new_window = NULL; |
214 if (use_existing_browser_window) | 214 if (use_existing_browser_window) |
215 // The false parameter passed below is to ensure that we find a browser | 215 // The false parameter passed below is to ensure that we find a browser |
216 // object matching the profile passed in, instead of the original profile | 216 // object matching the profile passed in, instead of the original profile |
217 new_window = chrome::FindTabbedBrowser(profile, false, | 217 new_window = chrome::FindTabbedBrowser(profile, false, |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 break; | 457 break; |
458 case windows::Create::Params::CreateData::TYPE_PANEL: | 458 case windows::Create::Params::CreateData::TYPE_PANEL: |
459 case windows::Create::Params::CreateData::TYPE_DETACHED_PANEL: { | 459 case windows::Create::Params::CreateData::TYPE_DETACHED_PANEL: { |
460 extension_id = GetExtension()->id(); | 460 extension_id = GetExtension()->id(); |
461 bool use_panels = false; | 461 bool use_panels = false; |
462 #if !defined(OS_ANDROID) | 462 #if !defined(OS_ANDROID) |
463 use_panels = PanelManager::ShouldUsePanels(extension_id); | 463 use_panels = PanelManager::ShouldUsePanels(extension_id); |
464 #endif | 464 #endif |
465 if (use_panels) { | 465 if (use_panels) { |
466 create_panel = true; | 466 create_panel = true; |
467 #if !defined(OS_CHROMEOS) | 467 // Non-ash supports both docked and detached panel types. |
468 // Non-ChromeOS has both docked and detached panel types. | 468 if (chrome::GetActiveDesktop() != chrome::HOST_DESKTOP_TYPE_ASH && |
469 if (create_data->type == | 469 create_data->type == |
470 windows::Create::Params::CreateData::TYPE_DETACHED_PANEL) { | 470 windows::Create::Params::CreateData::TYPE_DETACHED_PANEL) { |
471 panel_create_mode = PanelManager::CREATE_AS_DETACHED; | 471 panel_create_mode = PanelManager::CREATE_AS_DETACHED; |
472 } | 472 } |
473 #endif | |
474 } else { | 473 } else { |
475 window_type = Browser::TYPE_POPUP; | 474 window_type = Browser::TYPE_POPUP; |
476 } | 475 } |
477 break; | 476 break; |
478 } | 477 } |
479 case windows::Create::Params::CreateData::TYPE_NONE: | 478 case windows::Create::Params::CreateData::TYPE_NONE: |
480 case windows::Create::Params::CreateData::TYPE_NORMAL: | 479 case windows::Create::Params::CreateData::TYPE_NORMAL: |
481 break; | 480 break; |
482 default: | 481 default: |
483 error_ = keys::kInvalidWindowTypeError; | 482 error_ = keys::kInvalidWindowTypeError; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
524 if (create_data->focused) { | 523 if (create_data->focused) { |
525 focused = *create_data->focused; | 524 focused = *create_data->focused; |
526 saw_focus_key = true; | 525 saw_focus_key = true; |
527 } | 526 } |
528 } | 527 } |
529 | 528 |
530 if (create_panel) { | 529 if (create_panel) { |
531 if (urls.empty()) | 530 if (urls.empty()) |
532 urls.push_back(GURL(chrome::kChromeUINewTabURL)); | 531 urls.push_back(GURL(chrome::kChromeUINewTabURL)); |
533 | 532 |
534 #if defined(OS_CHROMEOS) | 533 #if defined(USE_ASH) |
535 if (PanelManager::ShouldUsePanels(extension_id)) { | 534 if (PanelManager::ShouldUsePanels(extension_id) && |
535 chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) { | |
Dmitry Titov
2013/11/05 05:53:07
There should be an else branch that creates a pane
sky
2013/11/05 15:49:37
I think you're saying nuke the ifdef here. Done. G
| |
536 ShellWindow::CreateParams create_params; | 536 ShellWindow::CreateParams create_params; |
537 create_params.window_type = ShellWindow::WINDOW_TYPE_V1_PANEL; | 537 create_params.window_type = ShellWindow::WINDOW_TYPE_V1_PANEL; |
538 create_params.bounds = window_bounds; | 538 create_params.bounds = window_bounds; |
539 create_params.focused = saw_focus_key && focused; | 539 create_params.focused = saw_focus_key && focused; |
540 ShellWindow* shell_window = new ShellWindow( | 540 ShellWindow* shell_window = new ShellWindow( |
541 window_profile, new ChromeShellWindowDelegate(), | 541 window_profile, new ChromeShellWindowDelegate(), |
542 GetExtension()); | 542 GetExtension()); |
543 AshPanelContents* ash_panel_contents = new AshPanelContents(shell_window); | 543 AshPanelContents* ash_panel_contents = new AshPanelContents(shell_window); |
544 shell_window->Init(urls[0], ash_panel_contents, create_params); | 544 shell_window->Init(urls[0], ash_panel_contents, create_params); |
545 SetResult(ash_panel_contents->GetExtensionWindowController()-> | 545 SetResult(ash_panel_contents->GetExtensionWindowController()-> |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
640 bool WindowsUpdateFunction::RunImpl() { | 640 bool WindowsUpdateFunction::RunImpl() { |
641 scoped_ptr<windows::Update::Params> params( | 641 scoped_ptr<windows::Update::Params> params( |
642 windows::Update::Params::Create(*args_)); | 642 windows::Update::Params::Create(*args_)); |
643 EXTENSION_FUNCTION_VALIDATE(params); | 643 EXTENSION_FUNCTION_VALIDATE(params); |
644 | 644 |
645 WindowController* controller; | 645 WindowController* controller; |
646 if (!windows_util::GetWindowFromWindowID(this, params->window_id, | 646 if (!windows_util::GetWindowFromWindowID(this, params->window_id, |
647 &controller)) | 647 &controller)) |
648 return false; | 648 return false; |
649 | 649 |
650 #if defined(OS_WIN) | 650 #if defined(OS_WIN) && !defined(USE_AURA) |
651 // Silently ignore changes on the window for metro mode. | 651 // Silently ignore changes on the window for metro mode. |
652 if (win8::IsSingleWindowMetroMode()) { | 652 if (win8::IsSingleWindowMetroMode()) { |
653 SetResult(controller->CreateWindowValue()); | 653 SetResult(controller->CreateWindowValue()); |
654 return true; | 654 return true; |
655 } | 655 } |
656 #endif | 656 #endif |
657 | 657 |
658 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT; // No change. | 658 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT; // No change. |
659 switch (params->update_info.state) { | 659 switch (params->update_info.state) { |
660 case windows::Update::Params::UpdateInfo::STATE_NORMAL: | 660 case windows::Update::Params::UpdateInfo::STATE_NORMAL: |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
768 bool WindowsRemoveFunction::RunImpl() { | 768 bool WindowsRemoveFunction::RunImpl() { |
769 scoped_ptr<windows::Remove::Params> params( | 769 scoped_ptr<windows::Remove::Params> params( |
770 windows::Remove::Params::Create(*args_)); | 770 windows::Remove::Params::Create(*args_)); |
771 EXTENSION_FUNCTION_VALIDATE(params); | 771 EXTENSION_FUNCTION_VALIDATE(params); |
772 | 772 |
773 WindowController* controller; | 773 WindowController* controller; |
774 if (!windows_util::GetWindowFromWindowID(this, params->window_id, | 774 if (!windows_util::GetWindowFromWindowID(this, params->window_id, |
775 &controller)) | 775 &controller)) |
776 return false; | 776 return false; |
777 | 777 |
778 #if defined(OS_WIN) | 778 #if defined(OS_WIN) && !defined(USE_AURA) |
779 // In Windows 8 metro mode, an existing Browser instance is reused for | 779 // In Windows 8 metro mode, an existing Browser instance is reused for |
780 // hosting the extension tab. We should not be closing it as we don't own it. | 780 // hosting the extension tab. We should not be closing it as we don't own it. |
781 if (win8::IsSingleWindowMetroMode()) | 781 if (win8::IsSingleWindowMetroMode()) |
782 return false; | 782 return false; |
783 #endif | 783 #endif |
784 | 784 |
785 WindowController::Reason reason; | 785 WindowController::Reason reason; |
786 if (!controller->CanClose(&reason)) { | 786 if (!controller->CanClose(&reason)) { |
787 if (reason == WindowController::REASON_NOT_EDITABLE) | 787 if (reason == WindowController::REASON_NOT_EDITABLE) |
788 error_ = keys::kTabStripNotEditableError; | 788 error_ = keys::kTabStripNotEditableError; |
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2065 execute_tab_id_ = tab_id; | 2065 execute_tab_id_ = tab_id; |
2066 details_ = details.Pass(); | 2066 details_ = details.Pass(); |
2067 return true; | 2067 return true; |
2068 } | 2068 } |
2069 | 2069 |
2070 bool TabsInsertCSSFunction::ShouldInsertCSS() const { | 2070 bool TabsInsertCSSFunction::ShouldInsertCSS() const { |
2071 return true; | 2071 return true; |
2072 } | 2072 } |
2073 | 2073 |
2074 } // namespace extensions | 2074 } // namespace extensions |
OLD | NEW |