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

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

Issue 536533004: Android: Remove more browser extensions code, and fullscreen ui. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ext_browser_clean
Patch Set: Created 6 years, 3 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 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_commands.h" 5 #include "chrome/browser/ui/browser_commands.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 #include "content/public/browser/notification_service.h" 73 #include "content/public/browser/notification_service.h"
74 #include "content/public/browser/page_navigator.h" 74 #include "content/public/browser/page_navigator.h"
75 #include "content/public/browser/render_view_host.h" 75 #include "content/public/browser/render_view_host.h"
76 #include "content/public/browser/render_widget_host_view.h" 76 #include "content/public/browser/render_widget_host_view.h"
77 #include "content/public/browser/user_metrics.h" 77 #include "content/public/browser/user_metrics.h"
78 #include "content/public/browser/web_contents.h" 78 #include "content/public/browser/web_contents.h"
79 #include "content/public/common/renderer_preferences.h" 79 #include "content/public/common/renderer_preferences.h"
80 #include "content/public/common/url_constants.h" 80 #include "content/public/common/url_constants.h"
81 #include "content/public/common/url_utils.h" 81 #include "content/public/common/url_utils.h"
82 #include "content/public/common/user_agent.h" 82 #include "content/public/common/user_agent.h"
83 #include "extensions/browser/extension_registry.h"
84 #include "extensions/browser/extension_system.h"
85 #include "extensions/common/extension.h"
86 #include "extensions/common/extension_set.h"
87 #include "net/base/escape.h" 83 #include "net/base/escape.h"
88 #include "ui/events/keycodes/keyboard_codes.h" 84 #include "ui/events/keycodes/keyboard_codes.h"
89 85
90 #if defined(OS_WIN) 86 #if defined(OS_WIN)
91 #include "chrome/browser/ui/metro_pin_tab_helper_win.h" 87 #include "chrome/browser/ui/metro_pin_tab_helper_win.h"
92 #endif 88 #endif
93 89
90 #if defined(ENABLE_EXTENSIONS)
91 #include "extensions/browser/extension_registry.h"
92 #include "extensions/browser/extension_system.h"
93 #include "extensions/common/extension.h"
94 #include "extensions/common/extension_set.h"
95 #endif
96
94 #if defined(ENABLE_PRINTING) 97 #if defined(ENABLE_PRINTING)
95 #if defined(ENABLE_FULL_PRINTING) 98 #if defined(ENABLE_FULL_PRINTING)
96 #include "chrome/browser/printing/print_preview_dialog_controller.h" 99 #include "chrome/browser/printing/print_preview_dialog_controller.h"
97 #include "chrome/browser/printing/print_view_manager.h" 100 #include "chrome/browser/printing/print_view_manager.h"
98 #else 101 #else
99 #include "chrome/browser/printing/print_view_manager_basic.h" 102 #include "chrome/browser/printing/print_view_manager_basic.h"
100 #endif // defined(ENABLE_FULL_PRINTING) 103 #endif // defined(ENABLE_FULL_PRINTING)
101 #endif // defined(ENABLE_PRINTING) 104 #endif // defined(ENABLE_PRINTING)
102 105
103 namespace { 106 namespace {
(...skipping 21 matching lines...) Expand all
125 model && model->loaded() && browser->is_type_tabbed() && 128 model && model->loaded() && browser->is_type_tabbed() &&
126 (!check_remove_bookmark_ui || 129 (!check_remove_bookmark_ui ||
127 !chrome::ShouldRemoveBookmarkThisPageUI(browser->profile())); 130 !chrome::ShouldRemoveBookmarkThisPageUI(browser->profile()));
128 } 131 }
129 132
130 bool GetBookmarkOverrideCommand( 133 bool GetBookmarkOverrideCommand(
131 Profile* profile, 134 Profile* profile,
132 const extensions::Extension** extension, 135 const extensions::Extension** extension,
133 extensions::Command* command, 136 extensions::Command* command,
134 extensions::CommandService::ExtensionCommandType* command_type) { 137 extensions::CommandService::ExtensionCommandType* command_type) {
138 #if defined(ENABLE_EXTENSIONS)
135 DCHECK(extension); 139 DCHECK(extension);
136 DCHECK(command); 140 DCHECK(command);
137 DCHECK(command_type); 141 DCHECK(command_type);
138 142
139 ui::Accelerator bookmark_page_accelerator = 143 ui::Accelerator bookmark_page_accelerator =
140 chrome::GetPrimaryChromeAcceleratorForCommandId(IDC_BOOKMARK_PAGE); 144 chrome::GetPrimaryChromeAcceleratorForCommandId(IDC_BOOKMARK_PAGE);
141 if (bookmark_page_accelerator.key_code() == ui::VKEY_UNKNOWN) 145 if (bookmark_page_accelerator.key_code() == ui::VKEY_UNKNOWN)
142 return false; 146 return false;
143 147
144 extensions::CommandService* command_service = 148 extensions::CommandService* command_service =
145 extensions::CommandService::Get(profile); 149 extensions::CommandService::Get(profile);
146 const extensions::ExtensionSet& extension_set = 150 const extensions::ExtensionSet& extension_set =
147 extensions::ExtensionRegistry::Get(profile)->enabled_extensions(); 151 extensions::ExtensionRegistry::Get(profile)->enabled_extensions();
148 for (extensions::ExtensionSet::const_iterator i = extension_set.begin(); 152 for (extensions::ExtensionSet::const_iterator i = extension_set.begin();
149 i != extension_set.end(); 153 i != extension_set.end();
150 ++i) { 154 ++i) {
151 extensions::Command prospective_command; 155 extensions::Command prospective_command;
152 extensions::CommandService::ExtensionCommandType prospective_command_type; 156 extensions::CommandService::ExtensionCommandType prospective_command_type;
153 if (command_service->GetBoundExtensionCommand((*i)->id(), 157 if (command_service->GetBoundExtensionCommand((*i)->id(),
154 bookmark_page_accelerator, 158 bookmark_page_accelerator,
155 &prospective_command, 159 &prospective_command,
156 &prospective_command_type)) { 160 &prospective_command_type)) {
157 *extension = i->get(); 161 *extension = i->get();
158 *command = prospective_command; 162 *command = prospective_command;
159 *command_type = prospective_command_type; 163 *command_type = prospective_command_type;
160 return true; 164 return true;
161 } 165 }
162 } 166 }
167 #endif
163 168
164 return false; 169 return false;
165 } 170 }
166 171
167 void BookmarkCurrentPageInternal(Browser* browser) { 172 void BookmarkCurrentPageInternal(Browser* browser) {
168 content::RecordAction(UserMetricsAction("Star")); 173 content::RecordAction(UserMetricsAction("Star"));
169 174
170 BookmarkModel* model = 175 BookmarkModel* model =
171 BookmarkModelFactory::GetForProfile(browser->profile()); 176 BookmarkModelFactory::GetForProfile(browser->profile());
172 if (!model || !model->loaded()) 177 if (!model || !model->loaded())
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 if (google_util::IsGoogleHomePageUrl( 464 if (google_util::IsGoogleHomePageUrl(
460 GURL(pref_service->GetString(prefs::kHomePage)))) { 465 GURL(pref_service->GetString(prefs::kHomePage)))) {
461 extra_headers = RLZTracker::GetAccessPointHttpHeader( 466 extra_headers = RLZTracker::GetAccessPointHttpHeader(
462 RLZTracker::ChromeHomePage()); 467 RLZTracker::ChromeHomePage());
463 } 468 }
464 } 469 }
465 #endif // defined(ENABLE_RLZ) && !defined(OS_IOS) 470 #endif // defined(ENABLE_RLZ) && !defined(OS_IOS)
466 471
467 GURL url = browser->profile()->GetHomePage(); 472 GURL url = browser->profile()->GetHomePage();
468 473
474 #if defined(ENABLE_EXTENSIONS)
469 // Streamlined hosted apps should return to their launch page when the home 475 // Streamlined hosted apps should return to their launch page when the home
470 // button is pressed. 476 // button is pressed.
471 if (browser->is_app()) { 477 if (browser->is_app()) {
472 const extensions::Extension* extension = 478 const extensions::Extension* extension =
473 extensions::ExtensionRegistry::Get(browser->profile()) 479 extensions::ExtensionRegistry::Get(browser->profile())
474 ->GetExtensionById( 480 ->GetExtensionById(
475 web_app::GetExtensionIdFromApplicationName(browser->app_name()), 481 web_app::GetExtensionIdFromApplicationName(browser->app_name()),
476 extensions::ExtensionRegistry::EVERYTHING); 482 extensions::ExtensionRegistry::EVERYTHING);
477 if (!extension) 483 if (!extension)
478 return; 484 return;
479 485
480 url = extensions::AppLaunchInfo::GetLaunchWebURL(extension); 486 url = extensions::AppLaunchInfo::GetLaunchWebURL(extension);
481 } 487 }
488 #endif
482 489
483 OpenURLParams params( 490 OpenURLParams params(
484 url, Referrer(), disposition, 491 url, Referrer(), disposition,
485 content::PageTransitionFromInt( 492 content::PageTransitionFromInt(
486 content::PAGE_TRANSITION_AUTO_BOOKMARK | 493 content::PAGE_TRANSITION_AUTO_BOOKMARK |
487 content::PAGE_TRANSITION_HOME_PAGE), 494 content::PAGE_TRANSITION_HOME_PAGE),
488 false); 495 false);
489 params.extra_headers = extra_headers; 496 params.extra_headers = extra_headers;
490 browser->OpenURL(params); 497 browser->OpenURL(params);
491 } 498 }
(...skipping 27 matching lines...) Expand all
519 NavigateParams params(browser, url, page_transition); 526 NavigateParams params(browser, url, page_transition);
520 params.disposition = open_disposition; 527 params.disposition = open_disposition;
521 // Use ADD_INHERIT_OPENER so that all pages opened by the omnibox at least 528 // Use ADD_INHERIT_OPENER so that all pages opened by the omnibox at least
522 // inherit the opener. In some cases the tabstrip will determine the group 529 // inherit the opener. In some cases the tabstrip will determine the group
523 // should be inherited, in which case the group is inherited instead of the 530 // should be inherited, in which case the group is inherited instead of the
524 // opener. 531 // opener.
525 params.tabstrip_add_types = 532 params.tabstrip_add_types =
526 TabStripModel::ADD_FORCE_INDEX | TabStripModel::ADD_INHERIT_OPENER; 533 TabStripModel::ADD_FORCE_INDEX | TabStripModel::ADD_INHERIT_OPENER;
527 Navigate(&params); 534 Navigate(&params);
528 535
536 #if defined(ENABLE_EXTENSIONS)
529 DCHECK(extensions::ExtensionSystem::Get( 537 DCHECK(extensions::ExtensionSystem::Get(
530 browser->profile())->extension_service()); 538 browser->profile())->extension_service());
531 const extensions::Extension* extension = 539 const extensions::Extension* extension =
532 extensions::ExtensionRegistry::Get(browser->profile()) 540 extensions::ExtensionRegistry::Get(browser->profile())
533 ->enabled_extensions().GetAppByURL(url); 541 ->enabled_extensions().GetAppByURL(url);
534 if (extension) { 542 if (extension) {
535 CoreAppLauncherHandler::RecordAppLaunchType( 543 CoreAppLauncherHandler::RecordAppLaunchType(
536 extension_misc::APP_LAUNCH_OMNIBOX_LOCATION, 544 extension_misc::APP_LAUNCH_OMNIBOX_LOCATION,
537 extension->GetType()); 545 extension->GetType());
538 } 546 }
547 #endif
539 } 548 }
540 549
541 void Stop(Browser* browser) { 550 void Stop(Browser* browser) {
542 content::RecordAction(UserMetricsAction("Stop")); 551 content::RecordAction(UserMetricsAction("Stop"));
543 browser->tab_strip_model()->GetActiveWebContents()->Stop(); 552 browser->tab_strip_model()->GetActiveWebContents()->Stop();
544 } 553 }
545 554
546 void NewWindow(Browser* browser) { 555 void NewWindow(Browser* browser) {
547 NewEmptyWindow(browser->profile()->GetOriginalProfile(), 556 NewEmptyWindow(browser->profile()->GetOriginalProfile(),
548 browser->host_desktop_type()); 557 browser->host_desktop_type());
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 browser->profile(), 1269 browser->profile(),
1261 browser->host_desktop_type())); 1270 browser->host_desktop_type()));
1262 app_browser->tab_strip_model()->AppendWebContents(contents, true); 1271 app_browser->tab_strip_model()->AppendWebContents(contents, true);
1263 1272
1264 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1273 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1265 contents->GetRenderViewHost()->SyncRendererPrefs(); 1274 contents->GetRenderViewHost()->SyncRendererPrefs();
1266 app_browser->window()->Show(); 1275 app_browser->window()->Show();
1267 } 1276 }
1268 1277
1269 } // namespace chrome 1278 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698