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

Side by Side Diff: extensions/browser/api/runtime/runtime_api.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 "extensions/browser/api/runtime/runtime_api.h" 5 #include "extensions/browser/api/runtime/runtime_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 28 matching lines...) Expand all
39 using content::BrowserContext; 39 using content::BrowserContext;
40 40
41 namespace extensions { 41 namespace extensions {
42 42
43 namespace runtime = core_api::runtime; 43 namespace runtime = core_api::runtime;
44 44
45 namespace { 45 namespace {
46 46
47 const char kNoBackgroundPageError[] = "You do not have a background page."; 47 const char kNoBackgroundPageError[] = "You do not have a background page.";
48 const char kPageLoadError[] = "Background page failed to load."; 48 const char kPageLoadError[] = "Background page failed to load.";
49 const char kFailedToCreateOptionsPage[] = "Could not create an options page.";
49 const char kInstallId[] = "id"; 50 const char kInstallId[] = "id";
50 const char kInstallReason[] = "reason"; 51 const char kInstallReason[] = "reason";
51 const char kInstallReasonChromeUpdate[] = "chrome_update"; 52 const char kInstallReasonChromeUpdate[] = "chrome_update";
52 const char kInstallReasonUpdate[] = "update"; 53 const char kInstallReasonUpdate[] = "update";
53 const char kInstallReasonInstall[] = "install"; 54 const char kInstallReasonInstall[] = "install";
54 const char kInstallReasonSharedModuleUpdate[] = "shared_module_update"; 55 const char kInstallReasonSharedModuleUpdate[] = "shared_module_update";
55 const char kInstallPreviousVersion[] = "previousVersion"; 56 const char kInstallPreviousVersion[] = "previousVersion";
56 const char kInvalidUrlError[] = "Invalid URL."; 57 const char kInvalidUrlError[] = "Invalid URL.";
57 const char kPlatformInfoUnavailable[] = "Platform information unavailable."; 58 const char kPlatformInfoUnavailable[] = "Platform information unavailable.";
58 59
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 262 }
262 263
263 bool RuntimeAPI::GetPlatformInfo(runtime::PlatformInfo* info) { 264 bool RuntimeAPI::GetPlatformInfo(runtime::PlatformInfo* info) {
264 return delegate_->GetPlatformInfo(info); 265 return delegate_->GetPlatformInfo(info);
265 } 266 }
266 267
267 bool RuntimeAPI::RestartDevice(std::string* error_message) { 268 bool RuntimeAPI::RestartDevice(std::string* error_message) {
268 return delegate_->RestartDevice(error_message); 269 return delegate_->RestartDevice(error_message);
269 } 270 }
270 271
272 bool RuntimeAPI::OpenOptionsPage(const Extension* extension) {
273 return delegate_->OpenOptionsPage(extension);
274 }
275
271 /////////////////////////////////////////////////////////////////////////////// 276 ///////////////////////////////////////////////////////////////////////////////
272 277
273 // static 278 // static
274 void RuntimeEventRouter::DispatchOnStartupEvent( 279 void RuntimeEventRouter::DispatchOnStartupEvent(
275 content::BrowserContext* context, 280 content::BrowserContext* context,
276 const std::string& extension_id) { 281 const std::string& extension_id) {
277 DispatchOnStartupEventImpl(context, extension_id, true, NULL); 282 DispatchOnStartupEventImpl(context, extension_id, true, NULL);
278 } 283 }
279 284
280 // static 285 // static
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } 423 }
419 424
420 void RuntimeGetBackgroundPageFunction::OnPageLoaded(ExtensionHost* host) { 425 void RuntimeGetBackgroundPageFunction::OnPageLoaded(ExtensionHost* host) {
421 if (host) { 426 if (host) {
422 Respond(NoArguments()); 427 Respond(NoArguments());
423 } else { 428 } else {
424 Respond(Error(kPageLoadError)); 429 Respond(Error(kPageLoadError));
425 } 430 }
426 } 431 }
427 432
433 ExtensionFunction::ResponseAction RuntimeOpenOptionsPageFunction::Run() {
434 RuntimeAPI* api = RuntimeAPI::GetFactoryInstance()->Get(browser_context());
435 return RespondNow(api->OpenOptionsPage(extension())
436 ? NoArguments()
437 : Error(kFailedToCreateOptionsPage));
438 }
439
428 ExtensionFunction::ResponseAction RuntimeSetUninstallURLFunction::Run() { 440 ExtensionFunction::ResponseAction RuntimeSetUninstallURLFunction::Run() {
429 std::string url_string; 441 std::string url_string;
430 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url_string)); 442 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url_string));
431 443
432 GURL url(url_string); 444 GURL url(url_string);
433 if (!url.is_valid()) { 445 if (!url.is_valid()) {
434 return RespondNow( 446 return RespondNow(
435 Error(ErrorUtils::FormatErrorMessage(kInvalidUrlError, url_string))); 447 Error(ErrorUtils::FormatErrorMessage(kInvalidUrlError, url_string)));
436 } 448 }
437 SetUninstallURL( 449 SetUninstallURL(
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 content::ChildProcessSecurityPolicy* policy = 518 content::ChildProcessSecurityPolicy* policy =
507 content::ChildProcessSecurityPolicy::GetInstance(); 519 content::ChildProcessSecurityPolicy::GetInstance();
508 policy->GrantReadFileSystem(renderer_id, filesystem_id); 520 policy->GrantReadFileSystem(renderer_id, filesystem_id);
509 base::DictionaryValue* dict = new base::DictionaryValue(); 521 base::DictionaryValue* dict = new base::DictionaryValue();
510 dict->SetString("fileSystemId", filesystem_id); 522 dict->SetString("fileSystemId", filesystem_id);
511 dict->SetString("baseName", relative_path); 523 dict->SetString("baseName", relative_path);
512 return RespondNow(OneArgument(dict)); 524 return RespondNow(OneArgument(dict));
513 } 525 }
514 526
515 } // namespace extensions 527 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/runtime/runtime_api.h ('k') | extensions/browser/api/runtime/runtime_api_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698