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

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

Issue 1005673002: Make UI or API driven extension options navigations refocus any existing options page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test Created 5 years, 9 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
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/runtime/open_options_page/manifest.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/runtime/open_options_page/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698