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

Side by Side Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.cc

Issue 515563003: Remove dependency of chrome in WebRequestPermissions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move KWebStoreAppId to extensions. 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 (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/webui/ntp/app_launcher_handler.h" 5 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "apps/metrics_names.h" 9 #include "apps/metrics_names.h"
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 &icon_small_exists); 154 &icon_small_exists);
155 value->SetString("icon_small", icon_small.spec()); 155 value->SetString("icon_small", icon_small.spec());
156 value->SetBoolean("icon_small_exists", icon_small_exists); 156 value->SetBoolean("icon_small_exists", icon_small_exists);
157 value->SetInteger("launch_container", 157 value->SetInteger("launch_container",
158 extensions::AppLaunchInfo::GetLaunchContainer(extension)); 158 extensions::AppLaunchInfo::GetLaunchContainer(extension));
159 ExtensionPrefs* prefs = ExtensionPrefs::Get(service->profile()); 159 ExtensionPrefs* prefs = ExtensionPrefs::Get(service->profile());
160 value->SetInteger("launch_type", extensions::GetLaunchType(prefs, extension)); 160 value->SetInteger("launch_type", extensions::GetLaunchType(prefs, extension));
161 value->SetBoolean("is_component", 161 value->SetBoolean("is_component",
162 extension->location() == extensions::Manifest::COMPONENT); 162 extension->location() == extensions::Manifest::COMPONENT);
163 value->SetBoolean("is_webstore", 163 value->SetBoolean("is_webstore",
164 extension->id() == extension_misc::kWebStoreAppId); 164 extension->id() == extensions::kWebStoreAppId);
165 165
166 AppSorting* sorting = prefs->app_sorting(); 166 AppSorting* sorting = prefs->app_sorting();
167 syncer::StringOrdinal page_ordinal = sorting->GetPageOrdinal(extension->id()); 167 syncer::StringOrdinal page_ordinal = sorting->GetPageOrdinal(extension->id());
168 if (!page_ordinal.IsValid()) { 168 if (!page_ordinal.IsValid()) {
169 // Make sure every app has a page ordinal (some predate the page ordinal). 169 // Make sure every app has a page ordinal (some predate the page ordinal).
170 // The webstore app should be on the first page. 170 // The webstore app should be on the first page.
171 page_ordinal = extension->id() == extension_misc::kWebStoreAppId ? 171 page_ordinal = extension->id() == extensions::kWebStoreAppId ?
172 sorting->CreateFirstAppPageOrdinal() : 172 sorting->CreateFirstAppPageOrdinal() :
173 sorting->GetNaturalAppPageOrdinal(); 173 sorting->GetNaturalAppPageOrdinal();
174 sorting->SetPageOrdinal(extension->id(), page_ordinal); 174 sorting->SetPageOrdinal(extension->id(), page_ordinal);
175 } 175 }
176 value->SetInteger("page_index", 176 value->SetInteger("page_index",
177 sorting->PageStringOrdinalAsInteger(page_ordinal)); 177 sorting->PageStringOrdinalAsInteger(page_ordinal));
178 178
179 syncer::StringOrdinal app_launch_ordinal = 179 syncer::StringOrdinal app_launch_ordinal =
180 sorting->GetAppLaunchOrdinal(extension->id()); 180 sorting->GetAppLaunchOrdinal(extension->id());
181 if (!app_launch_ordinal.IsValid()) { 181 if (!app_launch_ordinal.IsValid()) {
182 // Make sure every app has a launch ordinal (some predate the launch 182 // Make sure every app has a launch ordinal (some predate the launch
183 // ordinal). The webstore's app launch ordinal is always set to the first 183 // ordinal). The webstore's app launch ordinal is always set to the first
184 // position. 184 // position.
185 app_launch_ordinal = extension->id() == extension_misc::kWebStoreAppId ? 185 app_launch_ordinal = extension->id() == extensions::kWebStoreAppId ?
186 sorting->CreateFirstAppLaunchOrdinal(page_ordinal) : 186 sorting->CreateFirstAppLaunchOrdinal(page_ordinal) :
187 sorting->CreateNextAppLaunchOrdinal(page_ordinal); 187 sorting->CreateNextAppLaunchOrdinal(page_ordinal);
188 sorting->SetAppLaunchOrdinal(extension->id(), app_launch_ordinal); 188 sorting->SetAppLaunchOrdinal(extension->id(), app_launch_ordinal);
189 } 189 }
190 value->SetString("app_launch_ordinal", app_launch_ordinal.ToInternalValue()); 190 value->SetString("app_launch_ordinal", app_launch_ordinal.ToInternalValue());
191 } 191 }
192 192
193 void AppLauncherHandler::RegisterMessages() { 193 void AppLauncherHandler::RegisterMessages() {
194 registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_NTP, 194 registrar_.Add(this, chrome::NOTIFICATION_APP_INSTALLED_TO_NTP,
195 content::Source<WebContents>(web_ui()->GetWebContents())); 195 content::Source<WebContents>(web_ui()->GetWebContents()));
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 // Prompt the user to re-enable the application if disabled. 500 // Prompt the user to re-enable the application if disabled.
501 if (!extension) { 501 if (!extension) {
502 PromptToEnableApp(extension_id); 502 PromptToEnableApp(extension_id);
503 return; 503 return;
504 } 504 }
505 505
506 Profile* profile = extension_service_->profile(); 506 Profile* profile = extension_service_->profile();
507 507
508 WindowOpenDisposition disposition = args->GetSize() > 3 ? 508 WindowOpenDisposition disposition = args->GetSize() > 3 ?
509 webui::GetDispositionFromClick(args, 3) : CURRENT_TAB; 509 webui::GetDispositionFromClick(args, 3) : CURRENT_TAB;
510 if (extension_id != extension_misc::kWebStoreAppId) { 510 if (extension_id != extensions::kWebStoreAppId) {
511 CHECK_NE(launch_bucket, extension_misc::APP_LAUNCH_BUCKET_INVALID); 511 CHECK_NE(launch_bucket, extension_misc::APP_LAUNCH_BUCKET_INVALID);
512 CoreAppLauncherHandler::RecordAppLaunchType(launch_bucket, 512 CoreAppLauncherHandler::RecordAppLaunchType(launch_bucket,
513 extension->GetType()); 513 extension->GetType());
514 } else { 514 } else {
515 CoreAppLauncherHandler::RecordWebStoreLaunch(); 515 CoreAppLauncherHandler::RecordWebStoreLaunch();
516 } 516 }
517 517
518 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB || 518 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB ||
519 disposition == NEW_WINDOW) { 519 disposition == NEW_WINDOW) {
520 // TODO(jamescook): Proper support for background tabs. 520 // TODO(jamescook): Proper support for background tabs.
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 Browser* browser = chrome::FindBrowserWithWebContents( 842 Browser* browser = chrome::FindBrowserWithWebContents(
843 web_ui()->GetWebContents()); 843 web_ui()->GetWebContents());
844 extension_uninstall_dialog_.reset( 844 extension_uninstall_dialog_.reset(
845 extensions::ExtensionUninstallDialog::Create( 845 extensions::ExtensionUninstallDialog::Create(
846 extension_service_->profile(), 846 extension_service_->profile(),
847 browser->window()->GetNativeWindow(), 847 browser->window()->GetNativeWindow(),
848 this)); 848 this));
849 } 849 }
850 return extension_uninstall_dialog_.get(); 850 return extension_uninstall_dialog_.get();
851 } 851 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698