Chromium Code Reviews| 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 "base/strings/stringprintf.h" |
| 11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
| 12 #include "chrome/browser/extensions/chrome_extension_function.h" | 12 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 13 #include "chrome/browser/extensions/tab_helper.h" | 13 #include "chrome/browser/extensions/tab_helper.h" |
| 14 #include "chrome/browser/extensions/window_controller.h" | 14 #include "chrome/browser/extensions/window_controller.h" |
| 15 #include "chrome/browser/extensions/window_controller_list.h" | 15 #include "chrome/browser/extensions/window_controller_list.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/sessions/session_tab_helper.h" | 17 #include "chrome/browser/sessions/session_tab_helper.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
| 20 #include "chrome/browser/ui/browser_iterator.h" | 20 #include "chrome/browser/ui/browser_iterator.h" |
| 21 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
| 22 #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" | 23 #include "chrome/browser/ui/singleton_tabs.h" |
| 24 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 24 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
| 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 26 #include "chrome/common/extensions/api/tabs.h" | 26 #include "chrome/common/extensions/api/tabs.h" |
| 27 #include "chrome/common/extensions/manifest_url_handler.h" | |
| 28 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 29 #include "components/url_fixer/url_fixer.h" | 28 #include "components/url_fixer/url_fixer.h" |
| 30 #include "content/public/browser/favicon_status.h" | 29 #include "content/public/browser/favicon_status.h" |
| 31 #include "content/public/browser/navigation_entry.h" | 30 #include "content/public/browser/navigation_entry.h" |
| 32 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 33 #include "extensions/common/constants.h" | 32 #include "extensions/common/constants.h" |
| 34 #include "extensions/common/error_utils.h" | 33 #include "extensions/common/error_utils.h" |
| 35 #include "extensions/common/extension.h" | 34 #include "extensions/common/extension.h" |
| 36 #include "extensions/common/feature_switch.h" | 35 #include "extensions/common/feature_switch.h" |
| 37 #include "extensions/common/manifest_constants.h" | 36 #include "extensions/common/manifest_constants.h" |
| 38 #include "extensions/common/manifest_handlers/incognito_info.h" | 37 #include "extensions/common/manifest_handlers/incognito_info.h" |
| 38 #include "extensions/common/manifest_handlers/options_page_info.h" | |
| 39 #include "extensions/common/permissions/api_permission.h" | 39 #include "extensions/common/permissions/api_permission.h" |
| 40 #include "extensions/common/permissions/permissions_data.h" | 40 #include "extensions/common/permissions/permissions_data.h" |
| 41 #include "url/gurl.h" | 41 #include "url/gurl.h" |
| 42 | 42 |
| 43 using apps::AppWindow; | 43 using apps::AppWindow; |
| 44 using content::NavigationEntry; | 44 using content::NavigationEntry; |
| 45 using content::WebContents; | 45 using content::WebContents; |
| 46 | 46 |
| 47 namespace extensions { | 47 namespace extensions { |
| 48 | 48 |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 const WebContents* web_contents) { | 550 const WebContents* web_contents) { |
| 551 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 551 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| 552 if (browser != NULL) | 552 if (browser != NULL) |
| 553 return browser->extension_window_controller(); | 553 return browser->extension_window_controller(); |
| 554 | 554 |
| 555 return NULL; | 555 return NULL; |
| 556 } | 556 } |
| 557 | 557 |
| 558 void ExtensionTabUtil::OpenOptionsPage(const Extension* extension, | 558 void ExtensionTabUtil::OpenOptionsPage(const Extension* extension, |
| 559 Browser* browser) { | 559 Browser* browser) { |
| 560 DCHECK(!ManifestURL::GetOptionsPage(extension).is_empty()); | 560 DCHECK(!OptionsPageInfo::GetOptionsPage(extension).is_empty()); |
|
not at google - send to devlin
2014/08/29 05:39:23
At this point I realise there should be an Options
ericzeng
2014/08/29 22:08:49
Done.
| |
| 561 | 561 |
| 562 // 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 |
| 563 // able to save settings from OTR. | 563 // able to save settings from OTR. |
| 564 scoped_ptr<chrome::ScopedTabbedBrowserDisplayer> displayer; | 564 scoped_ptr<chrome::ScopedTabbedBrowserDisplayer> displayer; |
| 565 if (browser->profile()->IsOffTheRecord()) { | 565 if (browser->profile()->IsOffTheRecord()) { |
| 566 displayer.reset(new chrome::ScopedTabbedBrowserDisplayer( | 566 displayer.reset(new chrome::ScopedTabbedBrowserDisplayer( |
| 567 browser->profile()->GetOriginalProfile(), | 567 browser->profile()->GetOriginalProfile(), |
| 568 browser->host_desktop_type())); | 568 browser->host_desktop_type())); |
| 569 browser = displayer->browser(); | 569 browser = displayer->browser(); |
| 570 } | 570 } |
| 571 | 571 |
| 572 if (FeatureSwitch::embedded_extension_options()->IsEnabled()) { | 572 if (FeatureSwitch::embedded_extension_options()->IsEnabled() && |
| 573 !OptionsPageInfo::OpenInTab(extension)) { | |
| 573 // If embedded extension options are enabled, open chrome://extensions | 574 // If embedded extension options are enabled, open chrome://extensions |
| 574 // in a new tab and show the extension options in an embedded popup. | 575 // in a new tab and show the extension options in an embedded popup. |
| 575 chrome::NavigateParams params(chrome::GetSingletonTabNavigateParams( | 576 chrome::NavigateParams params(chrome::GetSingletonTabNavigateParams( |
| 576 browser, GURL(chrome::kChromeUIExtensionsURL))); | 577 browser, GURL(chrome::kChromeUIExtensionsURL))); |
| 577 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; | 578 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; |
| 578 | 579 |
| 579 GURL::Replacements replacements; | 580 GURL::Replacements replacements; |
| 580 std::string query = | 581 std::string query = |
| 581 base::StringPrintf("options=%s", extension->id().c_str()); | 582 base::StringPrintf("options=%s", extension->id().c_str()); |
| 582 replacements.SetQueryStr(query); | 583 replacements.SetQueryStr(query); |
| 583 params.url = params.url.ReplaceComponents(replacements); | 584 params.url = params.url.ReplaceComponents(replacements); |
| 584 | 585 |
| 585 chrome::ShowSingletonTabOverwritingNTP(browser, params); | 586 chrome::ShowSingletonTabOverwritingNTP(browser, params); |
| 586 } else { | 587 } else { |
| 587 // Otherwise open a new tab with the extension's options page | 588 // Otherwise open a new tab with the extension's options page |
| 588 content::OpenURLParams params(ManifestURL::GetOptionsPage(extension), | 589 content::OpenURLParams params(OptionsPageInfo::GetOptionsPage(extension), |
| 589 content::Referrer(), | 590 content::Referrer(), |
| 590 SINGLETON_TAB, | 591 SINGLETON_TAB, |
| 591 content::PAGE_TRANSITION_LINK, | 592 content::PAGE_TRANSITION_LINK, |
| 592 false); | 593 false); |
| 593 browser->OpenURL(params); | 594 browser->OpenURL(params); |
| 594 browser->window()->Show(); | 595 browser->window()->Show(); |
| 595 WebContents* web_contents = | 596 WebContents* web_contents = |
| 596 browser->tab_strip_model()->GetActiveWebContents(); | 597 browser->tab_strip_model()->GetActiveWebContents(); |
| 597 web_contents->GetDelegate()->ActivateContents(web_contents); | 598 web_contents->GetDelegate()->ActivateContents(web_contents); |
| 598 } | 599 } |
| 599 } | 600 } |
| 600 | 601 |
| 601 } // namespace extensions | 602 } // namespace extensions |
| OLD | NEW |