Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Side by Side Diff: chrome/browser/extensions/extension_tab_util.cc

Issue 518653002: Add the "options_ui" extension manifest field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "chrome/browser/extensions/tab_helper.h" 11 #include "chrome/browser/extensions/tab_helper.h"
12 #include "chrome/browser/extensions/window_controller.h" 12 #include "chrome/browser/extensions/window_controller.h"
13 #include "chrome/browser/extensions/window_controller_list.h" 13 #include "chrome/browser/extensions/window_controller_list.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/sessions/session_tab_helper.h" 15 #include "chrome/browser/sessions/session_tab_helper.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_finder.h" 17 #include "chrome/browser/ui/browser_finder.h"
18 #include "chrome/browser/ui/browser_iterator.h" 18 #include "chrome/browser/ui/browser_iterator.h"
19 #include "chrome/browser/ui/browser_window.h" 19 #include "chrome/browser/ui/browser_window.h"
20 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 20 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
21 #include "chrome/browser/ui/singleton_tabs.h" 21 #include "chrome/browser/ui/singleton_tabs.h"
22 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" 22 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
23 #include "chrome/browser/ui/tabs/tab_strip_model.h" 23 #include "chrome/browser/ui/tabs/tab_strip_model.h"
24 #include "chrome/common/extensions/api/tabs.h" 24 #include "chrome/common/extensions/api/tabs.h"
25 #include "chrome/common/extensions/manifest_url_handler.h"
26 #include "chrome/common/url_constants.h" 25 #include "chrome/common/url_constants.h"
27 #include "components/url_fixer/url_fixer.h" 26 #include "components/url_fixer/url_fixer.h"
28 #include "content/public/browser/favicon_status.h" 27 #include "content/public/browser/favicon_status.h"
29 #include "content/public/browser/navigation_entry.h" 28 #include "content/public/browser/navigation_entry.h"
30 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
31 #include "extensions/browser/app_window/app_window.h" 30 #include "extensions/browser/app_window/app_window.h"
32 #include "extensions/browser/app_window/app_window_registry.h" 31 #include "extensions/browser/app_window/app_window_registry.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 content::NavigationEntry; 43 using content::NavigationEntry;
44 using content::WebContents; 44 using content::WebContents;
45 45
46 namespace extensions { 46 namespace extensions {
47 47
48 namespace { 48 namespace {
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 const WebContents* web_contents) { 549 const WebContents* web_contents) {
550 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); 550 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
551 if (browser != NULL) 551 if (browser != NULL)
552 return browser->extension_window_controller(); 552 return browser->extension_window_controller();
553 553
554 return NULL; 554 return NULL;
555 } 555 }
556 556
557 void ExtensionTabUtil::OpenOptionsPage(const Extension* extension, 557 void ExtensionTabUtil::OpenOptionsPage(const Extension* extension,
558 Browser* browser) { 558 Browser* browser) {
559 DCHECK(!ManifestURL::GetOptionsPage(extension).is_empty()); 559 DCHECK(OptionsPageInfo::HasOptionsPage(extension));
560 560
561 // Force the options page to open in non-OTR window, because it won't be 561 // Force the options page to open in non-OTR window, because it won't be
562 // able to save settings from OTR. 562 // able to save settings from OTR.
563 scoped_ptr<chrome::ScopedTabbedBrowserDisplayer> displayer; 563 scoped_ptr<chrome::ScopedTabbedBrowserDisplayer> displayer;
564 if (browser->profile()->IsOffTheRecord()) { 564 if (browser->profile()->IsOffTheRecord()) {
565 displayer.reset(new chrome::ScopedTabbedBrowserDisplayer( 565 displayer.reset(new chrome::ScopedTabbedBrowserDisplayer(
566 browser->profile()->GetOriginalProfile(), 566 browser->profile()->GetOriginalProfile(),
567 browser->host_desktop_type())); 567 browser->host_desktop_type()));
568 browser = displayer->browser(); 568 browser = displayer->browser();
569 } 569 }
570 570
571 if (FeatureSwitch::embedded_extension_options()->IsEnabled()) { 571 if (!OptionsPageInfo::ShouldOpenInTab(extension)) {
572 // If embedded extension options are enabled, open chrome://extensions 572 // If embedded extension options are enabled, open chrome://extensions
Devlin 2014/09/04 21:16:04 nit: tweak the wording slightly (something more li
ericzeng 2014/09/04 22:22:07 Done.
573 // in a new tab and show the extension options in an embedded popup. 573 // in a new tab and show the extension options in an embedded popup.
574 chrome::NavigateParams params(chrome::GetSingletonTabNavigateParams( 574 chrome::NavigateParams params(chrome::GetSingletonTabNavigateParams(
575 browser, GURL(chrome::kChromeUIExtensionsURL))); 575 browser, GURL(chrome::kChromeUIExtensionsURL)));
576 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 576 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
577 577
578 GURL::Replacements replacements; 578 GURL::Replacements replacements;
579 std::string query = 579 std::string query =
580 base::StringPrintf("options=%s", extension->id().c_str()); 580 base::StringPrintf("options=%s", extension->id().c_str());
581 replacements.SetQueryStr(query); 581 replacements.SetQueryStr(query);
582 params.url = params.url.ReplaceComponents(replacements); 582 params.url = params.url.ReplaceComponents(replacements);
583 583
584 chrome::ShowSingletonTabOverwritingNTP(browser, params); 584 chrome::ShowSingletonTabOverwritingNTP(browser, params);
585 } else { 585 } else {
586 // Otherwise open a new tab with the extension's options page 586 // Otherwise open a new tab with the extension's options page
587 content::OpenURLParams params(ManifestURL::GetOptionsPage(extension), 587 content::OpenURLParams params(OptionsPageInfo::GetOptionsPage(extension),
588 content::Referrer(), 588 content::Referrer(),
589 SINGLETON_TAB, 589 SINGLETON_TAB,
590 content::PAGE_TRANSITION_LINK, 590 content::PAGE_TRANSITION_LINK,
591 false); 591 false);
592 browser->OpenURL(params); 592 browser->OpenURL(params);
593 browser->window()->Show(); 593 browser->window()->Show();
594 WebContents* web_contents = 594 WebContents* web_contents =
595 browser->tab_strip_model()->GetActiveWebContents(); 595 browser->tab_strip_model()->GetActiveWebContents();
596 web_contents->GetDelegate()->ActivateContents(web_contents); 596 web_contents->GetDelegate()->ActivateContents(web_contents);
597 } 597 }
598 } 598 }
599 599
600 } // namespace extensions 600 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698