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

Side by Side Diff: chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc

Issue 936123002: [Extensions] Implement chrome.runtime.openOptionsPage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: default impl Created 5 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/api/runtime/chrome_runtime_api_delegate.h" 5 #include "chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/extension_tab_util.h"
14 #include "chrome/browser/extensions/updater/extension_updater.h" 15 #include "chrome/browser/extensions/updater/extension_updater.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser_finder.h" 17 #include "chrome/browser/ui/browser_finder.h"
17 #include "chrome/browser/ui/browser_navigator.h" 18 #include "chrome/browser/ui/browser_navigator.h"
18 #include "chrome/browser/ui/browser_window.h" 19 #include "chrome/browser/ui/browser_window.h"
19 #include "components/update_client/update_query_params.h" 20 #include "components/update_client/update_query_params.h"
20 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
21 #include "extensions/browser/extension_system.h" 22 #include "extensions/browser/extension_system.h"
22 #include "extensions/browser/notification_types.h" 23 #include "extensions/browser/notification_types.h"
23 #include "extensions/browser/warning_service.h" 24 #include "extensions/browser/warning_service.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 chromeos::DBusThreadManager::Get() 234 chromeos::DBusThreadManager::Get()
234 ->GetPowerManagerClient() 235 ->GetPowerManagerClient()
235 ->RequestRestart(); 236 ->RequestRestart();
236 return true; 237 return true;
237 } 238 }
238 #endif 239 #endif
239 *error_message = "Function available only for ChromeOS kiosk mode."; 240 *error_message = "Function available only for ChromeOS kiosk mode.";
240 return false; 241 return false;
241 } 242 }
242 243
244 bool ChromeRuntimeAPIDelegate::OpenOptionsPage(const Extension* extension) {
245 Profile* profile = Profile::FromBrowserContext(browser_context_);
246 Browser* browser =
247 chrome::FindLastActiveWithProfile(profile, chrome::GetActiveDesktop());
248 if (!browser)
249 return false;
250 return extensions::ExtensionTabUtil::OpenOptionsPage(extension, browser);
251 }
252
243 void ChromeRuntimeAPIDelegate::Observe( 253 void ChromeRuntimeAPIDelegate::Observe(
244 int type, 254 int type,
245 const content::NotificationSource& source, 255 const content::NotificationSource& source,
246 const content::NotificationDetails& details) { 256 const content::NotificationDetails& details) {
247 DCHECK(type == extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND); 257 DCHECK(type == extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND);
248 typedef const std::pair<std::string, Version> UpdateDetails; 258 typedef const std::pair<std::string, Version> UpdateDetails;
249 const std::string& id = content::Details<UpdateDetails>(details)->first; 259 const std::string& id = content::Details<UpdateDetails>(details)->first;
250 const Version& version = content::Details<UpdateDetails>(details)->second; 260 const Version& version = content::Details<UpdateDetails>(details)->second;
251 if (version.IsValid()) { 261 if (version.IsValid()) {
252 CallUpdateCallbacks( 262 CallUpdateCallbacks(
(...skipping 21 matching lines...) Expand all
274 const UpdateCheckResult& result) { 284 const UpdateCheckResult& result) {
275 UpdateCallbackList callbacks = pending_update_checks_[extension_id]; 285 UpdateCallbackList callbacks = pending_update_checks_[extension_id];
276 pending_update_checks_.erase(extension_id); 286 pending_update_checks_.erase(extension_id);
277 for (UpdateCallbackList::const_iterator iter = callbacks.begin(); 287 for (UpdateCallbackList::const_iterator iter = callbacks.begin();
278 iter != callbacks.end(); 288 iter != callbacks.end();
279 ++iter) { 289 ++iter) {
280 const UpdateCheckCallback& callback = *iter; 290 const UpdateCheckCallback& callback = *iter;
281 callback.Run(result); 291 callback.Run(result);
282 } 292 }
283 } 293 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.h ('k') | chrome/browser/extensions/extension_tab_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698