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/extension_tab_util.h" | 5 #include "chrome/browser/extensions/extension_tab_util.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
10 #include "chrome/browser/extensions/chrome_extension_function.h" | 10 #include "chrome/browser/extensions/chrome_extension_function.h" |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 // Force the options page to open in non-OTR window, because it won't be | 583 // Force the options page to open in non-OTR window, because it won't be |
584 // able to save settings from OTR. | 584 // able to save settings from OTR. |
585 scoped_ptr<chrome::ScopedTabbedBrowserDisplayer> displayer; | 585 scoped_ptr<chrome::ScopedTabbedBrowserDisplayer> displayer; |
586 if (browser->profile()->IsOffTheRecord()) { | 586 if (browser->profile()->IsOffTheRecord()) { |
587 displayer.reset(new chrome::ScopedTabbedBrowserDisplayer( | 587 displayer.reset(new chrome::ScopedTabbedBrowserDisplayer( |
588 browser->profile()->GetOriginalProfile(), | 588 browser->profile()->GetOriginalProfile(), |
589 browser->host_desktop_type())); | 589 browser->host_desktop_type())); |
590 browser = displayer->browser(); | 590 browser = displayer->browser(); |
591 } | 591 } |
592 | 592 |
593 if (!OptionsPageInfo::ShouldOpenInTab(extension)) { | 593 GURL url_to_navigate; |
594 // If we should embed the options page for this extension, open | 594 if (OptionsPageInfo::ShouldOpenInTab(extension)) { |
595 // chrome://extensions in a new tab and show the extension options in an | 595 // Options page tab is simply e.g. chrome-extension://.../options.html. |
596 // embedded popup. | 596 url_to_navigate = OptionsPageInfo::GetOptionsPage(extension); |
597 chrome::NavigateParams params(chrome::GetSingletonTabNavigateParams( | 597 } else { |
598 browser, GURL(chrome::kChromeUIExtensionsURL))); | 598 // Options page tab is Extension settings pointed at that Extension's ID, |
599 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; | 599 // e.g. chrome://extensions?options=... |
600 | 600 url_to_navigate = GURL(chrome::kChromeUIExtensionsURL); |
601 GURL::Replacements replacements; | 601 GURL::Replacements replacements; |
602 std::string query = | 602 std::string query = |
603 base::StringPrintf("options=%s", extension->id().c_str()); | 603 base::StringPrintf("options=%s", extension->id().c_str()); |
604 replacements.SetQueryStr(query); | 604 replacements.SetQueryStr(query); |
605 params.url = params.url.ReplaceComponents(replacements); | 605 url_to_navigate = url_to_navigate.ReplaceComponents(replacements); |
606 | |
607 chrome::ShowSingletonTabOverwritingNTP(browser, params); | |
608 } else { | |
609 // Otherwise open a new tab with the extension's options page | |
610 content::OpenURLParams params(OptionsPageInfo::GetOptionsPage(extension), | |
611 content::Referrer(), | |
612 SINGLETON_TAB, | |
613 ui::PAGE_TRANSITION_LINK, | |
614 false); | |
615 browser->OpenURL(params); | |
616 browser->window()->Show(); | |
617 WebContents* web_contents = | |
618 browser->tab_strip_model()->GetActiveWebContents(); | |
619 web_contents->GetDelegate()->ActivateContents(web_contents); | |
620 } | 606 } |
621 | 607 |
| 608 chrome::NavigateParams params( |
| 609 chrome::GetSingletonTabNavigateParams(browser, url_to_navigate)); |
| 610 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; |
| 611 params.url = url_to_navigate; |
| 612 chrome::ShowSingletonTabOverwritingNTP(browser, params); |
622 return true; | 613 return true; |
623 } | 614 } |
624 | 615 |
625 } // namespace extensions | 616 } // namespace extensions |
OLD | NEW |