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

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 706013004: Move non-browser specific ScreenshotTaker code to ui/snapshot. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge and fix gn Created 6 years 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 | « no previous file | chrome/browser/ui/ash/ash_init.cc » ('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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 #include "ui/base/resource/resource_bundle.h" 157 #include "ui/base/resource/resource_bundle.h"
158 #include "url/gurl.h" 158 #include "url/gurl.h"
159 159
160 #if defined(OS_CHROMEOS) 160 #if defined(OS_CHROMEOS)
161 #include "ash/accelerators/accelerator_controller.h" 161 #include "ash/accelerators/accelerator_controller.h"
162 #include "ash/accelerators/accelerator_table.h" 162 #include "ash/accelerators/accelerator_table.h"
163 #include "ash/shell.h" 163 #include "ash/shell.h"
164 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 164 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
165 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 165 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
166 #include "chrome/browser/profiles/profile_manager.h" 166 #include "chrome/browser/profiles/profile_manager.h"
167 #include "chrome/browser/ui/ash/screenshot_taker.h" 167 #include "chrome/browser/ui/ash/chrome_screenshot_grabber.h"
168 #include "chromeos/audio/cras_audio_handler.h" 168 #include "chromeos/audio/cras_audio_handler.h"
169 #include "ui/chromeos/accessibility_types.h" 169 #include "ui/chromeos/accessibility_types.h"
170 #include "ui/keyboard/keyboard_util.h" 170 #include "ui/keyboard/keyboard_util.h"
171 #include "ui/snapshot/screenshot_grabber.h"
171 #endif 172 #endif
172 173
173 #if !defined(OS_MACOSX) 174 #if !defined(OS_MACOSX)
174 #include "base/basictypes.h" 175 #include "base/basictypes.h"
175 #include "base/compiler_specific.h" 176 #include "base/compiler_specific.h"
176 #include "chrome/browser/ui/extensions/application_launch.h" 177 #include "chrome/browser/ui/extensions/application_launch.h"
177 #include "extensions/browser/app_window/app_window.h" 178 #include "extensions/browser/app_window/app_window.h"
178 #include "extensions/browser/app_window/app_window_registry.h" 179 #include "extensions/browser/app_window/app_window_registry.h"
179 #include "extensions/browser/app_window/native_app_window.h" 180 #include "extensions/browser/app_window/native_app_window.h"
180 #include "ui/base/window_open_disposition.h" 181 #include "ui/base/window_open_disposition.h"
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 PolicyMap policies; 648 PolicyMap policies;
648 policies.Set(key::kDisableScreenshots, 649 policies.Set(key::kDisableScreenshots,
649 POLICY_LEVEL_MANDATORY, 650 POLICY_LEVEL_MANDATORY,
650 POLICY_SCOPE_USER, 651 POLICY_SCOPE_USER,
651 new base::FundamentalValue(!enabled), 652 new base::FundamentalValue(!enabled),
652 NULL); 653 NULL);
653 UpdateProviderPolicy(policies); 654 UpdateProviderPolicy(policies);
654 } 655 }
655 656
656 #if defined(OS_CHROMEOS) 657 #if defined(OS_CHROMEOS)
657 class QuitMessageLoopAfterScreenshot : public ScreenshotTakerObserver { 658 class QuitMessageLoopAfterScreenshot : public ui::ScreenshotGrabberObserver {
658 public: 659 public:
659 virtual void OnScreenshotCompleted( 660 virtual void OnScreenshotCompleted(
660 ScreenshotTakerObserver::Result screenshot_result, 661 ScreenshotGrabberObserver::Result screenshot_result,
661 const base::FilePath& screenshot_path) override { 662 const base::FilePath& screenshot_path) override {
662 BrowserThread::PostTaskAndReply(BrowserThread::IO, 663 BrowserThread::PostTaskAndReply(BrowserThread::IO,
663 FROM_HERE, 664 FROM_HERE,
664 base::Bind(base::DoNothing), 665 base::Bind(base::DoNothing),
665 base::MessageLoop::QuitClosure()); 666 base::MessageLoop::QuitClosure());
666 } 667 }
667 668
668 virtual ~QuitMessageLoopAfterScreenshot() {} 669 virtual ~QuitMessageLoopAfterScreenshot() {}
669 }; 670 };
670 671
671 void TestScreenshotFile(bool enabled) { 672 void TestScreenshotFile(bool enabled) {
672 // AddObserver is an ash-specific method, so just replace the screenshot 673 // AddObserver is an ash-specific method, so just replace the screenshot
673 // taker with one we've created here. 674 // grabber with one we've created here.
674 scoped_ptr<ScreenshotTaker> screenshot_taker(new ScreenshotTaker); 675 scoped_ptr<ChromeScreenshotGrabber> chrome_screenshot_grabber(
675 // ScreenshotTaker doesn't own this observer, so the observer's lifetime 676 new ChromeScreenshotGrabber);
677 // ScreenshotGrabber doesn't own this observer, so the observer's lifetime
676 // is tied to the test instead. 678 // is tied to the test instead.
677 screenshot_taker->AddObserver(&observer_); 679 chrome_screenshot_grabber->screenshot_grabber()->AddObserver(&observer_);
678 ash::Shell::GetInstance()->accelerator_controller()->SetScreenshotDelegate( 680 ash::Shell::GetInstance()->accelerator_controller()->SetScreenshotDelegate(
679 screenshot_taker.Pass()); 681 chrome_screenshot_grabber.Pass());
680 682
681 SetScreenshotPolicy(enabled); 683 SetScreenshotPolicy(enabled);
682 ash::Shell::GetInstance()->accelerator_controller()->PerformActionIfEnabled( 684 ash::Shell::GetInstance()->accelerator_controller()->PerformActionIfEnabled(
683 ash::TAKE_SCREENSHOT); 685 ash::TAKE_SCREENSHOT);
684 686
685 content::RunMessageLoop(); 687 content::RunMessageLoop();
688 static_cast<ChromeScreenshotGrabber*>(ash::Shell::GetInstance()
689 ->accelerator_controller()
690 ->screenshot_delegate())
691 ->screenshot_grabber()
692 ->RemoveObserver(&observer_);
686 } 693 }
687 #endif 694 #endif
688 695
689 ExtensionService* extension_service() { 696 ExtensionService* extension_service() {
690 extensions::ExtensionSystem* system = 697 extensions::ExtensionSystem* system =
691 extensions::ExtensionSystem::Get(browser()->profile()); 698 extensions::ExtensionSystem::Get(browser()->profile());
692 return system->extension_service(); 699 return system->extension_service();
693 } 700 }
694 701
695 const extensions::Extension* InstallExtension( 702 const extensions::Extension* InstallExtension(
(...skipping 2732 matching lines...) Expand 10 before | Expand all | Expand 10 after
3428 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 3435 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
3429 browser2->tab_strip_model()->GetActiveWebContents(), 3436 browser2->tab_strip_model()->GetActiveWebContents(),
3430 "domAutomationController.send(window.showModalDialog !== undefined);", 3437 "domAutomationController.send(window.showModalDialog !== undefined);",
3431 &result)); 3438 &result));
3432 EXPECT_TRUE(result); 3439 EXPECT_TRUE(result);
3433 } 3440 }
3434 3441
3435 #endif // !defined(CHROME_OS) 3442 #endif // !defined(CHROME_OS)
3436 3443
3437 } // namespace policy 3444 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/ash/ash_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698