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 "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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 // static | 568 // static |
569 WindowController* ExtensionTabUtil::GetWindowControllerOfTab( | 569 WindowController* ExtensionTabUtil::GetWindowControllerOfTab( |
570 const WebContents* web_contents) { | 570 const WebContents* web_contents) { |
571 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 571 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
572 if (browser != NULL) | 572 if (browser != NULL) |
573 return browser->extension_window_controller(); | 573 return browser->extension_window_controller(); |
574 | 574 |
575 return NULL; | 575 return NULL; |
576 } | 576 } |
577 | 577 |
578 void ExtensionTabUtil::OpenOptionsPage(const Extension* extension, | 578 bool ExtensionTabUtil::OpenOptionsPage(const Extension* extension, |
579 Browser* browser) { | 579 Browser* browser) { |
580 DCHECK(OptionsPageInfo::HasOptionsPage(extension)); | 580 if (!OptionsPageInfo::HasOptionsPage(extension)) |
| 581 return false; |
581 | 582 |
582 // 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 |
583 // able to save settings from OTR. | 584 // able to save settings from OTR. |
584 scoped_ptr<chrome::ScopedTabbedBrowserDisplayer> displayer; | 585 scoped_ptr<chrome::ScopedTabbedBrowserDisplayer> displayer; |
585 if (browser->profile()->IsOffTheRecord()) { | 586 if (browser->profile()->IsOffTheRecord()) { |
586 displayer.reset(new chrome::ScopedTabbedBrowserDisplayer( | 587 displayer.reset(new chrome::ScopedTabbedBrowserDisplayer( |
587 browser->profile()->GetOriginalProfile(), | 588 browser->profile()->GetOriginalProfile(), |
588 browser->host_desktop_type())); | 589 browser->host_desktop_type())); |
589 browser = displayer->browser(); | 590 browser = displayer->browser(); |
590 } | 591 } |
(...skipping 19 matching lines...) Expand all Loading... |
610 content::Referrer(), | 611 content::Referrer(), |
611 SINGLETON_TAB, | 612 SINGLETON_TAB, |
612 ui::PAGE_TRANSITION_LINK, | 613 ui::PAGE_TRANSITION_LINK, |
613 false); | 614 false); |
614 browser->OpenURL(params); | 615 browser->OpenURL(params); |
615 browser->window()->Show(); | 616 browser->window()->Show(); |
616 WebContents* web_contents = | 617 WebContents* web_contents = |
617 browser->tab_strip_model()->GetActiveWebContents(); | 618 browser->tab_strip_model()->GetActiveWebContents(); |
618 web_contents->GetDelegate()->ActivateContents(web_contents); | 619 web_contents->GetDelegate()->ActivateContents(web_contents); |
619 } | 620 } |
| 621 |
| 622 return true; |
620 } | 623 } |
621 | 624 |
622 } // namespace extensions | 625 } // namespace extensions |
OLD | NEW |