OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
(...skipping 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2073 | 2073 |
2074 #if BUILDFLAG(ENABLE_EXTENSIONS) | 2074 #if BUILDFLAG(ENABLE_EXTENSIONS) |
2075 /////////////////////////////////////////////////////////////////////////////// | 2075 /////////////////////////////////////////////////////////////////////////////// |
2076 // Browser, extensions::ExtensionRegistryObserver implementation: | 2076 // Browser, extensions::ExtensionRegistryObserver implementation: |
2077 | 2077 |
2078 void Browser::OnExtensionLoaded(content::BrowserContext* browser_context, | 2078 void Browser::OnExtensionLoaded(content::BrowserContext* browser_context, |
2079 const extensions::Extension* extension) { | 2079 const extensions::Extension* extension) { |
2080 command_controller_->ExtensionStateChanged(); | 2080 command_controller_->ExtensionStateChanged(); |
2081 } | 2081 } |
2082 | 2082 |
2083 void Browser::OnExtensionUnloaded( | 2083 void Browser::OnExtensionUnloaded(content::BrowserContext* browser_context, |
2084 content::BrowserContext* browser_context, | 2084 const extensions::Extension* extension, |
2085 const extensions::Extension* extension, | 2085 extensions::UnloadedExtensionReason reason) { |
2086 extensions::UnloadedExtensionInfo::Reason reason) { | |
2087 command_controller_->ExtensionStateChanged(); | 2086 command_controller_->ExtensionStateChanged(); |
2088 | 2087 |
2089 // Close any tabs from the unloaded extension, unless it's terminated, | 2088 // Close any tabs from the unloaded extension, unless it's terminated, |
2090 // in which case let the sad tabs remain. | 2089 // in which case let the sad tabs remain. |
2091 // Also, if tab is muted and the cause is the unloaded extension, unmute it. | 2090 // Also, if tab is muted and the cause is the unloaded extension, unmute it. |
2092 if (reason != extensions::UnloadedExtensionInfo::REASON_TERMINATE) { | 2091 if (reason != extensions::UnloadedExtensionReason::REASON_TERMINATE) { |
2093 // Iterate backwards as we may remove items while iterating. | 2092 // Iterate backwards as we may remove items while iterating. |
2094 for (int i = tab_strip_model_->count() - 1; i >= 0; --i) { | 2093 for (int i = tab_strip_model_->count() - 1; i >= 0; --i) { |
2095 WebContents* web_contents = tab_strip_model_->GetWebContentsAt(i); | 2094 WebContents* web_contents = tab_strip_model_->GetWebContentsAt(i); |
2096 // Two cases are handled here: | 2095 // Two cases are handled here: |
2097 | 2096 |
2098 // - The scheme check is for when an extension page is loaded in a | 2097 // - The scheme check is for when an extension page is loaded in a |
2099 // tab, e.g. chrome-extension://id/page.html. | 2098 // tab, e.g. chrome-extension://id/page.html. |
2100 // - The extension_app check is for apps, which can have non-extension | 2099 // - The extension_app check is for apps, which can have non-extension |
2101 // schemes, e.g. https://mail.google.com if you have the Gmail app | 2100 // schemes, e.g. https://mail.google.com if you have the Gmail app |
2102 // installed. | 2101 // installed. |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2628 // new window later, thus we need to navigate the window now. | 2627 // new window later, thus we need to navigate the window now. |
2629 if (contents) { | 2628 if (contents) { |
2630 contents->web_contents()->GetController().LoadURL( | 2629 contents->web_contents()->GetController().LoadURL( |
2631 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 2630 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
2632 std::string()); // No extra headers. | 2631 std::string()); // No extra headers. |
2633 } | 2632 } |
2634 } | 2633 } |
2635 | 2634 |
2636 return contents != NULL; | 2635 return contents != NULL; |
2637 } | 2636 } |
OLD | NEW |