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 "apps/app_window.h" | 7 #include "apps/app_window.h" |
8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/stringprintf.h" | |
10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
11 #include "chrome/browser/extensions/chrome_extension_function.h" | 12 #include "chrome/browser/extensions/chrome_extension_function.h" |
12 #include "chrome/browser/extensions/tab_helper.h" | 13 #include "chrome/browser/extensions/tab_helper.h" |
13 #include "chrome/browser/extensions/window_controller.h" | 14 #include "chrome/browser/extensions/window_controller.h" |
14 #include "chrome/browser/extensions/window_controller_list.h" | 15 #include "chrome/browser/extensions/window_controller_list.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/sessions/session_tab_helper.h" | 17 #include "chrome/browser/sessions/session_tab_helper.h" |
17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
19 #include "chrome/browser/ui/browser_iterator.h" | 20 #include "chrome/browser/ui/browser_iterator.h" |
20 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
21 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 22 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
23 #include "chrome/browser/ui/singleton_tabs.h" | |
22 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 24 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
23 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
24 #include "chrome/common/extensions/api/tabs.h" | 26 #include "chrome/common/extensions/api/tabs.h" |
25 #include "chrome/common/extensions/manifest_url_handler.h" | 27 #include "chrome/common/extensions/manifest_url_handler.h" |
26 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
27 #include "components/url_fixer/url_fixer.h" | 29 #include "components/url_fixer/url_fixer.h" |
28 #include "content/public/browser/favicon_status.h" | 30 #include "content/public/browser/favicon_status.h" |
29 #include "content/public/browser/navigation_entry.h" | 31 #include "content/public/browser/navigation_entry.h" |
30 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
31 #include "extensions/common/constants.h" | 33 #include "extensions/common/constants.h" |
32 #include "extensions/common/error_utils.h" | 34 #include "extensions/common/error_utils.h" |
33 #include "extensions/common/extension.h" | 35 #include "extensions/common/extension.h" |
36 #include "extensions/common/feature_switch.h" | |
34 #include "extensions/common/manifest_constants.h" | 37 #include "extensions/common/manifest_constants.h" |
35 #include "extensions/common/manifest_handlers/incognito_info.h" | 38 #include "extensions/common/manifest_handlers/incognito_info.h" |
36 #include "extensions/common/permissions/api_permission.h" | 39 #include "extensions/common/permissions/api_permission.h" |
37 #include "extensions/common/permissions/permissions_data.h" | 40 #include "extensions/common/permissions/permissions_data.h" |
38 #include "url/gurl.h" | 41 #include "url/gurl.h" |
39 | 42 |
40 using apps::AppWindow; | 43 using apps::AppWindow; |
41 using content::NavigationEntry; | 44 using content::NavigationEntry; |
42 using content::WebContents; | 45 using content::WebContents; |
43 | 46 |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 // Force the options page to open in non-OTR window, because it won't be | 562 // Force the options page to open in non-OTR window, because it won't be |
560 // able to save settings from OTR. | 563 // able to save settings from OTR. |
561 scoped_ptr<chrome::ScopedTabbedBrowserDisplayer> displayer; | 564 scoped_ptr<chrome::ScopedTabbedBrowserDisplayer> displayer; |
562 if (browser->profile()->IsOffTheRecord()) { | 565 if (browser->profile()->IsOffTheRecord()) { |
563 displayer.reset(new chrome::ScopedTabbedBrowserDisplayer( | 566 displayer.reset(new chrome::ScopedTabbedBrowserDisplayer( |
564 browser->profile()->GetOriginalProfile(), | 567 browser->profile()->GetOriginalProfile(), |
565 browser->host_desktop_type())); | 568 browser->host_desktop_type())); |
566 browser = displayer->browser(); | 569 browser = displayer->browser(); |
567 } | 570 } |
568 | 571 |
569 content::OpenURLParams params(ManifestURL::GetOptionsPage(extension), | 572 if (FeatureSwitch::embedded_extension_options()->IsEnabled()) { |
570 content::Referrer(), | 573 // If embedded extension options are enabled, open chrome://extensions |
571 SINGLETON_TAB, | 574 // in a new tab and show the extension options in an embedded popup. |
572 content::PAGE_TRANSITION_LINK, | 575 chrome::NavigateParams params( |
573 false); | 576 chrome::GetSingletonTabNavigateParams(browser, |
Devlin
2014/08/21 17:18:19
indentation
ericzeng
2014/08/21 17:59:52
Done.
| |
574 browser->OpenURL(params); | 577 GURL(chrome::kChromeUIExtensionsURL))); |
575 browser->window()->Show(); | 578 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; |
576 WebContents* web_contents = | 579 if (!extension->id().empty()) { |
577 browser->tab_strip_model()->GetActiveWebContents(); | 580 GURL::Replacements replacements; |
578 web_contents->GetDelegate()->ActivateContents(web_contents); | 581 std::string query = |
582 base::StringPrintf("options=%s", extension->id().c_str()); | |
583 replacements.SetQueryStr(query); | |
584 params.url = params.url.ReplaceComponents(replacements); | |
585 } | |
586 chrome::ShowSingletonTabOverwritingNTP(browser, params); | |
587 } else { | |
588 // Otherwise open a new tab with the extension's options page | |
589 content::OpenURLParams params(ManifestURL::GetOptionsPage(extension), | |
590 content::Referrer(), | |
591 SINGLETON_TAB, | |
592 content::PAGE_TRANSITION_LINK, | |
593 false); | |
594 browser->OpenURL(params); | |
595 browser->window()->Show(); | |
596 WebContents* web_contents = | |
597 browser->tab_strip_model()->GetActiveWebContents(); | |
598 web_contents->GetDelegate()->ActivateContents(web_contents); | |
599 } | |
579 } | 600 } |
580 | 601 |
581 } // namespace extensions | 602 } // namespace extensions |
OLD | NEW |