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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 } | 174 } |
175 | 175 |
176 template <typename T> | 176 template <typename T> |
177 void AssignOptionalValue(const scoped_ptr<T>& source, | 177 void AssignOptionalValue(const scoped_ptr<T>& source, |
178 scoped_ptr<T>& destination) { | 178 scoped_ptr<T>& destination) { |
179 if (source.get()) { | 179 if (source.get()) { |
180 destination.reset(new T(*source.get())); | 180 destination.reset(new T(*source.get())); |
181 } | 181 } |
182 } | 182 } |
183 | 183 |
184 ui::WindowShowState ConvertToWindowShowState(windows::State state) { | |
185 switch (state) { | |
186 case windows::STATE_NORMAL: | |
187 return ui::SHOW_STATE_NORMAL; | |
188 case windows::STATE_MINIMIZED: | |
189 return ui::SHOW_STATE_MINIMIZED; | |
190 case windows::STATE_MAXIMIZED: | |
191 return ui::SHOW_STATE_MAXIMIZED; | |
192 case windows::STATE_FULLSCREEN: | |
193 return ui::SHOW_STATE_FULLSCREEN; | |
194 case windows::STATE_NONE: | |
195 return ui::SHOW_STATE_DEFAULT; | |
196 } | |
197 NOTREACHED(); | |
198 return ui::SHOW_STATE_DEFAULT; | |
199 } | |
200 | |
184 } // namespace | 201 } // namespace |
185 | 202 |
186 void ZoomModeToZoomSettings(ZoomController::ZoomMode zoom_mode, | 203 void ZoomModeToZoomSettings(ZoomController::ZoomMode zoom_mode, |
187 api::tabs::ZoomSettings* zoom_settings) { | 204 api::tabs::ZoomSettings* zoom_settings) { |
188 DCHECK(zoom_settings); | 205 DCHECK(zoom_settings); |
189 switch (zoom_mode) { | 206 switch (zoom_mode) { |
190 case ZoomController::ZOOM_MODE_DEFAULT: | 207 case ZoomController::ZOOM_MODE_DEFAULT: |
191 zoom_settings->mode = api::tabs::ZoomSettings::MODE_AUTOMATIC; | 208 zoom_settings->mode = api::tabs::ZoomSettings::MODE_AUTOMATIC; |
192 zoom_settings->scope = api::tabs::ZoomSettings::SCOPE_PER_ORIGIN; | 209 zoom_settings->scope = api::tabs::ZoomSettings::SCOPE_PER_ORIGIN; |
193 break; | 210 break; |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
552 create_params.initial_bounds = window_bounds; | 569 create_params.initial_bounds = window_bounds; |
553 } else { | 570 } else { |
554 create_params = Browser::CreateParams::CreateForApp( | 571 create_params = Browser::CreateParams::CreateForApp( |
555 web_app::GenerateApplicationNameFromExtensionId(extension_id), | 572 web_app::GenerateApplicationNameFromExtensionId(extension_id), |
556 false /* trusted_source */, | 573 false /* trusted_source */, |
557 window_bounds, | 574 window_bounds, |
558 window_profile, | 575 window_profile, |
559 host_desktop_type); | 576 host_desktop_type); |
560 } | 577 } |
561 create_params.initial_show_state = ui::SHOW_STATE_NORMAL; | 578 create_params.initial_show_state = ui::SHOW_STATE_NORMAL; |
579 if (create_data && create_data->state) { | |
580 create_params.initial_show_state = | |
581 ConvertToWindowShowState(create_data->state); | |
582 } | |
562 create_params.host_desktop_type = chrome::GetActiveDesktop(); | 583 create_params.host_desktop_type = chrome::GetActiveDesktop(); |
563 | 584 |
564 Browser* new_window = new Browser(create_params); | 585 Browser* new_window = new Browser(create_params); |
565 | 586 |
566 for (std::vector<GURL>::iterator i = urls.begin(); i != urls.end(); ++i) { | 587 for (std::vector<GURL>::iterator i = urls.begin(); i != urls.end(); ++i) { |
567 WebContents* tab = chrome::AddSelectedTabWithURL( | 588 WebContents* tab = chrome::AddSelectedTabWithURL( |
568 new_window, *i, ui::PAGE_TRANSITION_LINK); | 589 new_window, *i, ui::PAGE_TRANSITION_LINK); |
569 if (create_panel) { | 590 if (create_panel) { |
570 TabHelper::FromWebContents(tab)->SetExtensionAppIconById(extension_id); | 591 TabHelper::FromWebContents(tab)->SetExtensionAppIconById(extension_id); |
571 } | 592 } |
(...skipping 16 matching lines...) Expand all Loading... | |
588 // tab when it is intended to create an empty popup. | 609 // tab when it is intended to create an empty popup. |
589 if (!contents && urls.empty() && window_type != Browser::TYPE_POPUP) { | 610 if (!contents && urls.empty() && window_type != Browser::TYPE_POPUP) { |
590 chrome::NewTab(new_window); | 611 chrome::NewTab(new_window); |
591 } | 612 } |
592 chrome::SelectNumberedTab(new_window, 0); | 613 chrome::SelectNumberedTab(new_window, 0); |
593 | 614 |
594 // Unlike other window types, Panels do not take focus by default. | 615 // Unlike other window types, Panels do not take focus by default. |
595 if (!saw_focus_key && create_panel) | 616 if (!saw_focus_key && create_panel) |
596 focused = false; | 617 focused = false; |
597 | 618 |
619 WindowController* controller = new_window->extension_window_controller(); | |
620 // Start being fullscreen before Show(). This make the window looks like | |
621 // initialy fullscreen. | |
622 if (create_params.initial_show_state == ui::SHOW_STATE_FULLSCREEN) | |
623 controller->SetFullscreenMode(true, extension()->url()); | |
624 | |
598 if (focused) | 625 if (focused) |
599 new_window->window()->Show(); | 626 new_window->window()->Show(); |
600 else | 627 else |
601 new_window->window()->ShowInactive(); | 628 new_window->window()->ShowInactive(); |
602 | 629 |
630 // Make window minimized. Because Window can't be initially minimized. | |
631 if (create_params.initial_show_state == ui::SHOW_STATE_MINIMIZED) | |
632 new_window->window()->Minimize(); | |
tapted
2015/04/01 03:41:55
These additions still don't look right to me.
On
limasdf
2015/04/01 23:59:45
Yeah. views::Widget::Show() make newly made window
limasdf
2015/04/02 16:57:48
I found that minimized window creation from X11 is
tapted
2015/04/15 00:36:12
So is it just X11 that's affected?
reading Deskto
limasdf
2015/04/15 23:34:49
About creation of minimized window, Only X11 doesn
tapted
2015/04/16 00:31:03
For Windows and fullscreen, I've seen this too. Se
| |
633 | |
603 if (new_window->profile()->IsOffTheRecord() && | 634 if (new_window->profile()->IsOffTheRecord() && |
604 !GetProfile()->IsOffTheRecord() && !include_incognito()) { | 635 !GetProfile()->IsOffTheRecord() && !include_incognito()) { |
605 // Don't expose incognito windows if extension itself works in non-incognito | 636 // Don't expose incognito windows if extension itself works in non-incognito |
606 // profile and CanCrossIncognito isn't allowed. | 637 // profile and CanCrossIncognito isn't allowed. |
607 SetResult(base::Value::CreateNullValue()); | 638 SetResult(base::Value::CreateNullValue()); |
608 } else { | 639 } else { |
609 SetResult( | 640 SetResult(controller->CreateWindowValueWithTabs(extension())); |
610 new_window->extension_window_controller()->CreateWindowValueWithTabs( | |
611 extension())); | |
612 } | 641 } |
613 | 642 |
614 return true; | 643 return true; |
615 } | 644 } |
616 | 645 |
617 bool WindowsUpdateFunction::RunSync() { | 646 bool WindowsUpdateFunction::RunSync() { |
618 scoped_ptr<windows::Update::Params> params( | 647 scoped_ptr<windows::Update::Params> params( |
619 windows::Update::Params::Create(*args_)); | 648 windows::Update::Params::Create(*args_)); |
620 EXTENSION_FUNCTION_VALIDATE(params); | 649 EXTENSION_FUNCTION_VALIDATE(params); |
621 | 650 |
622 WindowController* controller; | 651 WindowController* controller; |
623 if (!windows_util::GetWindowFromWindowID(this, params->window_id, | 652 if (!windows_util::GetWindowFromWindowID(this, params->window_id, |
624 &controller)) | 653 &controller)) |
625 return false; | 654 return false; |
626 | 655 |
627 ui::WindowShowState show_state = ui::SHOW_STATE_DEFAULT; // No change. | 656 ui::WindowShowState show_state = |
628 switch (params->update_info.state) { | 657 ConvertToWindowShowState(params->update_info.state); |
629 case windows::Update::Params::UpdateInfo::STATE_NORMAL: | |
630 show_state = ui::SHOW_STATE_NORMAL; | |
631 break; | |
632 case windows::Update::Params::UpdateInfo::STATE_MINIMIZED: | |
633 show_state = ui::SHOW_STATE_MINIMIZED; | |
634 break; | |
635 case windows::Update::Params::UpdateInfo::STATE_MAXIMIZED: | |
636 show_state = ui::SHOW_STATE_MAXIMIZED; | |
637 break; | |
638 case windows::Update::Params::UpdateInfo::STATE_FULLSCREEN: | |
639 show_state = ui::SHOW_STATE_FULLSCREEN; | |
640 break; | |
641 case windows::Update::Params::UpdateInfo::STATE_NONE: | |
642 break; | |
643 default: | |
644 error_ = keys::kInvalidWindowStateError; | |
645 return false; | |
646 } | |
647 | 658 |
648 if (show_state != ui::SHOW_STATE_FULLSCREEN && | 659 if (show_state != ui::SHOW_STATE_FULLSCREEN && |
649 show_state != ui::SHOW_STATE_DEFAULT) | 660 show_state != ui::SHOW_STATE_DEFAULT) |
650 controller->SetFullscreenMode(false, extension()->url()); | 661 controller->SetFullscreenMode(false, extension()->url()); |
651 | 662 |
652 switch (show_state) { | 663 switch (show_state) { |
653 case ui::SHOW_STATE_MINIMIZED: | 664 case ui::SHOW_STATE_MINIMIZED: |
654 controller->window()->Minimize(); | 665 controller->window()->Minimize(); |
655 break; | 666 break; |
656 case ui::SHOW_STATE_MAXIMIZED: | 667 case ui::SHOW_STATE_MAXIMIZED: |
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1953 ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode(); | 1964 ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode(); |
1954 api::tabs::ZoomSettings zoom_settings; | 1965 api::tabs::ZoomSettings zoom_settings; |
1955 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); | 1966 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); |
1956 | 1967 |
1957 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); | 1968 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); |
1958 SendResponse(true); | 1969 SendResponse(true); |
1959 return true; | 1970 return true; |
1960 } | 1971 } |
1961 | 1972 |
1962 } // namespace extensions | 1973 } // namespace extensions |
OLD | NEW |