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

Side by Side Diff: chrome/browser/ui/browser_navigator.cc

Issue 664553007: Cleanup: Put more chrome/ code behind ENABLE_EXTENSIONS ifdefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: fix android Created 6 years, 2 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 | « chrome/browser/ui/browser_commands.cc ('k') | chrome/common/localized_error.h » ('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/ui/browser_navigator.h" 5 #include "chrome/browser/ui/browser_navigator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/browser_about_handler.h" 13 #include "chrome/browser/browser_about_handler.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/extensions/tab_helper.h"
16 #include "chrome/browser/prefs/incognito_mode_prefs.h" 15 #include "chrome/browser/prefs/incognito_mode_prefs.h"
17 #include "chrome/browser/prerender/prerender_manager.h" 16 #include "chrome/browser/prerender/prerender_manager.h"
18 #include "chrome/browser/prerender/prerender_manager_factory.h" 17 #include "chrome/browser/prerender/prerender_manager_factory.h"
19 #include "chrome/browser/prerender/prerender_util.h" 18 #include "chrome/browser/prerender/prerender_util.h"
20 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/tab_contents/tab_util.h" 20 #include "chrome/browser/tab_contents/tab_util.h"
22 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/browser_finder.h" 22 #include "chrome/browser/ui/browser_finder.h"
24 #include "chrome/browser/ui/browser_instant_controller.h" 23 #include "chrome/browser/ui/browser_instant_controller.h"
25 #include "chrome/browser/ui/browser_window.h" 24 #include "chrome/browser/ui/browser_window.h"
26 #include "chrome/browser/ui/host_desktop.h" 25 #include "chrome/browser/ui/host_desktop.h"
27 #include "chrome/browser/ui/location_bar/location_bar.h" 26 #include "chrome/browser/ui/location_bar/location_bar.h"
28 #include "chrome/browser/ui/search/instant_search_prerenderer.h" 27 #include "chrome/browser/ui/search/instant_search_prerenderer.h"
29 #include "chrome/browser/ui/singleton_tabs.h" 28 #include "chrome/browser/ui/singleton_tabs.h"
30 #include "chrome/browser/ui/status_bubble.h" 29 #include "chrome/browser/ui/status_bubble.h"
31 #include "chrome/browser/ui/tab_helpers.h" 30 #include "chrome/browser/ui/tab_helpers.h"
32 #include "chrome/browser/ui/tabs/tab_strip_model.h" 31 #include "chrome/browser/ui/tabs/tab_strip_model.h"
33 #include "chrome/browser/web_applications/web_app.h"
34 #include "chrome/common/pref_names.h" 32 #include "chrome/common/pref_names.h"
35 #include "chrome/common/url_constants.h" 33 #include "chrome/common/url_constants.h"
36 #include "components/google/core/browser/google_url_tracker.h" 34 #include "components/google/core/browser/google_url_tracker.h"
37 #include "content/public/browser/browser_url_handler.h" 35 #include "content/public/browser/browser_url_handler.h"
38 #include "content/public/browser/navigation_entry.h" 36 #include "content/public/browser/navigation_entry.h"
39 #include "content/public/browser/notification_service.h" 37 #include "content/public/browser/notification_service.h"
40 #include "content/public/browser/render_view_host.h" 38 #include "content/public/browser/render_view_host.h"
41 #include "content/public/browser/web_contents.h" 39 #include "content/public/browser/web_contents.h"
42 40
43 #if defined(USE_ASH) 41 #if defined(USE_ASH)
44 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 42 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
45 #endif 43 #endif
46 44
47 #if defined(USE_AURA) 45 #if defined(USE_AURA)
48 #include "ui/aura/window.h" 46 #include "ui/aura/window.h"
49 #endif 47 #endif
50 48
51 #if defined(ENABLE_EXTENSIONS) 49 #if defined(ENABLE_EXTENSIONS)
50 #include "chrome/browser/extensions/tab_helper.h"
51 #include "chrome/browser/web_applications/web_app.h"
52 #include "extensions/browser/extension_registry.h" 52 #include "extensions/browser/extension_registry.h"
53 #include "extensions/common/extension.h" 53 #include "extensions/common/extension.h"
54 #include "extensions/common/extension_set.h" 54 #include "extensions/common/extension_set.h"
55 #endif 55 #endif
56 56
57 using content::GlobalRequestID; 57 using content::GlobalRequestID;
58 using content::NavigationController; 58 using content::NavigationController;
59 using content::WebContents; 59 using content::WebContents;
60 60
61 class BrowserNavigatorWebContentsAdoption { 61 class BrowserNavigatorWebContentsAdoption {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // See if we can open the tab in the window this navigator is bound to. 147 // See if we can open the tab in the window this navigator is bound to.
148 if (params->browser && WindowCanOpenTabs(params->browser)) 148 if (params->browser && WindowCanOpenTabs(params->browser))
149 return params->browser; 149 return params->browser;
150 // Find a compatible window and re-execute this command in it. Otherwise 150 // Find a compatible window and re-execute this command in it. Otherwise
151 // re-run with NEW_WINDOW. 151 // re-run with NEW_WINDOW.
152 return GetOrCreateBrowser(profile, params->host_desktop_type); 152 return GetOrCreateBrowser(profile, params->host_desktop_type);
153 case NEW_POPUP: { 153 case NEW_POPUP: {
154 // Make a new popup window. 154 // Make a new popup window.
155 // Coerce app-style if |source| represents an app. 155 // Coerce app-style if |source| represents an app.
156 std::string app_name; 156 std::string app_name;
157 #if defined(ENABLE_EXTENSIONS)
157 if (!params->extension_app_id.empty()) { 158 if (!params->extension_app_id.empty()) {
158 app_name = web_app::GenerateApplicationNameFromExtensionId( 159 app_name = web_app::GenerateApplicationNameFromExtensionId(
159 params->extension_app_id); 160 params->extension_app_id);
160 } else if (params->browser && !params->browser->app_name().empty()) { 161 } else if (params->browser && !params->browser->app_name().empty()) {
161 app_name = params->browser->app_name(); 162 app_name = params->browser->app_name();
162 } else if (params->source_contents) { 163 } else if (params->source_contents) {
163 extensions::TabHelper* extensions_tab_helper = 164 extensions::TabHelper* extensions_tab_helper =
164 extensions::TabHelper::FromWebContents(params->source_contents); 165 extensions::TabHelper::FromWebContents(params->source_contents);
165 if (extensions_tab_helper && extensions_tab_helper->is_app()) { 166 if (extensions_tab_helper && extensions_tab_helper->is_app()) {
166 app_name = web_app::GenerateApplicationNameFromExtensionId( 167 app_name = web_app::GenerateApplicationNameFromExtensionId(
167 extensions_tab_helper->extension_app()->id()); 168 extensions_tab_helper->extension_app()->id());
168 } 169 }
169 } 170 }
171 #endif
170 if (app_name.empty()) { 172 if (app_name.empty()) {
171 Browser::CreateParams browser_params( 173 Browser::CreateParams browser_params(
172 Browser::TYPE_POPUP, profile, params->host_desktop_type); 174 Browser::TYPE_POPUP, profile, params->host_desktop_type);
173 browser_params.trusted_source = params->trusted_source; 175 browser_params.trusted_source = params->trusted_source;
174 browser_params.initial_bounds = params->window_bounds; 176 browser_params.initial_bounds = params->window_bounds;
175 return new Browser(browser_params); 177 return new Browser(browser_params);
176 } 178 }
177 179
178 return new Browser(Browser::CreateParams::CreateForApp( 180 return new Browser(Browser::CreateParams::CreateForApp(
179 app_name, 181 app_name,
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 params.browser->window()->GetNativeWindow(); 367 params.browser->window()->GetNativeWindow();
366 } 368 }
367 #endif 369 #endif
368 370
369 WebContents* target_contents = WebContents::Create(create_params); 371 WebContents* target_contents = WebContents::Create(create_params);
370 372
371 // New tabs can have WebUI URLs that will make calls back to arbitrary 373 // New tabs can have WebUI URLs that will make calls back to arbitrary
372 // tab helpers, so the entire set of tab helpers needs to be set up 374 // tab helpers, so the entire set of tab helpers needs to be set up
373 // immediately. 375 // immediately.
374 BrowserNavigatorWebContentsAdoption::AttachTabHelpers(target_contents); 376 BrowserNavigatorWebContentsAdoption::AttachTabHelpers(target_contents);
377 #if defined(ENABLE_EXTENSIONS)
375 extensions::TabHelper::FromWebContents(target_contents)-> 378 extensions::TabHelper::FromWebContents(target_contents)->
376 SetExtensionAppById(params.extension_app_id); 379 SetExtensionAppById(params.extension_app_id);
380 #endif
377 return target_contents; 381 return target_contents;
378 } 382 }
379 383
380 // If a prerendered page exists for |url|, replace the page at 384 // If a prerendered page exists for |url|, replace the page at
381 // |params->target_contents| with it and update to point to the swapped-in 385 // |params->target_contents| with it and update to point to the swapped-in
382 // WebContents. 386 // WebContents.
383 bool SwapInPrerender(const GURL& url, chrome::NavigateParams* params) { 387 bool SwapInPrerender(const GURL& url, chrome::NavigateParams* params) {
384 Profile* profile = 388 Profile* profile =
385 Profile::FromBrowserContext(params->target_contents->GetBrowserContext()); 389 Profile::FromBrowserContext(params->target_contents->GetBrowserContext());
386 InstantSearchPrerenderer* prerenderer = 390 InstantSearchPrerenderer* prerenderer =
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 bool reverse_on_redirect = false; 769 bool reverse_on_redirect = false;
766 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( 770 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary(
767 &rewritten_url, browser_context, &reverse_on_redirect); 771 &rewritten_url, browser_context, &reverse_on_redirect);
768 772
769 // Some URLs are mapped to uber subpages. Do not allow them in incognito. 773 // Some URLs are mapped to uber subpages. Do not allow them in incognito.
770 return !(rewritten_url.scheme() == content::kChromeUIScheme && 774 return !(rewritten_url.scheme() == content::kChromeUIScheme &&
771 rewritten_url.host() == chrome::kChromeUIUberHost); 775 rewritten_url.host() == chrome::kChromeUIUberHost);
772 } 776 }
773 777
774 } // namespace chrome 778 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_commands.cc ('k') | chrome/common/localized_error.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698