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

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

Issue 484033003: Open embedded extension options from the extension action context menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 4 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 "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
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(chrome::GetSingletonTabNavigateParams(
573 false); 576 browser, GURL(chrome::kChromeUIExtensionsURL)));
574 browser->OpenURL(params); 577 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
575 browser->window()->Show(); 578 if (!extension->id().empty()) {
not at google - send to devlin 2014/08/25 18:11:07 I don't think it's possible for Extensions to have
ericzeng 2014/08/25 21:42:34 This part was adapted from chrome_pages.cc, which
not at google - send to devlin 2014/08/25 21:53:29 Let's kill both. They're silly.
ericzeng 2014/08/25 22:04:04 But then I would need an owner for chrome/browser/
not at google - send to devlin 2014/08/25 22:07:53 Ok, just remove this one then :)
576 WebContents* web_contents = 579 GURL::Replacements replacements;
577 browser->tab_strip_model()->GetActiveWebContents(); 580 std::string query =
578 web_contents->GetDelegate()->ActivateContents(web_contents); 581 base::StringPrintf("options=%s", extension->id().c_str());
not at google - send to devlin 2014/08/25 18:11:07 Using StringPrintf here is overkill. Just "options
Devlin 2014/08/25 18:12:51 I told him to, as I've been told repeatedly to use
not at google - send to devlin 2014/08/25 21:53:29 Btw Devlin and I follow up on this offline with Je
582 replacements.SetQueryStr(query);
583 params.url = params.url.ReplaceComponents(replacements);
584 }
585 chrome::ShowSingletonTabOverwritingNTP(browser, params);
586 } else {
587 // Otherwise open a new tab with the extension's options page
588 content::OpenURLParams params(ManifestURL::GetOptionsPage(extension),
589 content::Referrer(),
590 SINGLETON_TAB,
591 content::PAGE_TRANSITION_LINK,
592 false);
593 browser->OpenURL(params);
594 browser->window()->Show();
595 WebContents* web_contents =
596 browser->tab_strip_model()->GetActiveWebContents();
597 web_contents->GetDelegate()->ActivateContents(web_contents);
598 }
579 } 599 }
580 600
581 } // namespace extensions 601 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698